Sandy (et al),

I've been out of touch with XML for a couple years (remember back when there
were no schemas and namespaces?).

Basically, you're saying that the schema against which the XML instance is
validated and the namespace in which that instance exists are independent
unless you specify a targetNamespace in the schema, in which case the
instance must use that namespace. Right?

BTW: Is it just me or does anyone else find it odd that XML schema is used
to validate existing XML "instances" (a.k.a. documents) and everywhere else
on the planet schema is used to create instances? (although I suppose an
argument could be made that an SQL UPDATE statement is validated against the
database schema before it is executed.)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 04, 2001 2:00 PM
To: [EMAIL PROTECTED]
Subject: Re: More validating schema problems...



Hi Pete,

In your schema file, you specified a targetNamespace, so in your instance
document, you should tell the parser that your element is from that
namespace. Change your instance document to the following should solve the
problem:

<?xml version="1.0"?>
<test xmlns="http://localhost";
      xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
      xsi:schemaLocation="http://localhost test.xsd">
</test>

Cheers,
Sandy Gao
Software Developer, IBM Canada
(1-416) 448-3255
[EMAIL PROTECTED]



 

                    [EMAIL PROTECTED]

                    .com                 To:
[EMAIL PROTECTED]                                      
                                         cc:

                    04/04/2001           Subject:     More validating schema
problems...                           
                    02:26 PM

                    Please respond

                    to

                    xerces-j-user

 

 





Hello all,

I was looking through the recent schema validating posts, but didn't see a
complete resolution to the issues, or at least a resolution to the issue
that I am running into. This issue is with an error generated by the parser
when validating a schema: "Element type "test" must be declared."

I thought what I thought were valid xsd/xml documents and am calling the
parser correctly. I then took almost everything out of the files, and was
still getting the error.. Obviously I'm doing something wrong... I was
hopeing that someone would spot my mistakes. Also, I've been scouring the
schema tutorial at xml.com, which seems to be the best schema reference I
could find. I also downloaded a schema tutorial, and from what I can tell,
I'm doing what they say... I think I've got a reasonable handle on schemas,
except for this little problem... I'm guessing the problem is in the header
somewhere, as the parser does read from the schema file. I can't find a
good document on all the information that should/needs-to be put in the
header, anyone know of one?

I call the parser with:  jre -classpath %xerces_CLASSPATH% sax.SAXCount -s
-v test.xml
My xml and xsd files look like:

<?xml version="1.0"?>
<test
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance";
        xsi:schemaLocation="http://localhost test.xsd">
</test>

-------------------------------

<?xml version="1.0"?>
<xsd:schema
        xmlns:xsd="http://www.w3.org/2000/10/XMLSchema";
        targetNamespace="http://localhost";
        xmlns="http://localhost";
        elementFormDefault="qualified"
        attributeFormDefault="unqualified">

<xsd:element name="test" />

</xsd:schema>

Thanks for any help!
-Pete




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to