xml validation ... help!

I

ian.rutgers

In validating http://www.otima.ca/XML/auto.xml (auto.xsd) I get the
following error: "Attribute 'make' should be qualified[XML]" If you
look at my schema i do havit it qualified, so I don't understand!
Please, someone, set me right.

Thank you,

Ian
 
P

Priscilla Walmsley

Hi Ian,

Default namespace declarations do not apply to attributes. So, when you
use the "make" attribute in your instance, and don't prefix it, it is
not in any namespace.

To make it work, you need to assign a prefix to the namespace and prefix
all the attribute names. For example,

<dealership xmlns:eek:t="http://www.otima.ca"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.otima.ca auto.xsd">
<ot:auto ot:make="Sienna" ot:model="XLE Limited" ot:year="2004"> ...

I usually recommend against qualified attributes in cases like this
because adding all the prefixes does not really add any information and
clutters up the document.


Hope that helps,
Priscilla
 
I

Ian Rutgers

Hi Priscilla,

Thank you for taking a look at my files. (Alway appreciate an expert's
advice). I have two follow up quesitons for you.
1. I removed all the prefixes (after backing up the files) from both the
xml and the xsd files and tried to validate the xml file ... told me it
didn't know about most of the elements ... so I put everything back and
when I re-validated ... the file validated?! Would you please take
another look and explain why it is right now (maybe I didn't back
everything up the same?)
2. You're recommendation is to remove all prefixes in this instance.
Would you please clarify in which file(s) to remove the prefixes and
that "all" prefixes should be removed.


Your humble student ...

Ian
 
P

Priscilla Walmsley

Hi,

Are you sure it's validating as it is now? Your schema is not
well-formed XML because it has two default namespace declarations.

Declaring the attributes as unqualified is not a matter of removing
prefixes from the schema. What you need to do instead is:

1. change attributeFormDefault to "unqualified" at the top of your
schema (or leave it off completely - unqualified is the default).

2. make your attribute declarations local, as in:

<xs:element name="auto">
<xs:complexType>
<xs:sequence>
<xs:element ref="interior"/>
<xs:element ref="exterior"/>
<xs:element ref="mechanical"/>
</xs:sequence>
<xs:attribute name="make" use="required" type="xs:string"/>
<xs:attribute name="model" use="required" type="xs:string"/>
<xs:attribute name="year" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>

Then, you will not have to prefix the attributes in the instance
document, and it will validate.

Hope that helps!
Priscilla
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top