[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: [relax-ng-comment] RELAX NG Restrictions
I have asked similar question some time ago. :-) This is the only thing I have found a little bit difficult about Relax NG. Although the schemas can be written really intuitively, sometimes you (as a beginner) violate some of the constraints for simple-syntax and then you must look at your full-syntax, go through the whole simplification process described in the specification, and figure out what happened. I have been thinking about this too, but could not find any other way than perform the whole simplification process. But, of course, I can miss something. Regards Jirka Rick Jelliffe wrote: > Are any of the restrictions of the simplified form of RELAX NG > applicable to the full form? > > I was making up a little Schematron schema (below) before I twigged that > the restrictions were not generally applicable, and it would be nice > not to throw the whole thing out. > > Cheers > Rick > > <schema xmlns="http://www.ascc.net/xml/schematron" > > <title>Simplified RELAX NG Restrictions</title> > <ns prefix="r" uri="http://relaxng.org/ns/structure/1.0"/> > <p>This schema validates various restrictions on RELAX NG > after it has been simplified.</p> > <p>See http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#restriction</p> > > <pattern name="Restrictions"> > > <rule context="r:ref"> > <report test="ancestor::r:attribute" > >(Simplified RELAX NG) An <attribute> should not have a <ref> anywhere under it</report> > <report test="ancestor::r:list" > >(Simplified RELAX NG) A <list> should not have a <ref> anywhere under it</report> > <report test="ancestor::r:except[parent::r:data]" > >(Simplified RELAX NG) A <except> element contained by a <data> should > not have a <ref> anywhere under it</report> > </rule> > > <rule context="list"> > <report test="ancestor::r:attribute" > >(Simplified RELAX NG) An <attribute> should not have a <list> anywhere under it</report> > <report test="ancestor::r:list" > >(Simplified RELAX NG) A <list> should not have a <list> anywhere under it</report> > <report test="ancestor::r:start" > >(Simplified RELAX NG) A <start> should not have a <list> anywhere under it</report> > > <report test="ancestor::r:except[parent::r:data]" > >(Simplified RELAX NG) A <except> element contained by a <data> should > not have a <list> anywhere under it</report> > <report test="ancestor::r:interleave[ancestor::r:oneOrMore]" > >(Simplified RELAX NG) A <oneOrMore> element anywhere under an <interleave> element should not have > a <list> anywhere under it</report> > > </rule> > > <rule context="r:text"> > <report test="ancestor::r:start" > >(Simplified RELAX NG) An <start> should not have a <text> anywhere under it</report> > <report test="ancestor::r:list" > >(Simplified RELAX NG) A <list> should not have a <text> anywhere under it</report> > <report test="ancestor::r:except[parent::r:data]" > >(Simplified RELAX NG) A <except> element contained by a <data> should > not have a <text> anywhere under it</report> > </rule> > > <rule context="r:interleave "> > <report test="count(//r:text) > 1" > >An <interleave> should not have more than one <text> descendents</report> > <report test="ancestor::r:list" > >(Simplified RELAX NG) An <list> should not have a <<name > />> anywhere under it</report> > <report test="ancestor::r:start" > >(Simplified RELAX NG) An <start> should not have a <<name > />> anywhere under it</report> > <report test="ancestor::r:except[parent::r:data]" > >(Simplified RELAX NG) A <except> element contained by a <data> should > not have a <<name />> anywhere under it</report> > </rule> > > <rule context="r:attribute"> > <report test="ancestor::r:group[parent::r:oneOrMore]" > >(Simplified RELAX NG) A <oneOrMore> element containing an <group> should > not have a <<name />> anywhere under it</report> > </rule> > > <rule context="r:group | r:oneOrMore | r:empty"> > <report test="ancestor::r:start" > >(Simplified RELAX NG) An <start> should not have > a <<name />> anywhere under it</report> > <report test="ancestor::r:except[parent::r:data]" > >(Simplified RELAX NG) A <except> element contained by a <data> should > not have a <<name />> anywhere under it</report> > </rule> > > <rule context="r:data | r:value"> > <report test="ancestor::r:start" > >(Simplified RELAX NG) An <start> should not have > a <<name />> anywhere under it</report> > </rule> > > </pattern> > > <!-- > <pattern name="String_Sequences"> > <rule context="r:element[not(//r:list)] | r:attribute[not(//r:list)]"> > > ??? > > </rule> > </pattern> > --> > <pattern name="Restrictions_on_Attributes_1"> > <!-- limitation: only handles name attributes --> > <!-- the count(*) is too broad --> > <rule context="r:group[count(*)>1]//r:attribute[@name] "> > <report test= > "count(ancestor::r:group//r:attribute/@name=current()/@name)>1 > or > count(ancestor::r:group//r:attribute//r:name=current()/@name)>1" > >(Simplified RELAX) Duplicate attributes are not allowed. </report> > </rule> > > <rule context="r:interleave[count(*)>1]//r:attribute[@name]"> > <report test= > "count(ancestor::r:interleave//r:attribute/@name=current()/@name)>1 > or > count(ancestor::r:interleave//r:attribute//r:name=current()/@name)>1" > >(Simplified RELAX) Duplicate attributes are not allowed. </report> > </rule> > </pattern> > <pattern name="Restrictions_on_Attributes_2"> > <!-- limitation: only handles direct name elements --> > <!-- the count(*) is too broad --> > <rule context="r:group[count(*)> 1)]//r:attribute[r:name] "> > <report test= > "count(ancestor::r:group//r:attribute/@name=current()/r:name)>1 > or > count(ancestor::r:group//r:attribute//r:name=current()/r:name)>1" > >(Simplified RELAX) Duplicate attributes are not allowed. </report> > </rule> > > <rule context="r:interleave[count(*)>1]//r:attribute[r:name]"> > <report test= > "count(ancestor::r:interleave//r:attribute/@name=current()/r:name)>1 > or > count(ancestor::r:interleave//r:attribute//r:name=current()/r:name)>1" > >(Simplified RELAX) Duplicate attributes are not allowed. </report> > </rule> > </pattern> > </schema> > > ---------------------------------------------------------------- > To subscribe or unsubscribe from this elist use the subscription > manager: <http://lists.oasis-open.org/ob/adm.pl > -- <name firstName="Jirka" surname="Jirat"/> <mail> jiratj@systinet.com </mail> <support> http://www.zvon.org </support> <zvonMailingList> http://www.zvon.org/index.php?nav_id=4 </zvonMailingList>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC