Re: preceding-sibling including previous node
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
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