"Re: [xml] Schema validation from API"



Hi,

on 4/26/2004 12:37 PM Garcia Jose Miguel-JGARCIR1 wrote:
Hi all,

I´m trying to validate a XML file by schema.xsd

With xmllint, everything is Ok,

xmllint --noout --schema test.xsd test.xml

test.xml validates

How should I make this validation through API ?


reader = xmlReaderForFile(test.xsd , NULL, NULL);

schema_parse = xmlSchemaNewParserCtxt("test.xsd");

schema = xmlSchemaParse(schema_parse);

schema_valid = xmlSchemaNewValidCtxt(schema);

doc = xmlTextReaderCurrentDoc(reader);

res_val = xmlSchemaValidateDoc (schema_valid, doc); //int xmlSchemaValidateDoc  (xmlSchemaValidCtxtPtr 
ctxt, xmlDocPtr doc)

I guess the problem is the "xmlReaderForFile" function; it's intention 
is to work as a pull parser [1]; AFAIK it does not produce a xmlDoc, so 
calling "xmlTextReaderCurrentDoc" returns NULL.

You may try the "xmlReadFile" function to parse your XML document instead.

[1] http://www.xmlsoft.org/xmlreader.html


Greetings,

Kasimier




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