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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Announce: XML Schema, The W3C's Object-OrientedDescription

[ Lists Home | Date Index | Thread Index ]

Hi Jeni,

On Wed, 2002-06-26 at 15:34, Jeni Tennison wrote:

> For example, if you had something like:
> 
> <length>12.5<unit>cm</unit></length>

Note that this model is only a (simple) XSLT transformation away from
something more "classical" and that (for instance)

     <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
      <xsl:template match="length/text()[normalize-space()]">
       <value>
        <xsl:value-of select="."/>
       </value>
      </xsl:template>
      <xsl:template match="*|@*">
      <xsl:copy>
       <xsl:apply-templates select="@*|*|text()"/>
      </xsl:copy>
     </xsl:template>
    </xsl:transform>

would transform it into

<length><value>12.5</value><unit>cm</unit></length>

which is much easier to validate with any schema language.

That's here that xvif can help and let you write:

<?xml version="1.0" encoding="iso-8859-1"?>
<element xmlns="http://relaxng.org/ns/structure/1.0"; name="length">
  <if:transform type='http://www.w3.org/1999/XSL/Transform'
     xmlns:if='http://namespaces.xmlschemata.org/xvif/iframe'>
    <if:apply xmlns="">
     <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
      <xsl:template match="length/text()[normalize-space()]">
       <value>
        <xsl:value-of select="."/>
       </value>
      </xsl:template>
      <xsl:template match="*|@*">
      <xsl:copy>
       <xsl:apply-templates select="@*|*|text()"/>
      </xsl:copy>
     </xsl:template>
    </xsl:transform>
    </if:apply>
  </if:transform>
  <element name="value">
   <text/>
  </element>
  <element name="unit">
   <text/>
  </element>
</element>

(this is embedded into Relax NG but I am pretty confident that this
could be implemented on top of WXS as well).

Eric

PS: you can try it on
http://downloads.xmlschemata.org/python/xvif/tryMe.cgi

-- 
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
------------------------------------------------------------------------





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS