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

Hello David,
 
Yes... I see where my problem lies.
The statement '//*[not(ancestor-or-self::NODE)]' does basicly what I need, and yes, it gives me to much data because it includes ROOT and all it's subdata, including the data I don't want.
 
Maybe it's better I explain what I'm dooing.
I may elaborate a bit long, so please bare with me. :-)
 
Im writing a program to assist StreamServe developers to create complex xpath/xslt statements for their events.
In StreamServe, statements are assembled of 3 inputs (that's how StreamServe works :-) ).
We have a Pattern, which tells StreamServe which datafile connects to which part op StreamServe applications.
We have a Match, which tells StreamServe while handling a file, when to act.
We have Value, which tells StreamServe how to act when the match occurs.
(Nothing strange so far. :-)
 
The development enviroment inside StreamServe does not give any visible insight into what you are doing as a developer.
It's ... create a few statements .... compile (export in StreamServe therems) and run. See if it works......
If not, back to the drawing board.
 
In my program, the statements are made visible in the datafile, so one can SEE what's happening BEFORE you put the statement into StreamServe. I do this by highlighting the selections produced by each stetement, and I show the results that would be produced if StreamServe would run.
 
Now the problem.
The XML-data is shown in a RichTextBox. Here the highlighting takes place by finding the string to highlight using a *regular expression*.
If a string however occurs in more places than just in the data produced by the xpath statement, these data is highlighted to. This is undesireble.
So, I want to know WHERE the data starts that the statements produce.


See the following example:
<ROOT>
    <ELEMENT>Element 1</ELEMENT>
    <NODE>

        <ELEMENT>Element 1</ELEMENT>
        <ELEMENT>Element2 </ELEMENT>
    </NODE>
</ROOT>

If I use //NODE/ELEMENT than xpath tells me the data is ELEMENT (Which Element 1) end ELEMENT (Wich Element 2).
Finding this data to highlight produces...

<ROOT>
    <ELEMENT>Element 1</ELEMENT>
    <NODE>

        <ELEMENT>Element 1</ELEMENT>
        <ELEMENT>Element2 </ELEMENT>
    </NODE>
</ROOT>

The first line to be highlighted should be the first element inside NODE, and not teh one after ROOT.
So, I want to know which data is NOT part of my selection, so I can skip the highlighting for the first one.
 
I hope I made the problem clear. :-)
En even more, I hope you can help me finding a solution.
 
Friendly greetings
Rens Duijsens
The Netherlands


 
2008/8/26 David Carlisle <davidc@nag.co.uk>

> The inverted selection *should* produce:
> ROOT, ELEMENT (With Element 1)

Are you sure you just want an Xpath selection.

//*[not(ancestor-or-self::NODE)]

is probably what you are looking for, which will return 2 nodes

ROOT and ELEMENT  (With Element 1)

However the ROOT element that is returned is the ROOT element in the
original source document, and so will have two children ELEMENT and
NODE.

Xpath (on its own) never changes the nodes it selects and the list of
child nodes is part of the node structure, so is never changed.

David
(you may find xsl-list or xquery-talk better than xml-dev for xpath
questions)

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________



[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