views:

457

answers:

1

I have an xsd document that starts with:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
    <xs:import namespace="http://www.w3.org/XML/1998/namespace"     schemaLocation="http://www.w3.org/2001/xml.xsd"/&gt;
    <xs:complexType name="T_segment">
        <xs:sequence>
            <xs:element ref="element" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute ref="xml:space" use="required"/>
        <xs:attribute ref="id" use="required"/>
    </xs:complexType>
...

When I try to use this xsd in a mapping application like BizTalk it blows up complaining about namespaces. So, I remove the xs:import namespace tag and it complains about the xs:attribute ref="xml:space" tag. So, I remove that and it seems to work ok (at least doesn't blow up).

My question is, what are those tags for? By removing them am I breaking the xsd?

From what I know namespaces are to avoid conflicts. But in the xsd everything is prefixed by xs and the schema itself has xmlns:xs="http://www.w3.org/2001/XMLSchema". I'm not sure what that import is for.

+1  A: 

The xs:import element imports the "xml" namespace into the schema. The imported namespace contains the definition for the "space" attribute. The <xs:attribute ref="xml:space" use="required"/> bit defines a required "space" attribute for the "T_segment" complex type by reference from the imported schema (i.e. so that you don't have to rewrite the definition). The space attribute essentially gives you the ability to define whether whitespace is significant for the element or not.

Now, depending on application you actually might be breaking things because essentially you are removing a constraint from the complex type that might be relevant to the application consuming the document described by this schema. Without knowing more of the application it is difficult to say if this is significant in your case or not.

Petri Pellinen
Great. I understand it now. Thanks for explaining it in clear terms.
metanaito