[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|