[xml] Validating one element - xmlSchemaValidateOneElement

Hi there,

I'm having a lot of trouble validating single elements in the tree (vs validating the whole document) with a schema (I'm using libxml2.6.19.).

Using a simple schema and xml document and trying to validate "Tove", I got this error: note2.xml:7:element to: Schemas validity error : Element 'to': No matching global declaration available.

Here's the code snippet:
if ((!xmlStrcmp(xmlNodeGetContent(cur), (const xmlChar *)keyword)))
   elemValid = xmlSchemaValidateOneElement(schemaValidCtxtPtr, cur);

<?xml version="1.0"?><note
xsi:schemaLocation="http://www.w3schools.com note.xsd">

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

<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.w3schools.com"; elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.w3schools.com";>
        <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"/>

And does libxml2 currently validate elements with xs:restriction, xs:minInclusive, etc?

Thanks a lot!

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