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

Re: Passing Elements to templates...

Subject: Re: Passing Elements to templates...
From: Mike Brown <mike@xxxxxxxx>
Date: Mon, 3 Jun 2002 12:49:16 -0600 (MDT)
Re:  Passing Elements to templates...
CROFT, MICHAEL wrote:
> Is there a way to pass an entire element, with all its children to a
> template.  Then, within that template which it was passed to, specifically
> extract certain elements to display the text?

You can pass an object of any type, including node-set, to a template as a
parameter. If passing a node-set, it is usually the case that you pass just
the one element node; you can use XPath expressions to obtain its descendants
and attributes. 

  <xsl:template match="foo">
    <xsl:apply-templates select="path/to/some/coolNodes">
      <xsl:with-param name="aNodeSet" select="some/foo/descendant"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="coolNodes">
    <xsl:param name="aNodeSet" select="/.."/> <!-- default: empty set -->
    <xsl:text>&#10;number of nodes in aNodeSet: </xsl:text>
    <xsl:value-of select="count($aNodeSet)"/>
    <xsl:text>&#10;number of child elements of all of those nodes: </xsl:text>
    <xsl:value-of select="count($aNodeSet/*)"/>
  </xsl:template>

Is there a particular problem you are having?

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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-2011 All Rights Reserved.