XSD schema, beginner needs a hint

Grabo

Senior member
Apr 5, 2005
252
56
101
Hi.

So let's say I have an XSD schema that goes like this:

" <?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="URL1"
xmlns:xbe="URL1">

<xsd:group name="book">
<xsd:sequence>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="pubYear" type="xsd:gYear"/>
</xsd:sequence>
</xsd:group>

<xsd:element name="loans" type="xbe:bookloans"/>

<xsd:complexType name="bookloans">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:group ref="xbe:book"/>
</xsd:sequence>
</xsd:complexType>

</xsd:schema> "

Why do I need the xbe xmlns? It has to refer to the same target namespace as targetNamespace, else xbe:bookloans and xbe:book are perceived as calling something undeclared.
If I don't use targetNamespace, I don't need the second prefix xmlns.
I guess I don't see why the complex types and groups aren't included in the targetNamespace as they upon definition use the same prefix as the rest of the document.
, i.e <xsd:complexType name="bookloans"> as opposed to <xbe:complexType name="bookloans">.

Any help is appreciated.