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

Re: Solving current schema problems with DSDs


dsds

> 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















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.