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] Solving current schema problems with DSDs

[ Lists Home | Date Index | Thread Index ]


> 1. Checking content (strings particularly) against different types
>    of element attribute. For example how would the following be
>    done in current schemas so that invalid cases were trapped?
>
>         <AttribContext>
>           <!-- Valid -->
>           <Var Type="fixed">1234</Var>
>           <Var Type="float">3.14159</Var>
>           <Var Type="hex">345ABCH</Var>
>           <Var Type="hex">03fe5a6H</Var>
>           <!-- Invalid -->
>           <Var Type="hex">34V56H</Var>
>           <Var Type="hex">abcdh</Var>
>           <Var Type="hex">2adef</Var>
>           <Var Type="fixed">2a1217</Var>
>           <Var Type="fixed">2+1217</Var>
>           <Var Type="float">32.8.7</Var>
>           <Var Type="fixed">2.1217</Var>
>         </AttribContext>

In RELAX NG, you can do it like this:

datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes";

element AttribContext {
  element Var {
    (attribute Type { "fixed" }, xsd:integer)
    | (attribute Type { "float" }, xsd:float)
    | (attribute Type { "hex" }, xsd:token { pattern = "[0-9a-fA-F]+H" })
  }*
}

(This is using the non-XML syntax:
http://www.thaiopensource.com/relaxng/nonxml/)

> 2. The other and, I believe more critical, problem was the challenge
>    I gave to Nis Klarlundis and described on the DSD site at
>    http://www.research.att.com/projects/DSD/generic-lists/. I still
>    do not believe that this challenge has been successfully answered
>    in any other schema (except possibly the Schematron which I consider
>    to be a validation rather than a definition language).

That particular document can be handled straightforwardly by this:

element person {
  element surname { text },
  element forenames {
    element oList {
      element listItem { element name { text } }*
    }
  },
  element webbs {
    element oList {
      element listItem { element qualification { text } }*
    }
  }
}

If you want to do this as modification to a generic ordered list schema, you
can also do that.  Here's the list schema:

start = element oList { element listItem { itemContent }* }

and here's a person schema that uses it:

element person {
  element surname { text },
  element forenames {
    grammar {
      include "list.rng"
      itemContent = element name { text }
    }
  },
  element webbs {
    grammar {
      include "list.rng"
      itemContent = element qualification { text }
    }
  }
}

James


















 

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

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