I want to use XSLT to format xml, next is my xml file and xsl file
XML
...
<root>
<user>
<user_id>27</user_id>
<name>John</name>
</user>
......
</root>
XSL file
<xsl:template match="/">
<xsl:for-each select="root/user">
<tr>
<td>& href="#">Link &</td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</xsl:template>
In line 4 of xsl file , I want to put value from <xsl:value-of select="user_id"/> into html link. just href="<xsl:value-of select="user_id"/>"
I tried several methods to do it, anyone didn't work successfully.
Please help ....
-
It's boring, XSLT ... (2 messages)
- Posted by: tony lu
- Posted on: January 14 2004 03:23 EST
Threaded Messages (2)
- It's boring, XSLT ... by David Rabinowitz on January 14 2004 05:53 EST
- It's boring, XSLT ... by Paul Strack on January 14 2004 10:33 EST
-
It's boring, XSLT ...[ Go to top ]
- Posted by: David Rabinowitz
- Posted on: January 14 2004 05:53 EST
- in response to tony lu
Try xsl:attribute
<a>
<xsl:attribute name="href"><xsl:value-of select="user_id"/></xsl:attribute>
</a>
David -
It's boring, XSLT ...[ Go to top ]
- Posted by: Paul Strack
- Posted on: January 14 2004 10:33 EST
- in response to tony lu
Another mechanism: use an attribute value template: {user_id}
<xsl:template match="/">
<xsl:for-each select="root/user">
<tr>
<td><a href="{user_id}">Link</a></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</xsl:template>