Immediate Return for a SOA with New and Exciting Purposes

Web 2.0 & Enterprise Mashups

Subscribe to Web 2.0 & Enterprise Mashups: eMailAlertsEmail Alerts newslettersWeekly Newsletters
Get Web 2.0 & Enterprise Mashups: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Enterprise Mashups Authors: Andy Thurai, Hovhannes Avoyan, David Weinberger, RealWire News Distribution, Tomohiro Iizuka

Related Topics: Enterprise Mashups, XML Magazine

RSS Feed Item

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 !

Read the original blog entry...