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 ]

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.html#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>
>
>





 

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

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