Using xsl Stylesheet - html view including images

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Marc

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!
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Marc,

Try to replace the

Code: Select all


<xsl:for-each select="//Pfad">
with

Code: Select all


<xsl:for-each select=".//Pfad">
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
Post Reply