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

Output of Following-Sibling or Preceding Sibling

Wei, Alice J. ajwei at indiana.edu
Tue Feb 19 07:48:26 PST 2008


  Output of Following-Sibling or Preceding Sibling
Hi, XQueriers:

    I am wondering if any on the list could give me hints on how to extract the <pb> node. I have made attempts of usinng


<my>
    <myHeader>
        <fileDesc>
            <titleStmt>
                <title>My Collection</title>
            </titleStmt>
            <sourceDesc>
                <biblFull>
                    <seriesStmt>
                        <title level="journal">My Journal</title>
                        <idno type="volume"> 1 </idno>
                        <idno type="issue"> 1 </idno>
                    </seriesStmt>
                </biblFull>
            </sourceDesc>
        </fileDesc>
    </myHeader>
    <text>
        <body>
           <pb n="1" xml:id="my000108"/>
            <pb n="2" xml:id="my000110"/>
               <div>
                <ad>
                    <head>Be Taller</head>
                    <p>If you wish to know the facts about HEIGHT INCREASE, send 35c for details to
                        TALL-UP.
                        <address>
                            <addressLine>TALL-UP,</addressLine>
                            <addressLine>232 W. Front St.</addressLine>
                            <addressLine>Napoleon, Ohio 42345</addressLine>
                        </address>
                    </p>
                    <note>Dept. NA</note>
                </ad>
                <ad>
                    <head type="main">FREE POWERFUL MUSCLES FAST</head>
                    <head type="sub">FREE</head>
                    <p>Fantastic mew discoveries in the science of body-building. Our method will
                        add inches of powerful muscles to arms, chest, shoulders &amp; legs.
                        Learn secrets on trimming the waist with ultra-modern methods—fast! Results
                        guaranteed! Send for free brochure. Send dime for postage and handling.
                        <address>
                            <addressLine>Universal Bodybuilding</addressLine>
                            <addressLine>Box 485</addressLine>
                            <addressLine>Dearborn, Michigan 48121</addressLine>
                        </address>
                    </p>
                    <note>Dept. P</note>
                </ad>
            </div>
                  <pb n="3" xml:id="my000112"/>
        </body>
    </text>
</my>

My XQuery:

let $ad := fn:collection("xmldb:exist://db/my")
let $journal := $ad//seriesStmt/title[@level='journal'][1]
let $ad2 := $ad//ad/head[contains(upper-case(.), 'STAMPS')]
let $sorted_result:=
for $doc in distinct-values($ad2)
order by $doc
return $doc
for $r at $count in $sorted_result
let $nodes := $ad2[. = $r][1]
let $para := $nodes/parent::p[1]
let $head := $nodes/ancestor::ad//head[1]
let $note := $nodes/ancestor::ad//note[1]
let $seriesStmt:=$nodes/ancestor::my//seriesStmt
let $pb := $nodes/ancestor:my//pb[descendant::ad/head[contains(upper-case(.), 'MUSCLES')]]
return
<ad>
<statistics>
Showing Result: {$count} / {count($sorted_result)}
</statistics>
<source>
<journal>{data($journal)[1]}</journal>
<publication_information>Volume {data($seriesStmt/idno[@type='volume'][1])},
Issue {data($seriesStmt/idno[@type='issue'][1])}</publication_information>
</source>
{$head}
{$nodes}
<description>{$para}</description>
<information>Source from page {$pb}</information>
{$note}</ad>

This brings this:

<ad>
<statistics> Showing Result: 1 / 1</statistics>
<source>
<journal>My Collection</journal>
<publication_information>Volume 1 , Issue 1 </publication_information>
</source>
<head type ="main">FREE POWERFUL MUSCLES FAST</head>
<head type ="main">FREE POWERFUL MUSCLES FAST</head>
<description/>
<information>Source from page </information>
<note>Dept. P</note>
</ad>

If I do

let $pb := $nodes/ancestor::my//pb

The <information> gives me
<information>Source from page
        <pb n="1" xml:id="my000108"/>
        <pb n="2" xml:id="my000110"/>
     <pb n="3" xml:id="my000112"/>
 </information>

This is also the same when I do let $pb := $nodes/ancestor::ad/following-sibling::pb[1]

Intended Output:

<ad>
<statistics> Showing Result: 1 / 1</statistics>
<source>
<journal>My Collection</journal>
<publication_information>Volume 1 , Issue 1 </publication_information>
</source>
<head type ="main">FREE POWERFUL MUSCLES FAST</head>
<head type ="main">FREE POWERFUL MUSCLES FAST</head>
<description/>
<information>Source from page  <pb n="2" xml:id="my000110"/></information>
<note>Dept. P</note>
</ad>

Can anyone please help me figure this out?
Any help is appreciated.

Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
http://x-query.com/mailman/listinfo/talk



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.