Luis Angel Fdez. Fdez.
Usenet Archive
- Joined
- Jul 19, 2007
- Messages
- 8
- Reaction score
- 0
Hi!
I have a simple .xml file only for testing purpouses...
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl" href="attr.xsl" ?> <root> <element> <id>0</id> <name>A cheap thing</name> <prize currency='GBP'>0.5</prize> <stock>15</stock> </element> <element> <id>1</id> <name>A one hundred euros cost thing</name> <prize currency='EUR'>100</prize> <stock>7</stock> </element> <element> <id>2</id> <name>The most expensive thing</name> <prize currency='USD'>15000</prize> <stock>2</stock> </element> </root>
What I want to do is to extract the value of the attribute currency. I tried this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:template match="/"> <html> <head> </head> <body> <h2>Testing XML-XSL II</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="center">Name</th> <th align="center">Prize</th> </tr> <xsl:for-each select="root/element"> <tr> <td align="center"><xsl:value-of select="name"/></td> <td align="center"><xsl:value-of select="@currency"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
But it doesn't work. It show nothing. I read on book 'XML in a Nutshell' something about built-in templates and it seems <xsl:apply- templates select="@currency"/> should work but it doesn't... even if I include into the xsl:
<xsl:template match="text|@*">
<xsl:value-of select="."/>
</xsl:template>
What am I doing wrong?
Bye.
I have a simple .xml file only for testing purpouses...
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl" href="attr.xsl" ?> <root> <element> <id>0</id> <name>A cheap thing</name> <prize currency='GBP'>0.5</prize> <stock>15</stock> </element> <element> <id>1</id> <name>A one hundred euros cost thing</name> <prize currency='EUR'>100</prize> <stock>7</stock> </element> <element> <id>2</id> <name>The most expensive thing</name> <prize currency='USD'>15000</prize> <stock>2</stock> </element> </root>
What I want to do is to extract the value of the attribute currency. I tried this:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:template match="/"> <html> <head> </head> <body> <h2>Testing XML-XSL II</h2> <table border="1"> <tr bgcolor="#9acd32"> <th align="center">Name</th> <th align="center">Prize</th> </tr> <xsl:for-each select="root/element"> <tr> <td align="center"><xsl:value-of select="name"/></td> <td align="center"><xsl:value-of select="@currency"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>
But it doesn't work. It show nothing. I read on book 'XML in a Nutshell' something about built-in templates and it seems <xsl:apply- templates select="@currency"/> should work but it doesn't... even if I include into the xsl:
<xsl:template match="text|@*">
<xsl:value-of select="."/>
</xsl:template>
What am I doing wrong?
Bye.