Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: difference between two schema

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent