XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Lee HumphriesSubject: Accessing the document context of a node that is in a sequence
Author: Lee Humphries
Date: 21 Sep 2005 02:10 AM
OK, next XQuery question.

I have a hierarchical document, with various instances of the same element occurring at various levels. I need to process each of these elements in turn and perform differing behaviour based on their context within the hierarchical document.

So for instance:
for $Seg in //Seg[ancestor-or-self::*/@status != 'X']
return
<Seg @id="{@id}" @status="{@status}">
{
if ($Seg/following::*[@status = 'M' or @status = 'R']) then
(: do required behaviour :)
else
(: do nothing :)
}
</Seg>

The problem with above code snippet is that the 'following::' axis is applied relative to the sequence of tuples produced by the for clause, whereas I need it to be relative to the node in its original context within the document.

What's the correct way to approach this situation?

Regards, Lee

Postnext
(Deleted User) Subject: Accessing the document context of a node that is in a sequence
Author: (Deleted User)
Date: 21 Sep 2005 01:24 PM
Hi Lee,
the following:: axis should always work on the DOM tree, not on the sequence created by FLWOR block. Can you modify your query to print out the nodes, in order to verify if the fault is in the XPath query?

Alberto

Posttop
Lee HumphriesSubject: Accessing the document context of a node that is in a sequence
Author: Lee Humphries
Date: 22 Sep 2005 05:38 AM
Hi Alberto,

I think the problem was that I should have been using following-sibling::

Regards, Lee

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.