xml schema info

Tue, Aug 2, 2005

You use xsd:include when you want to bring definitions from another schema but in the same namespace into your own schema. The main point to remember is the included schema must have the same targetNamespace as the including schema. If you try to include a schema from another namespace, you get the error:

The targetNamespace of the referenced schema … must be identical to that of the including schema …

You use xsd:import when you want to bring element definitions in from another namespace. The main point here is that you can only import from a different namespace. You use this to extend your schema using definitions from another namespace. It’s also essential that you specify the schema location URI for the namespace you’re importing:

<import namespace=“urn:oasis:names:tc:SAML:2.0:metadata” schemaLocation=“saml/saml-schema-metadata-2.0.xsd”/>

I used the above xsd:import when developing the Guanxi Service Provider extensions to the SAML2 Metadata specification.

With the above schema, I get the validation error:

Invalid content was found starting with element ‘service-provider’. One of ‘{"":service-provider}’ is expected.

To get rid of the validation error, change elementFormDefault to be:


comments powered by Disqus