[xquery-talk] Returning "pre-pos" context

Michael Kay mhk at mhk.me.uk
Thu Jan 5 17:34:34 PST 2006


Your terminology is a bit out: you're looking for elements, not tags: but I
think what you want is to find three consecutive <tok> elements whose child
<orth> elements contain the values AA, BB, and CC respectively. I'm not sure
why you've focused on the middle one of the three explicitly, but I'll
retain that emphasis in the solution:
 
tok[orth='BB'][following-sibling::tok[1]/orth='CC'][preceding-sibling::tok[1
]/orth='AA']
 
Of course this assumes that your XQuery implementation offers all the axes.
But then you don't actually need XQuery for this: the above is pure XPath
1.0.
 
Michael Kay
http://www.saxonica.com/


  _____  

From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On Behalf Of
Elarrat, EFC
Sent: 05 January 2006 16:27
To: talk at xquery.com
Subject: [xquery-talk] Returning "pre-pos" context


Happy new year everybody
 
 
I have this xml structure
                       <s>
                         <tok>
                              <orth>dataxxx</orth>
                              <lex>
                                   <ctag>datayyy</ctag> 
                              </lex>
                         </tok>
                        ...(mani tok tags for a s tag)
                       </s>
 
I tried to do the following: 
find the tags that contains some data beginning with d (for example) on the
ORTH tag - Ok You guys already helped me with that

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

find the tags that contains some data beginning with d (for example) on the
ORTH AND the CTAG tag - Ok You guys already helped me with that
 
And now the hard one (for me, of course)
within the rules above, I would like to find the same as before, but with
some others tags before it, and some others tag after it. It's hard to
explain...so I'm going to give an example:
This xml
                       <s>
                         <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>
                       </s>
 
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. 
 
Is it possible to do something like this? Thanks for you attention.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20060105/11ad5dbe/attachment.htm


More information about the talk mailing list