Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - difference between two schema [Thread Next] Re: difference between two schemaTo: NULL Date: 11/9/2009 12:50:00 PM thierry wrote:
> Hello,
>
> I would like to understand the difference between FIRST
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://domaine.tld"
> xmlns="http://domaine.tld">
>
> <xsd:element name="serveur" type="xsd:string" />
> <xsd:element name="definition">
> <xsd:complexType>
> <xsd:all>
> <xsd:element ref="serveur" minOccurs
> ="1" maxOccurs ="1" />
> </xsd:all>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> which validate
>
> <?xml version="1.0" encoding="utf-8"?>
> <definition xmlns="http://domaine.tld">
> <serveur>serveur1</serveur>
> </definition>
>
> AND SECOND
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://domaine.tld"
> xmlns="http://domaine.tld">
>
> <xsd:element name="definition">
> <xsd:complexType>
> <xsd:all>
> <xsd:element name="serveur" minOccurs
> ="1" maxOccurs ="1" />
> </xsd:all>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> which validate
>
> <?xml version="1.0" encoding="utf-8"?>
> <definition xmlns="http://domaine.tld">
> <serveur xmlns="">anyType</serveur>
> </definition>
>
> The difference is the xmlns attribute in the serveur tag of the second
> xml file.
The xsd:schema element takes an attribute
elementFormDefault
which can take the value 'unqualified' or 'qualified'. See
http://www.w3.org/TR/xmlschema-0/#QualLocals.
If you don't specify the attribute, as it is the case in your schemas,
it takes on the value 'unqualified' meaning any local/inline definitions
define elements in no namespace. That is why you need to put the
xmlns="" on your "serveur" element. If you don't want to do that but
rather define that elements in the targetNamespace of the schema you can use
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://domaine.tld"
xmlns="http://domaine.tld"
elementFormDefault="qualified">
<xsd:element name="definition">
<xsd:complexType>
<xsd:all>
<xsd:element name="serveur" minOccurs
="1" maxOccurs ="1" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>
--
Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
