XSchema: help

  • Thread starter Tjerk Wolterink
  • Start date
T

Tjerk Wolterink

I have an schema, like this one:

<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:x="http://www.wolterinkwebdesign.com/xml/model"
xmlns="http://www.wolterinkwebdesign.com/xml/structure"
targetNamespace="http://www.wolterinkwebdesign.com/xml/structure"
version="1.0">

<xsd:element name="structure">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="metadata"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="author" type="xsd:string"/>
<xsd:element name="keywords" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>


and a document like this one:

<structure
xmlns="http://www.wolterinkwebdesign.com/xml/structure"
xmlns:x="http://www.wolterinkwebdesign.com/xml/model"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.wolterinkwebdesign.com/xml/structure
../schemas/structure.xsd">

<metadata>
<title>XCM Test</title>
<author>Tjerk Wolterink</author>
<keywords>xcm test</keywords>
</metadata>
</structure>



When i try to validate i get this:

Xerces Java 2 Validation Starting.
file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:18,10:
(Error) cvc-complex-type.2.4.a: Invalid content starting with element
'title'. One of '{"":title}' is expected.

huh title is in the namespace of /xml/structure

file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:41,11:
(Error) cvc-complex-type.2.4.a: Invalid content starting with element
'title'. One of '{"":title}' is expected.
Xerces Java 2 Validation Complete.



help me
 
S

Soren Kuula

Hi,
file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:18,10:
(Error) cvc-complex-type.2.4.a: Invalid content starting with element
'title'. One of '{"":title}' is expected.

It says: I want the title element in no-namespace land.

Why ?? Because of a really really silly feature i XSD: Locally declared
elements, such as your title one, slip out of the target namespace and
into no-namespace-land, unless you add an attribute

elementFormDefault="qualified"

to the schema document element (<xsd:schema .......>).

Alternatively, you can alter to:

<xsd:sequence>
<xsd:element name="title" type="xsd:string"
form="qualified"/>
<xsd:element name="author" type="xsd:string"
form="qualified"/>
<xsd:element name="keywords" type="xsd:string"
form="qualified"/>
</xsd:sequence>

in your schema...


(don't try looking in the Schema recommendation for where this is said.
It's totally unreadable :))

Søren
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top