RE: [xml] XSchema and libxml


-----Original Message-----
From: Hei Chan [mailto:structurechart yahoo com] 

Hi Kasimier,
I have a question about your really old post:

I have tried your example with libxml 2.6.23.  It
gives me:

test.xml:6: element note: Schemas validity error :
Element '{}note': No matching
global declaration available for the validation root.
The document 'test.xml' is not valid.

I get the following with your scenario:

xmllint --noout --schema http://localhost:8080/text.xsd test.xml
test.xml validates

Here is the XML:
<?xml version="1.0"?>


<body>Don't forget me this weekend!</body>

Here is the XSD:
<?xml version="1.0"?>
<xs:schema xmlns:xs="";

<xs:element name="note">
        <xs:element name="to" type="xs:string"/>
        <xs:element name="from" type="xs:string"/>
        <xs:element name="heading" type="xs:string"/>
        <xs:element name="body" type="xs:string"/>


If I do the following:
pCtxt =
schema = xmlSchemaParse(pCtxt);
ctxt = xmlSchemaNewValidCtxt(scheam);
ret = xmlSchemaValidateDoc(ctxt, doc);
, then it works.

Is there something wrong with my XML or XSD?  Or is
the feature(looking up XSD via xsi) turned off?

Right, with xmllint the XSI information is not processed
automatically; you need to specify explicitely both, the
schema and the instance. Actually this is a long-standing
enhancement request, and I currently could also use such a
mechanism in order to plug in Libxml2's XML Schema facility
into my favourite XML editor.

Daniel, would it be OK to add such an option to xmllint?

Relevant bugzilla-entries:

In addition to that, is there a way to validate a XML
against the corresponding schema(specified in the XML)
automatcially regardless the type of the schema(e.g.
DTD, XSD, RelaxNG or whatever)?

I don't think so. But you can try to write one.



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