[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xvif: fallback mechanism


fallback mechanism
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@x..., please send an email
with "subscribe" in the title or body to
xmlschemata-request@x... .
-- 
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
------------------------------------------------------------------------


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.