[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT 2.0: Definition of a structure and its use
As others have explained in answer to your previous question, you can do this in two passes, first copying the branch, then processing the new input tree, but in this simple case you can do it in one pass, without using any variables: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:key name="r" match="regdef" use="@name"/> <xsl:template match="*"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="reg[@href]"> <xsl:apply-templates select="key('r',@href)/*"> <xsl:with-param name="c" select="count(preceding-sibling::reg[not(@href)]|key('r',preceding-sibling::reg/@href)/*)"/> </xsl:apply-templates> </xsl:template> <xsl:template match="regdef"/> <xsl:template match="reg"> <xsl:param name="c" select="0"/> <xsl:text> </xsl:text> <br/>Register : <xsl:value-of select="."/> <xsl:text/> Offset = <xsl:value-of select="../@offset"/> <xsl:text/> Prev-Sibling count = <xsl:value-of select="$c+count(preceding-sibling::reg[not(@href)]|key('r',preceding-sibling::reg/@href)/*)"/> </xsl:template> </xsl:stylesheet> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|