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

Re: How to 'invert' an Xpath statement please

  • From: "Rens Duijsens" <rens.duijsens@g...>
  • To: xml-dev@l...
  • Date: Wed, 27 Aug 2008 11:23:57 +0200

Re:  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@n...>

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


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.