[xmlschemata] xvif: fallback mechanism

From: Eric van der Vlist <vdv@dyomedea.com>
Date: Fri Jun 21 2002 - 07:13:54 UTC

One of the comments received so far about xvif is that the current
syntax changes the semantic of the Relax NG schema.

In other words, when I am writing:

<?xml version="1.0" encoding="utf-8"?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo">
 <if:transform type="http://simonstl.com/ns/fragments/"
  xmlns:if='http://namespaces.xmlschemata.org/xvif/iframe'>
  <if:apply>
   <fragmentRules xmlns="http://simonstl.com/ns/fragments/">
    <fragmentRule pattern="," split="true" skipFirst="false"
repeat="true">
     <applyTo>
      <element localName="foo"/>
     </applyTo>
     <produce>
      <element localName="item"/>
     </produce>
    </fragmentRule>
   </fragmentRules>
  </if:apply>
 </if:transform>
 <oneOrMore>
  <element name="item">
   <choice>
    <value>foo</value>
    <value>bar</value>
   </choice>
  </element>
 </oneOrMore>
</element>

This is a perfectly valid Relax NG schema but this schema has a
different meaning and validates a different class of documents for a
Relax NG "classical" processor such as Jing and my xvif implementation.

A Relax NG "classical" processor will, per the Relax NG specification,
discard any element which do no belong to the Relax NG namespace and
read this schema as:

<?xml version="1.0" encoding="utf-8"?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo">
 <oneOrMore>
  <element name="item">
   <choice>
    <value>foo</value>
    <value>bar</value>
   </choice>
  </element>
 </oneOrMore>
</element>

ie as a foo element holding item text only elements with values "foo" or
"bar" such as:

<foo>
  <item>bar</item>
  <item> foo</item>
</foo>

A xvif implementation will OTH accept such documents after applying a
regular fragmentation on "foo" and validate instance documents such as:

<foo>bar, foo</foo>

A solution to this issue is to slightly reorganize the content models of
the xvif elements and to write:

<?xml version="1.0" encoding="utf-8"?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo"
  xmlns:if='http://namespaces.xmlschemata.org/xvif/iframe'>
 <if:pipe>
  <if:transform type="http://simonstl.com/ns/fragments/">
   <if:apply>
    <fragmentRules xmlns="http://simonstl.com/ns/fragments/">
     <fragmentRule pattern="," split="true" skipFirst="false"
                   repeat="true">
      <applyTo>
       <element localName="foo"/>
      </applyTo>
      <produce>
       <element localName="item"/>
      </produce>
     </fragmentRule>
    </fragmentRules>
   </if:apply>
  </if:transform>
  <oneOrMore>
   <element name="item">
    <choice>
     <value>foo</value>
     <value>bar</value>
    </choice>
   </element>
  </oneOrMore>
 </if:pipe>
 <text/>
</element>
 
A Relax NG processor will now read the schema as:

<?xml version="1.0" encoding="utf-8"?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo"
  xmlns:if='http://namespaces.xmlschemata.org/xvif/iframe'>
 <text/>
</element>

And validate a superset of the class of instance documents validated by
the xvif processor which will now add new validations rather than doing
a different set of validations.

Note that the <text/> pattern is not necessary for a xvif processor and
that schema designers may want to skip them in this case. This could be
done by adding a if:skip attribute to instruct a xvif processor to skip
the pattern which would then become a fallback mechanism and the full
schema could be:

<?xml version="1.0" encoding="utf-8"?>
<element xmlns="http://relaxng.org/ns/structure/1.0" name="foo"
  xmlns:if='http://namespaces.xmlschemata.org/xvif/iframe'>
 <if:pipe>
  <if:transform type="http://simonstl.com/ns/fragments/">
   <if:apply>
    <fragmentRules xmlns="http://simonstl.com/ns/fragments/">
     <fragmentRule pattern="," split="true" skipFirst="false"
                   repeat="true">
      <applyTo>
       <element localName="foo"/>
      </applyTo>
      <produce>
       <element localName="item"/>
      </produce>
     </fragmentRule>
    </fragmentRules>
   </if:apply>
  </if:transform>
  <oneOrMore>
   <element name="item">
    <choice>
     <value>foo</value>
     <value>bar</value>
    </choice>
   </element>
  </oneOrMore>
 </if:pipe>
 <text if:skip="true"/>
</element>

Eric

PS: to subscribe to xmlschemata@xmlschemata.org, please send an email
with "subscribe" in the title or body to
xmlschemata-request@xmlschemata.org .

-- 
See you in San Diego.
                               http://conferences.oreillynet.com/os2002/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------
Received on Fri Jun 21 09:13:55 2002

This archive was generated by hypermail 2.1.8 : Fri Dec 03 2004 - 14:29:47 UTC