xsl-list
[Top] [All Lists]

Re: preceding-sibling including previous node

2005-11-28 08:03:44
On 11/28/05, ADAM PATRICK <adampatrick(_at_)btinternet(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>