DTDs, schema's and namespaces

M

Miel Bronneberg

Hi,

I've got a problem validating an xml document with both a dtd and
a schema. The problem seems to be about namespaces. What I want is a
well-formed, valid XML document, which also validates against a schema.
The following document validates ok at
http://www.stg.brown.edu/service/xmlvalid/ which doesn't check the schema.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

<minim xmlns="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

<lmnt>
Only one.
</lmnt>

</minim>

However, the xsv schema validator (http://www.w3.org/2001/03/webdata/xsv)
complains that: "element {http://www.cs.vu.nl/~embronne/XML/minim}:lmnt
not allowed here (1) in element
{http://www.cs.vu.nl/~embronne/XML/minim}:minim, expecting [{None}:lmnt]".
This can be fixed as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<!DOCTYPE minim SYSTEM "http://www.cs.vu.nl/~embronne/XML/minim/minim.dtd">

<mnm:minim xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.cs.vu.nl/~embronne/XML/minim http://www.cs.vu.nl/~embronne/XML/minim/minim.xsd">

<lmnt>
Only one.
</lmnt>

</mnm:minim>

This seems to be unacceptable to the dtd-validator. If I want this to work
I'd have to modify the dtd and make "mnm:minim" the root element and add as
an attribute "xmlns:mnm". This I find an ugly solution. I was already
dissatisfied that I had to declare "xmlns:xsi" and "xsi:schemaLocation" as
attributes, but making "mnm:minim" the root element, while it should be
"minim" which just happens to be in the namespace "mnm" is really horrible.
Are there better solutions?

Regards, Miel.
 
R

Richard Tobin

Miel Bronneberg said:

Ok, so you want minim and lmnt to both be in the minim namespace, which
is very reasonable.

But your schema (I just downloaded it) is

<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.cs.vu.nl/~embronne/XML/minim"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:mnm="http://www.cs.vu.nl/~embronne/XML/minim">

<element name="minim" type="mnm:minimType"/>

<complexType name="minimType">
<sequence>
<element name="lmnt" type="string" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>

</schema>

This declares the local lmnt element in *no namespace*, not in the
minim namespace. Add elementFormDefault="qualified" to the schema
element.

-- Richard
 
M

Miel Bronneberg

: In article <[email protected]>,

[snip]

: Ok, so you want minim and lmnt to both be in the minim namespace, which
: is very reasonable.

: But your schema (I just downloaded it) is

[snip]

: This declares the local lmnt element in *no namespace*, not in the
: minim namespace. Add elementFormDefault="qualified" to the schema
: element.

Ok, thanks, that works. Now that you mention it, I have read about this
somewhere. Apologies for not reading the manual well enough.

Thanks, Miel.
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top