xsl-list
[Top] [All Lists]

[xsl] Obtain depth to create relative path

2006-08-23 02:02:26
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="http://www.example.com/actors/store"]/../../ps:sender/ps:interactionPAssertion/ps:content/ex:envelope/ex:store
[ex:location="/home/sj/data/file1"]/../../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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>