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

Returning "pre-pos" context

David Carlisle davidc at nag.co.uk
Thu Jan 5 17:28:24 PST 2006


lex utf 8

> find the tags that contains some data beginning with d (for example) on the
> ORTH tag - Ok You guys already helped me with that

note that Xquery (like XSLT and Xpath) has no access to the tags in a
document, only to the tree structure produced by parsing those tags.
I assume you mean element rather than tag. tag doesn't mean element, the
content of the tag <s> is "s". The content of the element s is the
sequence of white space and tok elements.

> What I would like to do, is to find the BB, but with the AA and the CC with
> it, so the final return value would be like: AA BB CC.

Not sure what you want returned, just those three strings or the 3 orth
elements containing those, or the three tok elements containing those
orth elements. I'll assume the last of these, in which case, perhaps

/s/tok[orth='BB']/(preceding-sibling::*[1],.,following-sibling::*[1])

assuming your processor supports the sibling axes (if not these can
always be rewritten to use <<)

If you want just the sequence of strings AA BB CC then:

/s/tok[orth='BB']/(preceding-sibling::*[1],.,following-sibling::*[1])/string(orth)


saxon produces

$ saxon8q -s tok.xml tok.xq
<?xml version="1.0" encoding="UTF-8"?>
<tok>
                              <orth>AA</orth>
                              <lex>
                                   <ctag>XX</ctag>
                              </lex>
                         </tok>
<tok>
                              <orth>BB</orth>
                              <lex>
                                   <ctag>YY</ctag>
                              </lex>
                         </tok>
<tok>
                              <orth>CC</orth>
                              <lex>
                                   <ctag>ZZ</ctag>
                              </lex>
                         </tok>

for the first expression and


$ saxon8q -s tok.xml tok.xq
<?xml version="1.0" encoding="UTF-8"?>AA BB CC


for the second

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


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.