XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] xsl processing problem with multiple templates

At 2009-11-14 16:55 -0500, Ian S. Worthington wrote:
>The idea of pushing is new to me I'm afraid.

In fact you are already using it because you catch a node pushed at 
your stylesheet when using a template match.

>Where should that "apply-templates" line go?

In place of the <xsl:for-each/>

>Obviously not here:
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:template match="fixlist">
>     <xsl:message>Matched data root</xsl:message>
>     <html>
>     <body>
>       <xsl:for-each select="fix">
>         <xsl:apply-templates select="fix[not(@href)] |
>document( fix/@href )/fix"/>
>         <p>Change number: <xsl:value-of select="number"/></p>
>       </xsl:for-each>
>     </body>
>     </html>
>   </xsl:template>
></xsl:stylesheet>

Your choice .... either using pull:

       <xsl:for-each select="fix[not(@href)] |
                             document( fix/@href )/fix">
         <p>Change number: <xsl:value-of select="number"/></p>
       </xsl:for-each>

... or using push:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:template match="fixlist">
     <xsl:message>Matched data root</xsl:message>
     <html>
     <body>
      <xsl:apply-templates select="fix[not(@href)] |
                                   document( fix/@href )/fix"/>
     </body>
     </html>
   </xsl:template>

   <xsl:template match="fix">
    <p>Change number: <xsl:value-of select="number"/></p>
   </xsl:template>

</xsl:stylesheet>


I hope this helps.  On my web site I have a free download of an 
excerpt of my XSLT book where I've introduced the concepts of pull and push.

I hope this helps.

. . . . . . . . Ken

--
Vote for your XML training:   http://www.CraneSoftwrights.com/x/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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

Copyright 1993-2007 XML.org. This site is hosted by OASIS