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.
thank you in advance
thierry
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/