xsl-list
[Top] [All Lists]

Re: How to create a node set that excludes some descendant elements?

2005-04-11 17:34:10
More info (sorry I didn't put it in the first post)

Rush Manbert wrote:

I want to create a global variable that contains the result tree fragment contained within element <c>, with the following restrictions: I only want to include the first <y> element that is contained within <c>, no matter where it occurs. There may be no <y> elements present. I want to exclude all <z> elements that are contained within <c>, no matter where they occur. Again, there may be none present.

I have tried many variations on the select portion of the variable definition. I can filter the immediate children of <c>, OR the second level children, etc., but I can't seem to come up with anything that handles <y> and <z> appearing at any depth in the descendant tree.

Some things I have tried:
<xsl:variable name="set" select="/a/b/c/*[((name() != 'y') and (name() != 'z'))] | /a/b/c//y[1]" />

<xsl:variable name="set" select="/a/b/c/descendant::*[((name() != 'y') and (name() != 'z'))] | /a/b/c//y[1]" />

Then I tried to just exclude <z> at any level:
<xsl:variable name="set" select="/a/b/c/descendant::*[not(self::z)]" />
but that only excludes <z> elements that are children of <c>.

I'm using xsltproc, built with libxml 2.6.19 and libxslt 1.1.14

- Rush

--~------------------------------------------------------------------
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>
--~--