XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] How to 'invert' an Xpath statement please

XPath coding questions are better asked on the xsl-list at mulberrytech.com
 
Please see the following example:
<ROOT>
    <ELEMENT>Element 1</ELEMENT>
    <NODE>
        <ELEMENT>Element 2</ELEMENT>
        <ELEMENT>Element 3</ELEMENT>
    </NODE>
</ROOT>

The normal xpath statement '//NODE' will give me:
NODE, ELEMENT (with Element 2), ELEMENT (With Element 3)  

Actually, no, it only gives you one element: NODE. You can reach all the other nodes from there, but they are not selected by the XPath expression. Your development environment might choose to display NODE by showing it along with its children, but that's not part of the action of the XPath expression itself.  

I'm experimenting with some inverted statements:
For instance: /*[!//NODE] or //*[!//NODE]  

Please don't experiment with syntax. You'll never work out how XPath works by a suck-it-and-see approach. Read the spec, or a good book.

 
It keeps giving me the NODE data as well.  

Both the above are syntax errors and should give you nothing but an error message. 

The inverted selection *should* produce:
ROOT, ELEMENT (With Element 1)
Any advice on how to put the statement together?

Since you've explained the effect of the correct statement incorrectly, I'm really not sure what you actually want to select.

Michael Kay

http://www.saxonica.com/



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS