[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xpath problem

  • From: "Michael Kay" <mike@saxonica.com>
  • To: "'Vincent De Groote'" <list.encelade@gmail.com>,"'xml-dev'" <xml-dev@l...>
  • Date: Tue, 12 Jan 2010 17:26:10 -0000

RE:  xpath problem
>The referenced "a" node should exist in its preceding-siblings, the
preceding-siblings of its parent, ... up to the "x" ascendant: 

Apart from stopping at the x element, that constraint can be written

@id-ref = ancestor-or-self::*/preceding-sibling::*/@id

Stopping at the x element can be done as

@id-ref = (ancestor-or-self::* except
ancestor::x/ancestor-or-self::*)/preceding-sibling::*/@id


Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Vincent De Groote [mailto:list.encelade@gmail.com] 
> Sent: 12 January 2010 17:09
> To: xml-dev
> Subject:  xpath problem
> 
> Hello,
> 
> I have a xml file, simplified like this:
> 
> <a-file>
> 
> <x>
>   <a id='a1'/>
>   <a id='a2'/>
>   <bb>
>     <xx>
>        <a id='55'/>
>        <a id='66'/>
>     </xx>
>     <a id='a3'/>
>     <a id='a4'/>
>     <cc>
>        <a-ref id-ref='a2'/>
>        <a-ref id-ref='a4'/>
>     </cc>
>   </bb>
>   <a id='a7'/>
>   <a id='a8'/>
> </x>
> 
> <x>
>   ...
> </x>
> 
> </a-file>
> 
> In this xml file, "a-ref/@id-ref" shoud reference a "a/@id" 
> under its "x" ascendant.
> 
> I wrote the xml schema grammar: the "a/@id" attributes are 
> checked to be unique within an "x" element, and the 
> "a-ref/@id-ref" attributes are checked to reference an 
> existing "a/@id" attribute.
> 
> I have another constraint:  an "a-ref/@id-ref" may only 
> reference a "a/@id" node which appears before him, within its 
> "x" ascendant.
> The referenced "a" node should exist in its 
> preceding-siblings, the preceding-siblings of its parent, ... 
> up to the "x" ascendant:
> 
> In other words, in the example, the first "a-ref" element 
> should only reference one of the following ids: a1, a2, a3, 
> a4, but not 55 or 66,
> a7 or a8.
> 
> In xslt-2, i can write a function which checks this rule, but 
> i cannot find a way to write it in a grammar.
> I will need to use embedded shematron rules for other checks, 
> but i cannot find an xpath to check this rule.
> 
> I'm working with saxon9-ee edition.
> 
> Any idea on how to do that ?
> 
> Thanks for your replies
> Vincent De Groote
> 
> ______________________________________________________________
> _________
> 
> XML-DEV is a publicly archived, unmoderated list hosted by 
> OASIS to support XML implementation and development. To 
> minimize spam in the archives, you must subscribe before posting.
> 
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org List archive: 
> http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
> 


  • References:
    • xpath problem
      • From: Vincent De Groote <list.encelade@gmail.com>

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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-2013 All Rights Reserved.