Schema & Namespaces

H

hooomee

I'm having tons of trouble getting my schema namespace to work. When i
point the validator at the following two examples, it gives the error:

Warning at (2,2): Could not find schema information for the element
'pleaseWork:aWidget'.

I'm trying to validate it using:
http://apps.gotdotnet.com/xmltools/xsdvalidator/default.aspx

What am I missing/not understanding? I'm familiar with namespaces
from C++, but cant seem to get this right.


instance.xml:
<?xml version="1.0" encoding="utf-8" ?>
<aWidget xmlns="pleaseWork">
<Model>3x4x1.5</Model>
</aWidget>

namespace.xsd:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="pleaseWork" xmlns="pleaseWork" >
<xs:element name="aWidget" type="Widget" />
<xs:complexType name="Widget">
<xs:all>
<xs:element name="Model" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:schema>
 
H

hooomee

yes, i know they "should" be URI's but that is not required, its just
commen ( and good ) practice to use them. I removed the URI's i had
trying to reduce the problem and make it simpler. If you replace
"pleaseWork" with "http://www.google.com" in both documents it makes no
difference.
 
H

hooomee

Using the following documents I get this error:

Type 'Widget' is not declared.

namespace.xsd:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="pleaseWork" elementFormDefault="qualified" >
<xs:element name="aWidget" type="Widget" />
<xs:complexType name="Widget">
<xs:all>
<xs:element name="Model" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:schema>

instance.xml:
<?xml version="1.0" encoding="utf-8" ?>
<aWidget xmlns="pleaseWork">
<Model>3x4x1.5</Model>
</aWidget>
 
R

Richard Tobin

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="pleaseWork" xmlns="pleaseWork" >
[/QUOTE]
Remove that xmlns="pleaseWork"

No, it's needed for the reference to the type Widget in the element
declaration of aWidget.
and add elementFormDefault="qualified"
as an attribute to the xs:schema element.

Yes, this is the problem. The declaration of the element Model is
a local declaration, and by default it declares the element with no
namespace.

-- Richard
 
A

Andy Dingley

Joe said:
First thing to fix: Namespace names should be absolute URIs.

Why? They need to be URIs, but what requires them to be absolute?

Obviously document portability suffers if they're not, but this
shouldn't affect validity within a local system (i.e. the actual
resolution of the URI remains constant within the scope of all document
instances)
 
J

Joe Kesselman

Andy Dingley said:
Why? They need to be URIs, but what requires them to be absolute?

The W3C debated this at painful length, and concluded that there were
too many conflicting views of what a relative namespace should mean, if
anything. (Think about it. The namespace asserts the semantic intent of
the document. Do you really want a document's intent to change because
you copy it from one directory to another, even on a single machine? Do
you want to deal with the fact that two URIs may resolve to the same
thing but can't be proven to do so?) The conclusion was that relative
namespace URIs should deprecated, and their behavior is explicitly
undefined, until and unless the Semantic Web folks come back to us with
a proposal that makes them meaningful ... and at that time, a lot of
code is going to have to be revisited.

Meanwhile, applications are free to reject relative namespace URIs, or
to compare them as literal strings, or to try to compare them as
resolved... in other words, the behavior is unpredicatable.

That's good and sufficient reason not to climb into this kettle of worms.
 
J

Joe Kesselman

Richard said:
They went so far as to have a ballot on the subject.

Yeah, I know. I was there. It was rather more interesting than any of us
really wanted it to be.
 

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,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top