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

Re: Pass an element based on its childrens content

Subject: Re: Pass an element based on its childrens content
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 4 Jun 2002 19:00:33 -0600 (MDT)
xsl text pass node
CROFT, MICHAEL wrote:
> I need to pass an element to a template based on a condition where its
> children would contain certain text(an id).  

<xsl:param name="cid"/>  <!-- $cid comes from somewhere.. it is either a
                              string or a node-set containing the claim
                              IDs to find. it doesn't have to be a param -->

<!-- template to process the root node (always the first node processed) -->
<xsl:template match="/">
  <!-- go process the matching InsClaimElements elements, one at a time -->
  <xsl:apply-templates select="ListOfInsClaimsElements/InsClaimsElements[ClaimId=$cid]"/>
</xsl:template>

<!-- template to process an InsClaimsElements element -->
<xsl:template match="InsClaimsElements">
  <result>
    <xsl:text>The claim ID is </xsl:text>
    <xsl:value-of select="ClaimId"/>
    <xsl:text>and the claimant is </xsl:text>
    <xsl:value-of select="concat(ClaimantFirstName,' ',Claimant,'.')"/>
  </result>
</xsl:template>

> I need to find the list of claims elements (ListOfInsClaimsElements) which
> contains the claims (InsClaimsElements) that Im interested in (ClaimId).

The above will work even if $cid is a node-set.

> THen I would pass this entire list to a called template for processing.

The way XSLT works, you generally just select nodes for processing
with xsl:apply-templates or xsl:for-each. Select the right nodes, and
have a template to match them. You don't need to pass node-sets as
parameters to named templates.

> THere are multiple lists within the xml document each with possible multiple
> claims but each list of claims only belongs to one claimant.

See the FAQ at www.dpawson.co.uk for more sorting and grouping examples.

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