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] XML Question

[ Lists Home | Date Index | Thread Index ]

Title: RE: [xml-dev] XML Question

Saurabh,

I'll try my best to answer your question without an example of your schema.  If you are using the "sequence" compositor, the elements must appear in the XML instance document in the order in which they are declared in the schema.  For example:

<xsd:complexType name="SomeType">
   <xsd:sequence>
      <xsd:element name="FirstElement" type="xsd:string"/>
      <xsd:element name="SecondElement" type="xsd:string"/>
      <xsd:element name="ThirdElement" type="xsd:string"/>
   </xsd:sequence>
</xsd:complexType>

So if you are using the "sequence" compositor, you will want to change it to the "all" compositor.  The "all" compositor allows the elements declared within it to appear in the XML instance document in any order.  For example:

<xsd:complexType name="SomeType">
   <xsd:all>
      <xsd:element name="FirstElement" type="xsd:string"/>
      <xsd:element name="SecondElement" type="xsd:string"/>
      <xsd:element name="ThirdElement" type="xsd:string"/>
   </xsd:all>
</xsd:complexType>

If this doesn't suffice, I would recommend you consider the "wildcard" feature of W3C Schema (although this may be a bit extreme for your purposes).  The wildcard feature uses an "any" construct for elements (and an "anyAttribute construct for attributes) to create a "placeholder" at which any well-formed XML may appear in an instance document - i.e. it does not specify element/attribute declarations or datatype definitions.  In the following example, the element "ThirdElement" may be (does not have to be) followed in an XML instance document by one or more elements:

<xsd:complexType name="SomeType">
   <xsd:sequence>
      <xsd:element name="FirstElement" type="xsd:string"/>
      <xsd:element name="SecondElement" type="xsd:string"/>
      <xsd:element name="ThirdElement" type="xsd:string"/>
      <xsd:any minOccurs="0"/>
   </xsd:sequence>
</xsd:complexType>

Hope this helps,
Joe Chiusano
LMI
> **************************************************************************
>   Joseph M. Chiusano
>   Logistics Management Institute
>   2000 Corporate Ridge
>   McLean, VA 22102
>   Email: jchiusano@lmi.org
>   Tel: 571.633.7722
> **************************************************************************
>


-----Original Message-----
From: Saxena, Saurabh [mailto:saurabh.saxena@intel.com]
Sent: Wednesday, May 29, 2002 6:33 AM
To: 'xml-dev@lists.xml.org'
Subject: [xml-dev] XML Question


Hi
I am using XML Schema to validate a XML file.If i make change in the
sequence of the TAGS as defined in the Schema.xsd file the parser is giving
an error.Is there any way to ignore that and allow to define the TAGS in any
sequence

regards,
Saurabh Saxena


-----------------------------------------------------------------
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