OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] XSLT 2.0: Definition of a structure and its use

[ Lists Home | Date Index | Thread Index ]


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>&#10;</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
________________________________________________________________________




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS