Using xsl Stylesheet - html view including images
Having trouble installing Oxygen? Got a bug to report? Post it all here.
Using xsl Stylesheet - html view including images
Post by Marc »
Hi again,
I do have a problem with xsl:for-each select =".". I am trying to show some images in a html view.
My xml code:
<Untersuchung>
<Untersuchungsname>MR-Mammographie</Untersuchungsname>
<ID>01ZC1</ID>
<Termin>2003-08-08</Termin>
<Bild>
<Pfad>Brustkrebs.jpg</Pfad>
<Pfad>MR_Mammographie.jpg</Pfad>
<Pfad>Querschnitt.jpg</Pfad>
<Befund>Brustkrebs, 7mm Durchmesser</Befund>
</Bild>
</Untersuchung>
<Untersuchung>
<Untersuchungsname>Ultraschall des Herzens</Untersuchungsname>
<ID>01ZC2</ID>
<Termin>2003-08-08</Termin>
<Bild>
<Pfad>Herz.jpg</Pfad>
<Befund>o.B.</Befund>
</Bild>
</Untersuchung>
The first for-each works fine. This means I will get both "Untersuchungen".
Now I want to have the three images for the first Untersuchung then the Befund then the one image for the second Untersuchung and at last the Befund. But I get all four images then the Befund in the first and all four in the second Untersuchung. Also I don't know how to handle if I have no image to show (<Pfad/> in html a red X). How can I change this?
My xsl code:
...
<xsl:for-each select="//Untersuchung">
<table>
<colgroup>
<col width="120"/>
<col width="250"/>
</colgroup>
<tr>
<td><b>Untersuchung:</b></td>
<td><b><xsl:value-of select="Untersuchungsname" /></b></td>
</tr>
<tr>
<td><b>ID:</b></td>
<td><b><xsl:value-of select="ID" /></b></td>
</tr>
<tr>
<td><b>Termin:</b></td>
<td><b><xsl:value-of select="Termin" /></b></td>
</tr>
<tr>
<td><b>Bild(er):</b></td>
</tr>
</table>
<xsl:for-each select="//Pfad">
<br/><br/>
<img>
<xsl:attribute name="src">
<xsl:value-of select="."/>
</xsl:attribute>
</img>
</xsl:for-each>
<table>
<colgroup>
<col width="120"/>
<col width="500"/>
</colgroup>
<br></br>
<tr>
<td valign="top"><b>Befund:</b></td>
<td><b><xsl:value-of select="Bild/Befund" /></b></td>
</tr>
</table>
<br/><br/>
</xsl:for-each>
</body>
Thank you George for your help, I am sure you know the mistake!
I do have a problem with xsl:for-each select =".". I am trying to show some images in a html view.
My xml code:
<Untersuchung>
<Untersuchungsname>MR-Mammographie</Untersuchungsname>
<ID>01ZC1</ID>
<Termin>2003-08-08</Termin>
<Bild>
<Pfad>Brustkrebs.jpg</Pfad>
<Pfad>MR_Mammographie.jpg</Pfad>
<Pfad>Querschnitt.jpg</Pfad>
<Befund>Brustkrebs, 7mm Durchmesser</Befund>
</Bild>
</Untersuchung>
<Untersuchung>
<Untersuchungsname>Ultraschall des Herzens</Untersuchungsname>
<ID>01ZC2</ID>
<Termin>2003-08-08</Termin>
<Bild>
<Pfad>Herz.jpg</Pfad>
<Befund>o.B.</Befund>
</Bild>
</Untersuchung>
The first for-each works fine. This means I will get both "Untersuchungen".
Now I want to have the three images for the first Untersuchung then the Befund then the one image for the second Untersuchung and at last the Befund. But I get all four images then the Befund in the first and all four in the second Untersuchung. Also I don't know how to handle if I have no image to show (<Pfad/> in html a red X). How can I change this?
My xsl code:
...
<xsl:for-each select="//Untersuchung">
<table>
<colgroup>
<col width="120"/>
<col width="250"/>
</colgroup>
<tr>
<td><b>Untersuchung:</b></td>
<td><b><xsl:value-of select="Untersuchungsname" /></b></td>
</tr>
<tr>
<td><b>ID:</b></td>
<td><b><xsl:value-of select="ID" /></b></td>
</tr>
<tr>
<td><b>Termin:</b></td>
<td><b><xsl:value-of select="Termin" /></b></td>
</tr>
<tr>
<td><b>Bild(er):</b></td>
</tr>
</table>
<xsl:for-each select="//Pfad">
<br/><br/>
<img>
<xsl:attribute name="src">
<xsl:value-of select="."/>
</xsl:attribute>
</img>
</xsl:for-each>
<table>
<colgroup>
<col width="120"/>
<col width="500"/>
</colgroup>
<br></br>
<tr>
<td valign="top"><b>Befund:</b></td>
<td><b><xsl:value-of select="Bild/Befund" /></b></td>
</tr>
</table>
<br/><br/>
</xsl:for-each>
</body>
Thank you George for your help, I am sure you know the mistake!
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Marc,
Try to replace the
with
If you use //node (<=> root()//node) that means you select all such nodes in the document, while if you use .//node then you select all such nodes that are descendants of the current selected node.
Best Regards,
George
Try to replace the
Code: Select all
<xsl:for-each select="//Pfad">
Code: Select all
<xsl:for-each select=".//Pfad">
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service