Hi. guys
The following xslt stylesheet supposed to loop through the xml doc visiting each node, read and write its name and their attributes (userid, password). Actually it visits the only the first node since it performs this statement <xsl:for-each select="data/node1">
which prevents it from visiting the others. My question is how to amend this code in order to allow it to visit the whole xml doc with any number of nodes with same attributes?
Any help is really much appreciated
Cheers
Here is the xml document
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="xx.xslt"? >
<data>
<node1 userid="x" password="y" />
<node2 userid="xx" password="yy" />
<node3 userid="xxx" password="yyy" />
</data>
Here is the xslt stylesheet
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dt d" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<xsl:for-each select="data/node1">
<h2> <xsl:value-of select="local-name()"/> </h2>
<h1> <xsl:value-of select="@userid " /> </h1>
<h1> <xsl:value-of select="@passwo rd" /> </h1>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The following xslt stylesheet supposed to loop through the xml doc visiting each node, read and write its name and their attributes (userid, password). Actually it visits the only the first node since it performs this statement <xsl:for-each select="data/node1">
which prevents it from visiting the others. My question is how to amend this code in order to allow it to visit the whole xml doc with any number of nodes with same attributes?
Any help is really much appreciated
Cheers
Here is the xml document
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="xx.xslt"? >
<data>
<node1 userid="x" password="y" />
<node2 userid="xx" password="yy" />
<node3 userid="xxx" password="yyy" />
</data>
Here is the xslt stylesheet
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dt d" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<xsl:for-each select="data/node1">
<h2> <xsl:value-of select="local-name()"/> </h2>
<h1> <xsl:value-of select="@userid " /> </h1>
<h1> <xsl:value-of select="@passwo rd" /> </h1>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Comment