[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Why is apply-templates not called?

Subject: RE: Why is apply-templates not called?
From: "Dion Houston" <dionh@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 Dec 2002 17:59:39 -0800
xslt jdf
Hey Jeff:

<xsl:apply-templates> always operates on a node list.  The node list by
default are the child nodes of the node matched on the template.
Therefore, if you have an XML like:

<Foo>
   <Bar/>
</Foo>

And you're in a template:

<xsl:template match="Bar">

Then apply-templates will not do anything for this particular source
(Bar has no children).

Probably what you're looking for is:

<xsl:apply-templates select="."/> 

This will take the current node (in this case the nodes you're iterating
through xsl:for-each) and run templates on it.

HTH!

Dion


-----Original Message-----
From: Jeff Lowery [mailto:jlowery@xxxxxxxxxxxxxx] 
Sent: Monday, December 09, 2002 5:36 PM
To: 'xsl-list'
Subject:  Why is apply-templates not called?

I suspect I'm going to expose a fundamental misunderstanding of how XSLT
works, but here goes...

Using the following script snippet, both <Color> elements are output
correctly:

<xsl:template match="jdf:ColorantControl">
  <ProcessColorMap>
    <xsl:for-each select="jdf:ColorPool/jdf:Color[(@Name='Cyan') or
(@Name='Yellow') or (@Name='Magenta') or (@Name='Black')]">
      <Color
       colorName="{@Name}"
      >
      </Color>
    </xsl:for-each>
  </ProcessColorMap>
  <SpotColorMap>
    <xsl:for-each select="jdf:ColorPool/jdf:Color[not((@Name='Cyan') or
(@Name='Yellow') or (@Name='Magenta') or (@Name='Black'))]">
      <Color
         colorName="{@Name}"
      >
      </Color>
    </xsl:for-each>
  </SpotColorMap>
</xsl:template>

This approach works, but contains duplicate XML.  What I'd like to do is
put
this common XML in another template, so I would have:

...
<SpotColorMap>
    <xsl:for-each select="jdf:ColorPool/jdf:Color[not((@Name='Cyan') or
(@Name='Yellow') or (@Name='Magenta') or (@Name='Black'))]">
       <xsl:apply-templates/>
    </xsl:for-each>
  </SpotColorMap>
...

<xsl:template match="jdf:Color">
      <Color
         colorName="{@Name}"
      >
      </Color>
</xsl:template>


But she no work!

I'm using instant Saxon 6.5.2

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.