Unable to pass XML in xsl script



Below is the XML and XSL and i want to pass the complete xml node to xsl script to do some operations on that node and I do not want to use XPATH and want to operate using selectsinglenode in msxslscript.


XML



<?xml version="1.0" ?>
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
<books>
<book>
<name>Revolution</name>
<qty value="4">1</qty>
</book>
<book>
<name>Life of a pie</name>
<qty value="4">5</qty>
</book>
</books>


XSL



<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xsl="http://ift.tt/tCZ8VR"
xmlns:user="com.nitish">
<msxsl:script language="javascript" implements-prefix="user" >
function getNode(node){

return node.selectSingleNode("books/book/qty/@value");

}
</msxsl:script>

<xsl:template match="/">


<html>
<body>
<h2>Book Details</h2>
<table xmlns:h="http://ift.tt/Zgg410" border="1px" cellspacing="20px">
<xsl:variable name="rootNode" select="books"/>
<xsl:for-each select="//book">
<tr><td><xsl:value-of select="user:getNode($rootNode)"/>
</td></tr>
</xsl:for-each>
</table>
</body>
</html>

</xsl:template>

</xsl:stylesheet>


Please help.


No comments:

Post a Comment