[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Arbitrary grouping
From: "Mitch Amiano" <mamiano@n...> > Using a Schematron approach might be appropriate > in this case. Depending upon how arbitrary the > grouping is, it may be a more practical means > as opposed to permuting all the possible groupings. I would be a little stronger than that: I think it is generally impractical to use other schema languages for this: you may have some kind of combinatorial explosion. Furthermore, constraints such as that the contents of one branch of a document will determine the allowed elements in another branch of the document typically cannot be done by regular-grammar-based systems. {I say typically, because it also depends on how "ambigiuity" is handled: some grammar-based systems such as WXS and DTDs say "based on what the parent is, this is what I expect in the children" while it is possible to have a schema language that says "this is what I found in the children, therefore this is what the parent is (or, at least, what the following siblings may be)". I think this is more how RELAX NG can act.} > A better explanation is at > http://www.topologi.com/public/Schtrn_XSD/Paper.html > See also > http://www.topologi.com/products/validator/index.html And also http://www.ascc.net/xml/schematron To be more concrete, here is a Schematron rule that 1) constrains that there are 6 abcdef elements 2) sets up simple partial ordering and existance requirement between these elements, <sch:rule context="x "> <sch:assert test= "count(.//a | .//b | .//c | .//d | .//e | .//f)=6"> An x should contain directly or indirectly 6 abcdef elements. </sch:assert> <sch:assert test=".//f [preceding::e[preceding::d[preceding::c[preceding::b [preceding::a[ancestor::x=current()]]]]]]"> Under an x, the elements abcdef should follow that order. </sch:assert> </sch:rule> (This fairly terse. There are other ways to factor the constraints which would allow better diagnostics and better efficiency, where these were an issue.) Cheers Rick Jelliffe
|
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
|