[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

recurrency

David Carlisle davidc at nag.co.uk
Wed Mar 11 09:33:16 PST 2009


  recurrency

Your posted input wan't well formed, if I make it so:


<x>
<testXML>
   <system>
       <node-name>
           <name>name1</name>
           <addInfo>t11</addInfo>
            <node-name>
                   <name>name2</name>
                   <addInfo>t22</addInfo>
                   <node-name>
                            <addInfo>t33</addInfo>
                            <name>name3</name>
		   </node-name>
	    </node-name>
       </node-name>
   </system>
</testXML>



<somewhere-it-is-used>
   <what-the-name--of-var-is>
        <ref>name1</ref>
        <ref>name3 'sdsdsd'</ref>
   </what-the-name--of-var-is>



   <what-the-name--of-var-is>
        <ref>name1</ref>
   </what-the-name--of-var-is>

</somewhere-it-is-used>

</x>



Then I think this returns what you want for the two references.




declare function local:ref ($node as node(), $s as xs:string*) {
if (empty($s)) 
then
$node/addInfo
else
local:ref($node/descendant::node-name[name=$s[1]][1],$s[position()!=1])
};

for $v in /x/somewhere-it-is-used/what-the-name--of-var-is
let $s := $v/ref/replace(.,' .*$','')
return
<var ref="{string-join($s,'/')}">
{local:ref(/,$s)}
</var>



as demonstrated by saxon if the above are saved in ref.xml and ref.xq
respectively.



$ saxon9q -s:ref.xml ref.xq
<?xml version="1.0" encoding="UTF-8"?>
<var ref="name1/name3">
   <addInfo>t33</addInfo>
</var>
<var ref="name1">
   <addInfo>t11</addInfo>
</var>

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________


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