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

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

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


Subject: Add pattern to match any element?


At the moment in TREX in order to match an element with arbitrary
content, it is necessary to write a recursive pattern, for example:

<grammar>

  <start name="anyElement">
    <element>
      <anyName/>
      <zeroOrMore>
	<choice>
	  <attribute>
	    <anyName/>
	  </attribute>
	  <anyString/>
	  <ref name="anyElement"/>
	</choice>
      </zeroOrMore>
    </element>
  </start>

</grammar>

This seems a rather overly complex solution for such a conceptually
simple problem.

There are two possible ways to fix this:

1.  Add a pattern that matches a single element, regardless of its name,
attributes and children.  It would be equivalent to the grammar pattern
above.

2.  Add a pattern that matches anything: any attributes and any content.

For the sake of discussion, let's call the first one "anyElement" and
the second one "any".

"anyElement" is definable in terms of "any":

<element>
  <anyName/>
  <any/>
</element>

"any" is also definable in terms of "anyElement":

<zeroOrMore>
  <choice>
    <anyString/>
    <attribute>
       <anyName/>
    </attribute>
    <anyElement/>
  </choice>
</zeroOrMore>

Thus if you have only "any", it's easier to get "anyElement", than it is
to get "any" if you have only "anyElement".

Also "any" has significantly simpler semantics:

  M[[<any/>]](a, c, e) is always true

which nicely complements <notAllowed/>.

On the other hand, it is easier to explain to a non-technical user what
"anyElement" means.  It is also clear from the name "anyElement" what it
matches.  If we added an element with the semantics of "any", it is not
clear what name to give it to make it clear that it doesn't have the
semantics of anyElement.

James



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


Powered by eList eXpress LLC