Re: [xml] libxml2 does xmlSchemaValidateDoc() support xml schema extensions?



Hi Andy,

I am setting up the xml schema namespace the same way eclipse does when
you create a new XSD or XML file. I entered
*http://www.w3.org/2001/XMLSchema-instance*in the address bar of my
browsers and got quite a surprise!

The XML Namespace spec(1) states that the namespace URI need not be a
valid URL (i.e. point to a valid document on the network). In other
words, you are declaring your namespaces correctly.

http://www.w3.org/TR/xmlschema-1/#no-xsi is very confusing. 
If you look at section 3.2.7 (first table) at that location, you'll see
that using 'xsi:type' is perfectly fine.

where does libxml get the schema lang schema/dtd? As a test I put some
typos in my xsd file. libxml generated an error when I tried to validate
the xsd file as expected?
You don't have to worry about libxml retrieving resources at namespace
locations, that does not happen. Only the actual URI string matters (as
per (1)).

what URL should I be using?

Do I need to make a special call to cause the libxml to use this other
location?
Nope, you're using the right URIs, no network access is necessary.

Would you be willing to send my your sample C program? 
Sure thing (I should have done so in my original reply).

[] to compile:
$ gcc `xml2-config --cflags --libs` zoo.c -o zoo

[] sample run:
$ ./zoo zoo.xml ZooRequest.xsd
Attempting to validate zoo.xml with ZooRequest.xsd
Document in zoo.xml is valid

[] contents of zoo.xml:
$ cat zoo.xml
<?xml version="1.0" encoding="UTF-8"?>
<zoo:cageRequest xmlns:zoo="http://www.example.org/Zoo";
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
  <animal xsi:type="zoo:Fish">
    <name>Blue Fin Tuna</name>
    <numberOfFins>4</numberOfFins>
  </animal>
</zoo:cageRequest>

Hope you get things sorted out.

Piotr


(1) - http://www.w3.org/TR/REC-xml-names/#ns-decl

Attachment: zoo.c
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]