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 ]
  • To: David Carlisle <davidc@nag.co.uk>
  • Subject: Re: [xml-dev] XSLT 2.0: Definition of a structure and its use
  • From: "Agnisys Technology \(P\) Ltd." <agnisys@yahoo.com>
  • Date: Wed, 14 Sep 2005 07:18:52 -0700 (PDT)
  • Cc: xml-dev@lists.xml.org
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=sBd6H94kjFgt0bvaJdS9Aa6LlCfqaudBG/95A0KcAlYXztZ4Ch00HSQjfC7/F5bR+qxxYxl1WyLkBiIJv9SJf84df3S9t3lkMmUGrnbKP5NFFITUupYEHtO9Q4mubViUaFlC3Igsy8Zl7z5KLczL9Wxaz87IlZY5qbn//MjhGsc= ;
  • In-reply-to: <200509141405.PAA15941@penguin.nag.co.uk>

Hi David,
  I knew I'll get flak for this, but I was really stuck!

  The output I get using your stylesheet is :
Register : reg_1 Offset = 5 Prev-Sibling count = 0 
Register : reg_2 Offset = 5 Prev-Sibling count = 1 
Register : reg_10 Offset = Prev-Sibling count = 2 
Register : reg_20 Offset = Prev-Sibling count = 3 
Register : reg_3 Offset = 5 Prev-Sibling count = 4 

Note that the parent attribute "offset" is not being accessed by reg_10 and reg_20 nodes.
Any ideas, how to solve that?

Anupam.



--- David Carlisle <davidc@nag.co.uk> wrote:

> 
> 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
> ________________________________________________________________________
> 




		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com




 

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

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