Sign In/My Account | View Cart  
advertisement

Article:
 What Is XQuery
Subject: idref
Date: 2003-11-11 17:59:21
From: Jyothi ratna

Hello,
I am a beginner in Xquery.In my schema I have element which has IDREF attribute.I want to extract id value to which points and check whether that value is equivalent to some value.
eg:<AUTHOR EMAILID ="psmith@sfsu.edu"> >
<FNAME>smith</FNAME>
<MI>j</MI>
<LNAME>jen</LNAME>
</AUTHOR>
<PAPER PAPERID = 10
EMAILID = "sai@yahoo.com"
>
<MAINATHR>SHARMA</MAINATHR>
<TITLE>ABC</TITLE>
</PAPER>
<PAPER PAPERID = 10
EMAILID = "sha@yahoo.com"
>
<MAINATHR>SHARMA</MAINATHR>
<TITLE>ABC</TITLE>
</PAPER>


Here EMAILID is a IDREF attribute in PAPER element.I want to check the value of EMAILID of paper element and check if it is "sai@yahoo.com ".If it is "sai@yahoo.com" I have to retrieve paperid,author fname from the document.I think I may have to use dereference operator => but I do not know how to apply that in my situation.Could anybody please help me to solve this problem?
Thanks,
Sharma


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • idref
    2003-11-12 11:32:24 Per Bothner

    This should get you on the right track. Note that for more complex conditions you might want to use a 'where' clause rather than a [predicate].


    let $id := "sai@yahoo.com",
    for $paper in $doc/PAPER[@EMAILID = $id],
    for $author in $doc/AUTHOR[@EMAILID = $id]
    return
    <result PAPERID="{$paper/@PAPERID}">
    {$author/FNAME}
    <result>


    This assumes you have a specific emailid. If you want this for all emailids, you could do:


    for $paper in $doc/PAPER,
    for $author in $doc/AUTHOR
    where $paper/@EMAILID = $auther/$EMAILID
    return
    <result PAPERID="{$paper/@PAPERID}">
    {$author/FNAME}
    <result>


    XQuery does not have the => operator.


Sponsored By: