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

Obtain depth to create relative path

Subject: Obtain depth to create relative path
From: "ASB 98" <asb98.doc@xxxxxxxxxxxxxx>
Date: Wed, 23 Aug 2006 10:02:12 +0100
create relative path
Dear All,

Using eXist database as data repository, including built in xpath and
xquery functions.

My current xquery search needs to determine the depth of the returned
node ($x) in the document - from the root.
I would then like to use this to generate the relative path that is
needed to access a node higher up the structure ($x will always be
deeper in the document).

So for example if the depth was 10, and the specific item I wished to
retrieve was at level 5, then I would want to create the relative
path: $x/../../../../../ps:specific-nodename
 i.e. ( (10-5) x "/.." ) + /ps:specific-nodename       (probably
done within a loop)

Below is what I have so far, but don't know how to get position or
counter to function on $x.

Can this be done without xsl? how can the relative path value be created?
TIA

- - - - - -
declare namespace ps="http://www.pasoa.org/schemas/version025/PStruct.xsd";
declare namespace wsa=" http://schemas.xmlsoap.org/ws/2004/03/addressing";
declare namespace ex="http://www.example.com";
declare namespace ph=" http://www.pasoa.org/schemas/version025/PHeader.xsd";
declare namespace pq="
http://www.pasoa.org/schemas/version025/pquery/ProvenanceQuery.xsd ";
declare namespace xsl=" http://www.w3.org/Style/XSL/ ";
declare namespace fc="http://www.w3.org/2005/02/xpath-functions ";

for $x at $i in
/ps:pstruct/ps:interactionRecord/ps:interactionKey/ps:messageSink[wsa:Address=&quot;http://www.example.com/actors/store&quot;]/../../ps:sender/ps:interactionPAssertion/ps:content/ex:envelope/ex:store
[ex:location=&quot;/home/sj/data/file1&quot;]/../../ex:envelope/ex:store/ex:data

let $pos := fn:position()                      <!-- this is not working ->
let $count := count(ancestor::*)+1      <!-- this is not working ->

let $view := $x/../../../../..                   <!-- this is what the
depth is to be used to set ->
return
<resultPQ counter="{$i}">
 <testcount>{$pos} and {$count}</testcount>
 <qdhdata>{$x}</qdhdata>
 <qdhkey>{$view/../ps:interactionKey}</qdhkey>
 <qdhviewtype>{$view/name()}</qdhviewtype>
 <qdhsender>{$view/../ps:sender}</qdhsender>
 <qdhreceiver>{$view/../ps:receiver}</qdhreceiver>
</resultPQ>



- - - -

Many thanks! asb

Current Thread

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