[xml] Validating one element - xmlSchemaValidateOneElement
- From: "Karen Y" <elaeni hotmail com>
- To: xml gnome org
- Subject: [xml] Validating one element - xmlSchemaValidateOneElement
- Date: Wed, 20 Apr 2005 19:57:40 -0700
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
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?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:complexType>
<xs:sequence>
<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"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And does libxml2 currently validate elements with xs:restriction,
xs:minInclusive, etc?
Thanks a lot!
Karen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]