[
Lists Home |
Date Index |
Thread Index
]
Saurabh,
Here is the W3C site that will help answer you questions and more.
http://www.w3schools.com/schema/default.asp
<http://www.w3schools.com/schema/default.asp>
Regards,
/**
*
* @author Craig
* @Developer
* @Ever Vigilant!!!
*
*/
-----Original Message-----
From: CHIUSANO, Joseph [mailto:JCHIUSANO@lmi.org]
Sent: Wednesday, May 29, 2002 8:58 AM
To: 'Saxena, Saurabh'; xml-dev@lists.xml.org
Subject: RE: [xml-dev] XML Question
You're welcome Saurabh. I have not examined the example you provided for
accuracy - but I believe your question is: "how can I reference a schema
from within an XML instance document?". There are 2 methods for doing so -
which method you use depends on whether or not the schema to which the XML
instance document validates has a target namespace.
If the schema does not have a target namespace, the root element of the XML
instance document will look as follows:
<SomeRootElement xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xsi:noNamespaceSchemaLocation=
"SomeSchema.xsd">
-- where "SomeSchema.xsd" is the name/location of the schema to which the
XML instance document validates..
If the schema has a target namespace, the root element of the XML instance
document will look as follows:
<SomeRootElement xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance> "
xsi:schemaLocation=" http://www.
<http://www.sometargetnamespace.org> sometargetnamespace.org"
"SomeSchema.xsd">
-- where " http://www. <http://www.sometargetnamespace.org/>
sometargetnamespace.org" is the target namespace of the schema
"SomeSchema.xsd".
Hope that 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 8:35 AM
To: 'CHIUSANO, Joseph'
Subject: RE: [xml-dev] XML Question
HI
This was an excellent example.Thanks for it. I have one more question
I am using the Schema.xsd file as
<schema targetNamespace="">
<element name="XML">
<complexType name="XML" content="elementOnly">
<element ref="TEST1" minOccurs="0" maxOccurs="1"/>
<element ref="TEST2" minOccurs="0" maxOccurs="*"/>
</complexType>
</element>
etc...
To include xsd what decalration i have to use in the schema.xsd file
Once again thanks for the help
regards
Saurabh
-----Original Message-----
From: CHIUSANO, Joseph [mailto:JCHIUSANO@lmi.org]
Sent: Wednesday, May 29, 2002 5:39 PM
To: 'Saxena, Saurabh'; 'xml-dev@lists.xml.org'
Subject: 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
<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
<http://www.xml.org> >, an
initiative of OASIS < http://www.oasis-open.org <http://www.oasis-open.org>
>
The list archives are at http://lists.xml.org/archives/xml-dev/
<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 <http://lists.xml.org/ob/adm.pl> >
|