[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

negate predicate

Subject: negate predicate
From: "Richard Lewis" <richardlewis@xxxxxxxxxxxxxx>
Date: Tue, 14 Dec 2004 14:10:34 +0000
xsl test negate
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//*[@id = '']/text()

would return: "Hello, foo barwords, words"

and one like:

//subsection//*[@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@xxxxxxxxxxxxxx

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.