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 09:01:58 -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=C5Tv606UI9XUmkReeJJ4MW1r2esz2tMLvWpHRBQIliFVIUG5rnzsUu0X52G/l942lxCrzyve7skqtHxRvQXib0J96UFTfIN3YKNYBOxiaGe1yGMSWdv7IFAbG5mKF73mV2TOmqRchTU1OoMHkMRqJviA4IUzv1QXHkC00oZuK5o= ;
  • In-reply-to: <200509141519.QAA16417@penguin.nag.co.uk>

Thanks David, I got that working!

Here is the final stylesheet ...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">
   
    <xsl:template match="*" mode="pass1">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates mode="#current"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="reg[@href]" mode="pass1">
        <xsl:variable name="x" >
            <xsl:copy-of select="//regdef[@name=current()/@href]/*"/>
         </xsl:variable>
        <xsl:apply-templates select="$x" mode="#current"/>
    </xsl:template>
    
    <xsl:template match="regdef" mode="pass1"/>
        
    <xsl:template match="reg" mode="pass2">
        <br/>Register = <xsl:value-of select="."/>
           Parent Offset = <xsl:value-of select="../@offset"/>
           Sibling count = <xsl:value-of  select="count(preceding-sibling::reg)"/>
     </xsl:template>
    
    <xsl:template match="/">
        <xsl:variable name="x">
            <xsl:apply-templates mode="pass1"/>
        </xsl:variable>
        <xsl:apply-templates mode="pass2" select="$x"/>
    </xsl:template>
    
</xsl:stylesheet>

Anupam.


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

> 
> > I am sorry, that is what I don't understand. How to do two transforms in succession?
> 
> well the simplest is to write the result of the first transform out as a
> file and then just process the file. It's best to do it that way while
> debugging as you get to see the intermediate stage.
> 
> Most API allow you to avoid the overhead of serialising and writing to a
> file and parsing it back, and just pass the output tree from one to the
> other, but that depends entirely on the api you are using to call xslt.
> 
> You can however do it in one stylesheet if it is more convenient, since
> you are using 2.0 you don't need x:node-set() just store the modified
> tree in a variable then apply templates to that:
> 
> 
> <xsl:template match="/">
> <xsl:variable name="x">
>  <xsl:apply-templates mode="pass1"/>
> </xsl:variable>
> </xsl:apply-templates mode="pass2" select="$x"/>
> </xsl:template>
> 
> Then have templates in pass1 mode that just expand references, and
> templates in pass2 mode that do whatever you want to do.
> 
> David
> 
> ________________________________________________________________________
> 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
> ________________________________________________________________________
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 



		
__________________________________ 
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