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

recurrency

Michalmas michalmas at gmail.com
Wed Mar 11 09:12:02 PST 2009


  recurrency
Hello,

Yes, indeed, i missed that. So, to make it complete:

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


Now, later in the same XML, it may be:
<somewhere-it-is-used>
   <what-the-name--of-var-is>
        <ref>name1</ref>
        <ref>name3 'sdsdsd'</ref>
   <what-the-name--of-var-is>
<somewhere-it-is-used>


And what i query for is the addInfo. When i see what-the-name--of-var-is
node, i want to use the ref values (this case name1/name3), and find the
type of last variable (name3 is used as last one - so it is final variable -
and i want its type - what is t33).

It may also happen that i see:
<somewhere-it-is-used>
   <what-the-name--of-var-is>
        <ref>name1</ref>
   <what-the-name--of-var-is>
<somewhere-it-is-used>

and then i want to get t11.

The function i am not showing is simply iterating through all nodes
searching for somewhere-it-is-used. Then, base on count of ref elements, one
of the function for getting types is called.

And the queries i use:

declare function local:getNodeDefinitionOne($sys as item(), $node1 as
item())as item()*
{
    let $processed := replace(data($node1), ' \(.*\)' , '')
    let $res := testXML/$sys//node-name[data(name) = $processed]
    return $res
};

declare function local:getNodeDefinitionTwo($sys as item(), $node1 as
item(), $node2 as item())as item()*
{
    let $processed := replace(data($node2), ' \(.*\)' , '')
    let $fir := local:getNodeDefinitionOne($sys, $node1)
    let $res := $fir//node-name[data(name) = $processed]
    return $res
};

declare function local:getNodeDefinitionThree($sys as item(), $node1 as
item(), $node2 as item(), $node3 as item())as item()*
{
    let $processed := replace(data($node3), ' \(.*\)' , '')
    let $fir := local:getNodeDefinitionTwo($sys, $node1, $node2)
    let $res := $fir//node-name[data(name) = $processed]
    return $res
};

declare function local:getNodeDefinitionFour($sys as item(), $node1 as
item(), $node2 as item(), $node3 as item(), $node4 as item() )as item()*
{
    let $processed := replace(data($node4), ' \(.*\)' , '')
    let $fir := local:getNodeDefinitionThree($sys, $node1, $node2, $node3)
    let $res := $fir//node-name[data(name) = $processed]
    return $res
};

declare function local:getNodeDefinitionFive($sys as item(), $node1 as
item(), $node2 as item(), $node3 as item(), $node4 as item(), $node5 as
item() )as item()*
{
    let $processed := replace(data($node5), ' \(.*\)' , '')
    let $fir := local:getNodeDefinitionFour($sys, $node1, $node2, $node3,
$node4)
    let $res := $fir//node-name[data(name) = $processed]
    return $res
};

Thanks!

On Wed, Mar 11, 2009 at 12:42 AM, David Carlisle <http://x-query.com/mailman/listinfo/talk> wrote:

>
>
> > The thing is that later in XML there can be referance to that fields:
> > <somewhere-it-is-used>
>
> sorry I really can not guess what you mean here, and I doubt anyone else
> on the list will be able to guess.
> Can you not post, to the list, a complete (but small) example of the
> input and say what result the query is supposed to produce, then
> probably someone would supply some xquery code.
>
>
> given your testXML node input in your original mail and
> the <somewhere-it-is-used> node in the last mail,
> what is supposed to be returned? perhaps ypu want the element
>  <name>name3</name>
> or perhaps the element
>  <node-name>
>   <name>name3</name>
> <node-name>
> or perhaps you want something else entirely. I can't guess what you
> intend.
>
> David
>
>
> ________________________________________________________________________
> 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.
> ________________________________________________________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20090311/662c4ac1/attachment.htm


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