Re: [xml] XML Catalog problem
- From: Chris Wareham <chris wareham pa press net>
- To: xml gnome org
- Subject: Re: [xml] XML Catalog problem
- Date: Mon, 13 Feb 2006 14:39:49 +0000
Daniel Veillard wrote:
On Mon, Feb 13, 2006 at 01:10:38PM +0000, Chris Wareham wrote:
if (xmlValidateDocument(&valid_ctxt, parser->doc) == 0) {
Very first thing is to not use xmlValidateDocument, it's a post
parsing validation mechanism, not the real one and for example won't
process the internal subset so won't work in this case. Use the real
validation as defined in the XML-1.0 spec i.e. as part of parsing.
Use xmlReadDoc with the XML_PARSE_DTDVALID like xmllint --valid
would do.
Daniel
Hi Daniel,
I amended my function to the following:
int
newsmlparser_set_xml(NewsMLParser *parser, const char *xml)
{
parser->doc = xmlReadFile(xml, "UTF-8", XML_PARSE_DTDVALID);
if (parser->doc == NULL) {
parser->status = NEWSMLPARSER_MALFORMED_XML;
return 1;
}
return 0;
}
This now appears to validate the NewsML file with embedded NITF:
Resolve: sysID http://www.customer.press.net/resources/nitf.dtd
0 Parsing catalog newsmlcatalog
newsmlcatalog added to file hash
Found system match http://www.customer.press.net/resources/nitf.dtd
Resolve: pubID urn:newsml:iptc.org:20001006:NewsMLv1.0.dtd:1 sysID
http://www.customer.press.net/resources/NewsMLv1.0.dtd
Found system match http://www.customer.press.net/resources/NewsMLv1.0.dtd
Before running my program, I disconnected my development machine from
the network as it has a version of libxml2 installed that includes HTTP
and FTP support. The NewsML file was validated, so my program must be
using the local DTD's referenced in the catalog.
If I deliberately break my NewsML file by adding an invalid element, I
get an error message on the console, but the xmlReadFile function still
returns a non-NULL xmlDocPtr. How should I test the validity of the XML
after a call to xmlReadFile?
Regards,
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]