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

Re: Creating a single XML vocabulary that is appropriatelycust

  • From: Philippe Poulard <philippe.poulard@s...>
  • To: "Costello, Roger L." <costello@m...>
  • Date: Wed, 09 Jul 2008 18:49:50 +0200

Re:  Creating a single XML vocabulary that is appropriatelycust
Costello, Roger L. a écrit :
> How do you create a single XML vocabulary, and validate that XML
> vocabulary, for a community that has sub-groups that have overlapping
> but different data needs?

This is a job for ASL !!!
For ASL, it is a trivial case of mutual-exclusion.

Before going further, my thoughts about a Schematron-based solution are:
-it is not so much readable
-it is not structural, that is to say that Schematron doesn't act on the 
content model but applies some rules after the grammar checking ; I'm 
afraid that W3C XML Schema 1.1 implementations will work that way too.

Fortunately, there is the ASL way (for the newbies, ASL stand for Active 
Schema Language :) ) that addresses this case (and others) with a single 
schema more simpler and shorter that the Schematron solution and the 
NVDL-based solution that Roger had proposed. It has the advantage that 
it doesn't need to know in advance which kind of books will come : the 3 
flavours will be validated with this single schema.

Note : I will talk about ASL at Balisage 2008
"Properties of schema mashups: dynamicity, semantic, mixins, hyperschemas"
http://www.balisage.net/Program.html#h245p

Basically, ASL does the same as other schema technologies with only 20 
elements but with much more power (I think) and everybody that has read 
before XML-based schemas should understand it easily. Just a comment 
about the <asl:interim> element : read it like this : "when the host 
element matches, then do the job within" (this is why it was called 
"interim" but I'm not sure it was a good idea)

Anyway, here is the schema, that you can run yourself if you download 
the RefleX engine (see below) :

<?xml version="1.0" encoding="iso-8859-1" ?>
<asl:active-schema
     xmlns:xcl="http://ns.inria.org/active-tags/xcl"
     xmlns:asl="http://ns.inria.org/active-schema"
     xmlns:xs="http://www.w3.org/2001/XMLSchema-datatypes"
     xmlns:b="http://www.books.org"
     target="b"
 >
<!--
     Testing mutual-exclusion.
-->

     <asl:element name="b:Books" root="always">
         <asl:attribute ref-ns="xml" min-occurs="0"/>
         <asl:sequence>
             <asl:element ref-elem="b:Book" min-occurs="1" 
max-occurs="unbounded"/>
         </asl:sequence>
     </asl:element>

     <asl:element name="b:Book">
         <asl:choice>
             <asl:element ref-elem="b:Title" min-occurs="0">
                 <asl:interim>
                     <asl:sequence>
                         <asl:element ref-elem="b:Author"/>
                     </asl:sequence>
                     <asl:choice>
                         <asl:element ref-elem="b:Date" min-occurs="0">
                             <asl:interim>
                                 <asl:sequence>
                                     <asl:element ref-elem="b:ISBN"/>
                                     <asl:element ref-elem="b:Publisher"/>
                                 </asl:sequence>
                             </asl:interim>
                         </asl:element>
                         <asl:element ref-elem="b:Size" min-occurs="0">
                             <asl:interim>
                                 <asl:sequence>
                                     <asl:element ref-elem="b:Weight"/>
                                     <asl:element ref-elem="b:MailingCost"/>
                                 </asl:sequence>
                             </asl:interim>
                         </asl:element>
                     </asl:choice>
                 </asl:interim>
             </asl:element>
             <asl:element ref-elem="b:Size" min-occurs="0">
                 <asl:interim>
                     <asl:sequence>
                         <asl:element ref-elem="b:NumPages"/>
                     </asl:sequence>
                 </asl:interim>
             </asl:element>
         </asl:choice>
     </asl:element>

     <asl:element name="b:Title" id="b:simpleText">
         <asl:sequence>
             <asl:text ref-type="xs:string"/>
         </asl:sequence>
     </asl:element>
     <asl:element name="b:Author">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:Date">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:ISBN">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:Publisher">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:Size">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:Weight">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:MailingCost">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>
     <asl:element name="b:NumPages">
         <asl:use ref-id="b:simpleText"/>
     </asl:element>

</asl:active-schema>

If you want to experiment it yourself:
-download RefleX 0.3.1 (choose full-bin or src ; minimal-bin should work 
too):
http://reflex.gforge.inria.fr/running.html#download
-unzip RefleX
-checkout the actual schema + an example document + the launcher script 
that I've just added to the repository here :
svn checkout 
svn://scm.gforge.inria.fr/svn/reflex/root/src/tutorial/schema/books
-run it from the directory where RefleX was unzipped:
java -jar reflex-0.3.1.jar run /path/to/books/validate.xcl

Errors will be reported from the book n°4 (the 3 first books in the XML 
example are valid)

Other runnable examples with ASL are available here :
http://reflex.gforge.inria.fr/tutorial-schemas.html

The ASL specification :
http://ns.inria.fr/active-tags/active-schema/active-schema.html

Enjoy !

-- 
Cordialement,

               ///
              (. .)
  --------ooO--(_)--Ooo--------
|      Philippe Poulard       |
  -----------------------------
  http://reflex.gforge.inria.fr/
        Have the RefleX !


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.