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: FAQ: answers



I think we are going to deal with many questions and answers. How do
we organize them within this mailing list?

1. Shall we list all questions first, and then try to answer them one
   by one?

2. Shall we post one question in one message?



Let me try to write answers for several easy ones.
Generally these are partial answers, rather than the complete answers.



> I read that RELAX NG is based on "regular tree languages"? What's that all 
> about? Does it have any practical benefits?

As long as you are using RELAX NG, you don't need to know anything
about those geeky stuff. But yes, it does have several practical
benefits.

(1) The validation algorithm becomes simple because this theory is
    well-studied. This contributes to make validators smaller and
    faster.
(2) It makes RELAX NG easier to harmonize with other spec.

If you want to learn more about the regular tree language, go to
http://*****.



> What about the XML Schema processContents="strict|lax|skip" feature? How 
> can I do this in RELAX NG?

There is no special primitive for the wild card in RELAX NG, but you
can use the "name class" to achieve the same effect. 

Generally, "skip" is easy to mimic, but "strict" and "lax" are hard.

For example, the following pattern corresponds with
<any processContents="skip" namespace="##other"/>

<define name="wildcard.skipOther">
  <element>
    <anyName>
      <except><nsName/></except>
    </anyName>
    
    <zeroOrMore>
      <choice>
        <text/>
        <attribute><anyName/></attribute>
        <ref name="wildcard.skipOther"/>
      </choice>
    </zeroOrMore>
  </element>
</define>


> Why doesn't RELAX NG support minOccurs/maxOccurs as XML Schema?

[I cannot think of the strong rationale].

But If you really want to use minOccurs/maxOccurs, you can use
<a href="my preprocessor">the pre-processor</a>, which recognizes
minOccurs/maxOccurs and expand it to the normal RELAX NG syntax.



> What's the use of the <interleave> element in RELAX NG?

unordered content model. Another nice technique is to implement a
"set":

<list>
    <interleave>
        <optional>
            <value>abc</value>
        </optional><optional>
            <value>def</value>
        </optional><optional>
            <value>ghi</value>
        </optional>
    </interleave>
</list>



> What's the use of the combine attribute in RELAX NG?

Practically, combine="choice" and combine="interleave" serve two
completely different purpose.

1) combine="choice"

One of the technique is to implement the "class" of elements.

<define name="inline.class" combine="choice">
  <element name="b"> ... </element>
</define>

<define name="inline.class" combine="choice">
  <element name="i"> ... </element>
</define>


Another technique it to extend an already defined class.

<define name="list.class">
  <choice>
    <ref name="dl"/>
    <ref name="ul"/>
    <ref name="ol"/>
  </choice>
</define>

<define name="list.class" combine="choice">
  <ref name="xl"/>
</define>


2) combine="interleave"

Used to append attributes.


regards,
--
Kohsuke KAWAGUCHI                          +1 650 786 0721
Sun Microsystems                   kohsuke.kawaguchi@sun.com



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


Powered by eList eXpress LLC