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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1126)
+ Stylus Studio Technical Forum (13843)
+ Website Feedback (244)
+ XSLT Help and Discussion (7447)
- XQuery Help and Discussion (1870)
-> + Loving XQuery (3)
-> + Cross Referencing Country Name... (4)
-> + Creating a Pivot Table with xQ... (2)
-> + Error Please Help (3)
-> - Error Please Help (1)
-> + XPath descendant question (2)
-> + java/lang/OutOfMemoryError Run... (2)
-> + Xquery key value lookup (8)
-> + Improve xQuery Performance (3)
-> + MS SQL Server - Disable order ... (10)
-> + proper use of fn:distinct-valu... (2)
-> + Ignore DTD (7)
-> - Thanks Ivan (1)
-> + Trying to get 2nd value of nod... (5)
-> + Outer joins (4)
-> + Figured Out Issues From Last P... (2)
-> + Best Way To Generate Complex X... (3)
-> + count in xquery (4)
-> + left/right presentation (3)
-> + new to stylus - connecting to ... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (361)
+ Stylus Studio Announcements (113)
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
Alberto MassariSubject: Accessing the document context of a node that is in a sequence
Author: Alberto Massari
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

   
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-2011 All Rights Reserved.