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:email@example.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: firstname.lastname@example.org > subscribe: email@example.com List archive: > http://lists.xml.org/archives/xml-dev/ > List Guidelines: http://www.oasis-open.org/maillists/guidelines.php >
[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!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format