This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Pass an element based on its childrens content
- From: Mike Brown <mike at skew dot org>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 4 Jun 2002 19:00:33 -0600 (MDT)
- Subject: Re: [xsl] Pass an element based on its childrens content
- Reply-to: xsl-list at lists dot mulberrytech dot com
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