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

Re: help with schematron (axis in pattern must be child or att

  • From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
  • To: xml-dev@lists.xml.org
  • Date: Sun, 17 Oct 2010 16:21:27 -0400

Re:  help with schematron (axis in pattern must be child or att
At 2010-10-17 12:04 -0700, trubliphone wrote:
>I have a question about Schematron.  I don't know if this is a 
>suitable forum, but it's worth a shot.

I think Schematron questions are entirely in scope here ... no 
problem in my view.

>I have an XML file with certain elements with an attribute that can 
>take one of a set of values.  That set, however, change depending 
>upon the position of the element.  Here's a simplified sample:
>   <!-- the 1st matching element -->
>   <element match="true" value="one"/>
>   <element match="false">
>     <element match="false">
>      <!-- the 2nd matching element -->
>       <element match="true" value="two"/>
>     </element>
>   </element>
>   <element match="false/>
>   <!-- the 3rd matching element -->
>   <element match="true" value="three/>
>   ...
>I've been playing with XPath and the following expression will match 
>all of the appropriate elements:

All you need is "*[@match='true']" since only attributes can have 
attached attributes.  And this expression is, implicitly through an 
abbreviation, accessing the child axis as the complete syntax is 

>I can narrow this down by adding "[position()=n]" and then check in 
>an <assert> that @value is one of the allowable terms.
>In order to ensure that I don't miss out on any _nested_ elements 
>(as with number 2 above) - the matching elements could be absolutely 
>anyplace in the document - I search all descendants of the root element.

No need ... the expression I've given you above is context free ... 
it will match elements at any depth of the tree.

>However, the above expression generates an error: "axis in pattern 
>must be child or attribute".

Right, because you've used the "descendent-or-self::" axis and that 
isn't allowed in a pattern expression, which is a subset of all expressions.

I hope this helps.

. . . . . . . . . Ken

XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/x/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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


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.
First Name
Last Name
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.