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] Arbitrary grouping

[ Lists Home | Date Index | Thread Index ]

Also worthy of note is the Microsoft XSD Inference tool [5], which can also
infer an XSD schema from one or more XML documents, and validate them in the
process. Results of which also shown below.

Mike

[5] http://apps.gotdotnet.com/xmltools/xsdinference/XSDInference.exe

C:\XML\Rng\Examples>cat ex1.xml
<ex>
 <a/>
 <b/>
 <c/>
 <d/>
 <e/>
 <f/>
</ex>

C:\XML\Rng\Examples>cat ex2.xml
<ex>
 <grp>
  <a/>
  <b/>
 </grp>
 <c/>
 <grp>
  <d/>
  <e/>
  <f/>
 </grp>
</ex>

C:\XML\Rng\Examples>cat ex3.xml
<ex>
 <a/>
  <grp>
   <b/>
   <c/>
   <d/>
  </grp>
  <e/>
  <f/>
</ex>

C:\XML\Rng\Examples>infer -v ex1.xml ex2.xml ex3.xml
Microsoft (R) XSD Inference Command Line Utility V1.0
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

.\ex1.xml validation finished successfuly
.
.\ex2.xml validation finished successfuly
.
.\ex3.xml validation finished successfuly
.
Schema 1:

********************************************************
<?xml version="1.0" encoding="IBM437"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs
="http://www.w3.org/2001/XMLSchema";>
  <xs:element name="ex">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="grp">
            <xs:complexType>
              <xs:sequence>
                <xs:choice maxOccurs="unbounded">
                  <xs:element name="d" />
                  <xs:element name="e" />
                  <xs:element name="f" />
                  <xs:element name="a" />
                  <xs:element name="b" />
                  <xs:element name="c" />
                </xs:choice>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
          <xs:element name="a" />
          <xs:element name="b" />
          <xs:element name="c" />
          <xs:element name="d" />
          <xs:element name="e" />
          <xs:element name="f" />
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

C:\XML\Rng\Examples>infer -o ex.xsd -v ex1.xml ex2.xml ex3.xml

#### ex.xsd becomes ex_1.xsd
#### msv warnings are mild warnings regard implicit use of anyType in
ex_1.xsd

C:\XML\Rng\Examples>java -jar c:\lib\msv.jar ex_1.xsd ex1.xml ex2.xml
ex3.xml
start parsing a grammar.
warnings are found. use -warning switch to see all warnings.
validating ex1.xml
the document is valid.
--------------------------------------
validating ex2.xml
the document is valid.
--------------------------------------
validating ex3.xml
the document is valid.

> -----Original Message-----
> From: Mike Fitzgerald [mailto:mike@wyeast.net]
> Sent: Monday, March 10, 2003 9:40 AM
> To: Hunsberger, Peter; xml-dev
> Subject: RE: [xml-dev] Arbitrary grouping
>
>
> Look at <interleave> from RELAX NG [1]. You can also use Trang [2], a Java
> tool by XML wundermensch James Clark that infers RELAX NG and XSD schemas
> from XML and translates from RNG to XSD. Then validate against
> these schemas
> with Sun's Multi-schema Validator [3], a Java tool written by Kawaguchi
> Kohsuke that validates Relax, RELAX NG, XSD, and DTD. See full
> examples [4].
> Trang generates suitable constructs, other than <interleave>, to construct
> schemas that work for both RNG and XSD.
>
> Mike
>
> [1]
> http://www.oasis-open.org/committees/relax-ng/tutorial-20011203.ht
> ml#IDAN1YR
> [2] http://thaiopensource.com/relaxng/trang.html
> [3] http://wwws.sun.com/software/xml/developers/multischema/
> [4] Examples:
>
> C:\XML\Rng\Examples>cat ex1.xml
> <ex>
>  <a/>
>  <b/>
>  <c/>
>  <d/>
>  <e/>
>  <f/>
> </ex>
>
> C:\XML\Rng\Examples>cat ex2.xml
> <ex>
>  <grp>
>   <a/>
>   <b/>
>  </grp>
>  <c/>
>  <grp>
>   <d/>
>   <e/>
>   <f/>
>  </grp>
> </ex>
>
> C:\XML\Rng\Examples>cat ex3.xml
> <ex>
>  <a/>
>   <grp>
>    <b/>
>    <c/>
>    <d/>
>   </grp>
>   <e/>
>   <f/>
> </ex>
>
> C:\XML\Rng\Examples>java -cp c:\lib\trang.jar;c:\lib\jing.jar -jar
> c:\lib\trang.jar e
> x1.xml ex2.xml ex3.xml ex.rng
>
> C:\XML\Rng\Examples>java -jar c:\lib\msv.jar ex.rng ex1.xml
> ex2.xml ex3.xml
> start parsing a grammar.
> validating ex1.xml
> the document is valid.
> --------------------------------------
> validating ex2.xml
> the document is valid.
> --------------------------------------
> validating ex3.xml
> the document is valid.
>
> C:\XML\Rng\Examples>java -jar c:\lib\msv.jar ex.xsd ex1.xml
> ex2.xml ex3.xml
> start parsing a grammar.
> validating ex1.xml
> the document is valid.
> --------------------------------------
> validating ex2.xml
> the document is valid.
> --------------------------------------
> validating ex3.xml
> the document is valid.
>
> C:\XML\Rng\Examples>
>
> > -----Original Message-----
> > From: Hunsberger, Peter [mailto:Peter.Hunsberger@stjude.org]
> > Sent: Monday, March 10, 2003 8:36 AM
> > To: 'xml-dev@lists.xml.org'
> > Subject: [xml-dev] Arbitrary grouping
> >
> >
> > I'm new to XML schema and am confused on how I would create a
> schema that
> > introduces a set of arbitrary grouping for a set of elements.
> > For example:
> >
> > 	<x>
> > 		<a/>
> > 		<b/>
> > 		<c/>
> > 		<d/>
> > 		<e/>
> > 		<f/>
> > 	</x>
> >
> > or
> >
> > 	<x>
> > 		<group>
> > 			<a/>
> > 			<b/>
> > 		</group>
> > 		<c/>
> > 		<group>
> > 			<d/>
> > 			<e/>
> > 			<f/>
> > 		</group>
> > 	</x>
> >
> > or perhaps
> >
> > 	<x>
> > 		<a/>
> > 		<group>
> > 			<b/>
> > 			<c/>
> > 			<d/>
> > 		</group>
> > 		<e/>
> > 		<f/>
> > 	</x>
> >
> > would all be considered valid.  Additional constraints are that
> any number
> > of groups can occur, but the elements a through f can each only occur a
> > maximum of once inside the x element whether they are children of
> > a group or
> > not.
> >
> > Peter Hunsberger
> >
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> >
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> >
> > To subscribe or unsubscribe from this list use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> >
> >
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>





 

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

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