xsl-list
[Top] [All Lists]

negate predicate

2004-12-14 07:10:34
I want to select the text of all descendants of a node which *don't*
have an attribute called 'id' (and none of the nodes which are
descendants of nodes with id attributes).

So that, from the following document snipet:

<document>
    <section id="first">
        <p>Hello, foo bar</p>
        <subsection id="bar">
            <p>Some stuff</p>
        </subsection>
        <subsection id="foo">
            <p>Some other stuff</p>
        </subsection>
    </section>
    <section id="second">
        <subsection id="qwerty">
            <p>More text</p>
        </subsection>
        <p>words, words</p>
    </section>
</document>

an XPath expression like:

//section//*[(_at_)id = '']/text()

would return: "Hello, foo barwords, words"

and one like:

//subsection//*[(_at_)id = '']/text()

would return: "Some stuffSome other stuffMore text"

(I realise that here I could just tell it not to select 'subsection'
elements but my real document has a more complex hierachy including
structural elements which share names with formatting elements [and
which are only distinguished by having an 'id' attribute]).

Thanks for your help,
Richard
-- 
  Richard Lewis
  richardlewis(_at_)fastmail(_dot_)co(_dot_)uk


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