[xml] How "subject to change" is xmlRelaxNGParse()'s interface...
- From: Sean Chittenden <sean chittenden org>
- To: libxml list <xml gnome org>
- Subject: [xml] How "subject to change" is xmlRelaxNGParse()'s interface...
- Date: Sun, 4 Jan 2004 17:11:10 -0800
The subject says it all. In relaxng.c, around line 7212 it says:
### BEGIN
/**
* xmlRelaxNGParse:
* @ctxt: a Relax-NG parser context
*
* parse a schema definition resource and build an internal
* XML Shema struture which can be used to validate instances.
* *WARNING* this interface is highly subject to change
*
* Returns the internal XML RelaxNG structure built from the resource or
* NULL in case of error
*/
xmlRelaxNGPtr
xmlRelaxNGParse(xmlRelaxNGParserCtxtPtr ctxt)
...
#### END
... So I'm curious as to how subject to change this method is, esp
given it's the only way to get an xmlRelaxNGPtr from an
xmlRelaxNGParserCtxtPtr. Are there any plans or would patches be
accepted to simplify the process of sucking in a RelaxNG file and
making it available as an xmlRelaxNGValidCtxtPtr? Seems like every
program that I have that uses a RelaxNG schema goes through the same
hoops to obtain a schema that I can validate an xmlDocPtr with. It'd
be slick if there was a function like:
xmlRelaxNGValidCtxtPtr
xmlRelaxNGReadFile(char *filename, char *encoding, int options) {
xmlRelaxNGValidCtxtPtr ret;
xmlRelaxNGParserCtxtPtr rngctxt;
xmlDocPtr doc;
doc = xmlReadFile(filename, encoding, options);
if (doc == NULL)
return(NULL)
rngctxt = xmlRelaxNGNewDocParserCtxt(doc);
if (rngctxt == NULL) {
xmlDocFree(doc);
return(NULL);
}
rng = xmlRelaxNGParse(rngctxt);
if (rng == NULL) {
xmlDocFree(doc);
xmlRelaxNGFreeParserCtxt(rngctxt);
return(NULL);
}
ret = xmlRelaxNGNewValidCtxt(rng);
if (ret == NULL) {
xmlDocFree(doc);
xmlRelaxNGFreeParserCtxt(rngctxt);
xmlRelaxNGFree(rng);
return(NULL);
}
return(ret);
}
Because then it lowers the coding overhead to just two function calls,
getting the xmlRelaxNGValidCtxtPtr and then calling
xmlRelaxNGValidateDoc(). Just a thought. -sc
--
Sean Chittenden
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]