Re: [xml] Validating In Memory (How to get a ValidCtxtPointer?)
- From: Daniel Veillard <veillard redhat com>
- To: "Craig W. Wright" <craig wright cometsolutions com>
- Cc: xml gnome org
- Subject: Re: [xml] Validating In Memory (How to get a ValidCtxtPointer?)
- Date: Fri, 15 Feb 2002 15:21:40 -0500
On Thu, Feb 14, 2002 at 04:52:21PM +0700, Craig W. Wright wrote:
Hello,
I've searched up and down for a answer to this question and have come to
nothing so here it goes :)
I have the following C++ code:
Result XMLDocument::isValid(CmtString const& dtdFullPathName,
bool& isValid)
{
// get the dtd's name and parse the dtd.
xmlDtdPtr dtd = xmlParseDTD(NULL, BAD_CAST dtdFullPathName.getData());
isValid = false;
if ( dtd == NULL)
{
return Result(CMT_FAILURE);
}
// build a xmlValidCtxt Ptr
*************** This is the problem *****************
// docPtr is an xmlDocumentPtr
xmlValidCtxtPtr ctxt = xmlValidNewContext (data_->docPtr_);
*********************************************
// check validity.
if ( xmlValidateDtd(ctxt,data_->docPtr_,dtd))
{
isValid = true;
}
xmlFreeDtd(dtd);
*************** This is probably also a problem ***************
xmlValidFreeContext(ctxt);
**********************************************************
return Result(CMT_SUCCESS);
}
The main problem here is that I don't know how to get a hold of a proper
xmlValidContextPtr. I'm sure someone out there knows :)
the xmllint.c does this.
---------------
dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
if (dtd == NULL) {
xmlGenericError(xmlGenericErrorContext,
"Could not parse DTD %s\n", dtdvalid);
progresult = 2;
} else {
xmlValidCtxt cvp;
cvp.userData = (void *) stderr;
cvp.error = (xmlValidityErrorFunc) fprintf;
cvp.warning = (xmlValidityWarningFunc) fprintf;
if (!xmlValidateDtd(&cvp, doc, dtd)) {
xmlGenericError(xmlGenericErrorContext,
"Document %s does not validate against %s\n",
filename, dtdvalid);
}
xmlFreeDtd(dtd);
}
---------------
use the source !
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]