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

Selecting everything before and after path, but without duplicated leafs

Junte Zhang zhangjunte at gmail.com
Sun Feb 10 12:33:44 PST 2008


  Selecting everything before and after path
Hi all,

I have an XML file (quite long) and I have a path to an element. I
want to select
(1) everything of that path and its descendants, at the same time I
want to return everything (2) before that path, and everything (3)
after that path. I was trying the XPath axes "preceding" and
"following", but these axes are returning duplicate leafs, which is
not what I want. I would like to reconstruct the original XML file,
but with an extra tag for the XPath selection ($unit).

This is how my XQuery looks like.

 let $doc := doc("file.xml")

 let $precedingUnit := $doc/ead[1]/archdesc[1]/dsc[1]/c01[1]/preceding::node()
 let $unit := $doc/ead[1]/archdesc[1]/dsc[1]/c01[1]/self::node()
 let $followingUnit := $doc/ead[1]/archdesc[1]/dsc[1]/c01[1]/following::node()
 return
 <out>
  <before>
  {
     $precedingUnit
  }
  </before>
  <select>
  {
     $unit
  }
  </select>
  <after>
  {
     $followingUnit
  }
  </after>
  </out>

I am using XQuery with Saxon: java -cp saxon9.jar net.sf.saxon.Query query.xq

Could you please help me?

Thank you very much, I am really desperate in getting this working.

Kind regards

jz


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.