Question

We can have same namespace for included XSD and including XSD, but is it OK to have it like this? Is this in according to standards for xsd:include tag ?

The Eclipse, (IBM integration designer) isn't giving any warning/errors.

Following is the XSD to be included;

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.example.org/abc/" 
    xmlns="http://www.w3.org/2001/XMLSchema" 
    xmlns:tns="http://www.example.org/abc/">
<simpleType name="FirstName">
    <restriction base="string"></restriction>
</simpleType>
<simpleType name="LastName">
    <restriction base="string"></restriction>
</simpleType>
<complexType name="completeNameType">
    <sequence>
        <element name="FirstName" type="tns:FirstName"></element>
        <element name="LastName" type="tns:LastName"></element>
    </sequence>
</complexType>

<element name="completeName" type="tns:completeNameType"></element>
</schema>

and following XSD is including it,

 <?xml version="1.0" encoding="UTF-8"?>
    <schema targetNamespace="http://www.example.org/abc/"
    xmlns="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://www.example.org/abc/">
    <include schemaLocation="included.xsd"></include>

    <element name="completeName" type="tns:completeNameType"></element>
     </schema>
Was it helpful?

Solution

Yes.

Use xsd:include to bring in an XSD from the same or no namespace. (Including an XSD with no namespace to one with a namespace will result in the included XSD components assuming the namespace of the including XSD. Henry Thompson named such a pattern, chameleonic.)

Use xsd:import to bring in an XSD from a different namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top