Re: Help in XSL - better example

admin

Administrator
Staff member
Manish,A better example -<xsl:stylesheet name="Test2"xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method = "html"/><xsl:variable name="root" select="/mydata/questionire"/><xsl:template match="/mydata"><table><xsl:apply-templates select="question-id"/></table></xsl:template><xsl:template match="question-id"><tr><xsl:for-each select="id"><td><xsl:value-of select="."/></td><td><xsl:value-ofselect="$root/question[qid=current()]/desc"/></td></xsl:for-each></tr></xsl:template></xsl:stylesheet>Normally, using "//" is not a good idea becuase it searches every node.By using an xsl variable as a 'position locator' for the secondxsl:value-of operation, it restricts the search to just matching nodes.Greg
 
Back
Top