Subject: Re: [xsl] preceding-sibling including previous node From: andrew welch <andrew.j.welch@xxxxxxxxx> Date: Mon, 28 Nov 2005 15:03:44 +0000 |
On 11/28/05, ADAM PATRICK <adampatrick@xxxxxxxxxxxxxx> wrote: > xslt 1.0 xpath 1.0 > > <xsl:template > mact="animals[preceding-sibling::animals[contains(.'pig')]]"> > > With the above how would you: > > Select all preceding-siblings where node text contains > pig including the line that contains pig. > > Is there something you can do with position? You've done it as a match pattern, rather than a select. That template will only match an <animals> element provided it has a preceding-sibling <animals> element whose text value (all descendent text nodes concatenated together) contains the string 'pig'. If you want to select all preceding-sibling <animals> elements that have the string 'pig' somewhere in their string values then you would use: <xsl:apply-templates select="preceding-sibling::animals[contains(., 'pig')]"/> You then need to only specify "animals" in the template match pattern: <xsl:template match="animals"> It's difficult to guess your exact issue without seeing more of your stylesheet - if this isn't what you meant then post a snippet of your xml and xslt and what the problem is. cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] preceding-sibling includi, David Carlisle | Thread | Re: [xsl] node-set in .Net 2.0?, M. David Peterson |
Re: [xsl] preceding-sibling includi, David Carlisle | Date | [xsl] Grouping / Count Issue, Miraodb |
Month |