ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wannheden, Knut" <knut.wannhe...@paranor.ch>
Subject RE: xml namespace support in ant2
Date Fri, 06 Sep 2002 10:20:19 GMT
> > Other than that you still have to decide on a schema 
> language to use.  I
> > would argue that RELAX NG would be the most suitable for 
> this kind of stuff.
> > But I'm not an expert on this, so maybe someone will disagree.
> 
> For this, DTD is not usable, Schema is possible, but many agree that 
> RELAX NG is the best... if only I knew what it is ;-)
> 

Take a look at the excellent RELAX NG Tutorial
(http://www.oasis-open.org/committees/relax-ng/tutorial-20011203.html).

Just to give you an idea, here is the (complete?) grammar I wrote for
<patternset> (using an XML namespace):


<grammar xmlns="http://relaxng.org/ns/structure/1.0" 
         xmlns:ant="http://jakarta.apache.org/Ant/v2">

 <define name="patternset">
  <element name="ant:patternset">
   <ref name="default-attributes"/>
   <ref name="patternset-content"/>
  </element>
 </define>

 <define name="default-attributes">
  <optional><attribute name="id"/></optional>
  <optional><attribute name="description"/></optional>
 </define>

 <define name="patternset-content" combine="choice">
  <attribute name="refid"/>
 </define>

 <define name="patternset-content" combine="choice">
  <ref name="patternset-attributes"/>
  <ref name="patternset-elements"/>
 </define>

 <define name="patternset-attributes">
  <optional><attribute name="includes"/></optional>
  <optional><attribute name="includesfile"/></optional>
  <optional><attribute name="excludes"/></optional>
  <optional><attribute name="excludesfile"/></optional>
 </define>

 <define name="patternset-elements">
  <zeroOrMore>
   <element>
    <choice>
     <name>ant:include</name>
     <name>ant:includesfile</name>
     <name>ant:exclude</name>
     <name>ant:excludesfile</name>
    </choice>
    <attribute name="name"/>
    <optional><attribute name="if"/></optional>
    <optional><attribute name="unless"/></optional>
   </element>
  </zeroOrMore>
 </define>

</grammar>

Since RNG is very flexible you can write an equivalent grammar in many
different ways.  Just a matter of style and taste.

To play around with RELAX NG I suggest you download Sun's MSV
(http://wwws.sun.com/software/xml/developers/multischema/).

Cheers,

--
knut

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message