OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

[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 &lt;attribute> should not have a &lt;ref> anywhere under it</report>
>    <report test="ancestor::r:list"
>    >(Simplified RELAX NG) A &lt;list> should not have a &lt;ref> anywhere under it</report>
>    <report test="ancestor::r:except[parent::r:data]"
>    >(Simplified RELAX NG) A &lt;except> element contained by a &lt;data> should 
>    not have a &lt;ref> anywhere under it</report>
>   </rule>
> 
>   <rule context="list">
>    <report test="ancestor::r:attribute"
>    >(Simplified RELAX NG) An &lt;attribute> should not have a &lt;list> anywhere under it</report>
>    <report test="ancestor::r:list"
>    >(Simplified RELAX NG) A &lt;list> should not have a &lt;list> anywhere under it</report>
>    <report test="ancestor::r:start"
>    >(Simplified RELAX NG) A &lt;start> should not have a &lt;list> anywhere under it</report>
> 
>    <report test="ancestor::r:except[parent::r:data]"
>    >(Simplified RELAX NG) A &lt;except> element contained by a &lt;data> should 
>    not have a &lt;list> anywhere under it</report>
>    <report test="ancestor::r:interleave[ancestor::r:oneOrMore]"
>    >(Simplified RELAX NG) A &lt;oneOrMore> element anywhere under an &lt;interleave> element should not have 
>    a &lt;list> anywhere under it</report>
> 
>   </rule>
> 
>   <rule context="r:text">
>    <report test="ancestor::r:start"
>    >(Simplified RELAX NG) An &lt;start> should not have a &lt;text> anywhere under it</report>
>    <report test="ancestor::r:list"
>    >(Simplified RELAX NG) A &lt;list> should not have a &lt;text> anywhere under it</report>
>    <report test="ancestor::r:except[parent::r:data]"
>    >(Simplified RELAX NG) A &lt;except> element contained by a &lt;data> should 
>    not have a &lt;text> anywhere under it</report>
>   </rule>
> 
>  <rule context="r:interleave ">
>    <report test="count(//r:text) &gt; 1"
>    >An &lt;interleave> should not have more than one &lt;text> descendents</report>
>    <report test="ancestor::r:list"
>    >(Simplified RELAX NG) An &lt;list> should not have a &lt;<name
> />> anywhere under it</report>
>    <report test="ancestor::r:start"
>    >(Simplified RELAX NG) An &lt;start> should not have a &lt;<name
> />> anywhere under it</report>
>    <report test="ancestor::r:except[parent::r:data]"
>    >(Simplified RELAX NG) A &lt;except> element contained by a &lt;data> should 
>    not have a &lt;<name />> anywhere under it</report>
>   </rule>
> 
>   <rule context="r:attribute">
>    <report test="ancestor::r:group[parent::r:oneOrMore]"
>    >(Simplified RELAX NG) A &lt;oneOrMore> element containing an &lt;group> should 
>    not have a &lt;<name />> anywhere under it</report>
>   </rule>
> 
>   <rule context="r:group | r:oneOrMore | r:empty">
>    <report test="ancestor::r:start"
>    >(Simplified RELAX NG) An &lt;start> should not have 
>    a &lt;<name />> anywhere under it</report>
>    <report test="ancestor::r:except[parent::r:data]"
>    >(Simplified RELAX NG) A &lt;except> element contained by a &lt;data> should 
>    not have a &lt;<name />> anywhere under it</report>
>   </rule>
> 
>   <rule context="r:data | r:value">
>    <report test="ancestor::r:start"
>    >(Simplified RELAX NG) An &lt;start> should not have 
>    a &lt;<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(*)&gt;1]//r:attribute[@name] ">
>    <report test=
>    "count(ancestor::r:group//r:attribute/@name=current()/@name)&gt;1
>    or
>    count(ancestor::r:group//r:attribute//r:name=current()/@name)&gt;1"
>    >(Simplified RELAX) Duplicate attributes are not allowed. </report>
>   </rule>
> 
>   <rule context="r:interleave[count(*)&gt;1]//r:attribute[@name]">
>    <report test=
>    "count(ancestor::r:interleave//r:attribute/@name=current()/@name)&gt;1
>    or
>    count(ancestor::r:interleave//r:attribute//r:name=current()/@name)&gt;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(*)&gt; 1)]//r:attribute[r:name] ">
>    <report test=
>    "count(ancestor::r:group//r:attribute/@name=current()/r:name)&gt;1
>    or
>    count(ancestor::r:group//r:attribute//r:name=current()/r:name)&gt;1"
>    >(Simplified RELAX) Duplicate attributes are not allowed. </report>
>   </rule>
> 
>   <rule context="r:interleave[count(*)&gt;1]//r:attribute[r:name]">
>    <report test=
>    "count(ancestor::r:interleave//r:attribute/@name=current()/r:name)&gt;1
>    or
>    count(ancestor::r:interleave//r:attribute//r:name=current()/r:name)&gt;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