[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Obtain depth to 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="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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|