choose and Attribute Value Templates { }

Daboo

Usenet Archive
Joined
Nov 5, 2003
Messages
2
Reaction score
0
Hi!

I'm creating dynamic a XML file. in this file are store some informations about images i use in HTML datasheets. i'm going to transform the XML file with XSLT. My Problem is, that {image} allways select ths first attribute in <images>, ingnoring the type of image (the types are 0, 10, 20 or 30). Perhaps, somebody is able to help me with my problem!?!

Here is the important part of my XML File:
###################################################################### <images> <image type="10">D:\Projects\CNC Navigator\CNC Navigator\datasheets\OSV15000C.gif</image> <image type="20">D:\Projects\CNC Navigator\CNC Navigator\datasheets\CSV15000C_2.gif</image> </images> ######################################################################

In my XSLT i'm going to create two tables with the pictures...here is the first one...:
###################################################################### <table width="100%"> <tr class="tableHeader"> <td>Motor Characteristics</td> </tr> <xsl:for-each select="clsServomotor/images"> <xsl:choose> <xsl:when test="image/@type=20"> <tr> <td> <a href="{image}" target="_blank"> <img src="{image}" width="700" /> </a> </td> </tr> </xsl:when> <xsl:when test="image/@type=30"> <tr> <td> <a href="{image}" target="_blank"> <img src="{image}" width="700" /> </a> </td> </tr> </xsl:when> </xsl:choose> </xsl:for-each> </table> ######################################################################

and the second table...:
###################################################################### <table width="100%"> <tr class="tableHeader"> <td>Outline Dimensions</td> </tr> <xsl:for-each select="clsServomotor/images"> <xsl:choose> <xsl:when test="image/@type=10"> <tr> <td> <a href="{image}" target="_blank"> <img src="{image}" width="700" /> </a> </td> </tr> </xsl:when> </xsl:choose> </xsl:for-each> </table> ######################################################################

Many Thanks!

Greetings, DaBoo
 

Patrick TJ McPhee

Usenet Archive
Joined
Apr 2, 2000
Messages
269
Reaction score
0
% My Problem is, that {image} allways select ths first attribute in % <images>, ingnoring the type of image (the types are 0, 10, 20 or 30). % Perhaps, somebody is able to help me with my problem!?!

Actually, {image} always selects the text content of the first image element (and all its children, but it doesn't have any children in this case). You need to use a different XPath expression in the for-each loop to get the effect you want. Try

<xsl:for-each select="clsServomotor/images/image">
<xsl:choose>
<xsl:when test="@type=20">
<tr>
<td>
<a href="{.}" target="_blank">
<img src="{.}" width="700" />
</a>
</td>
</tr>
</xsl:when>
<xsl:when test="@type=30">
<tr>
<td>
<a href="{.}" target="_blank">
<img src="{.}" width="700" />
</a>
</td>
</tr>
</xsl:when>
</xsl:choose>
</xsl:for-each>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top