[xml] calling xmlXIncludeProcess after xmlParseFile generates error
- From: "Christopher J. Grayce" <cgrayce aleks com>
- To: xml gnome org
- Subject: [xml] calling xmlXIncludeProcess after xmlParseFile generates error
- Date: Tue, 30 Dec 2003 16:40:30 -0800
Dear All,
I would appreciate any enlightment on why this program works as expected...
--------------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <libxml/parser.h>
#include <libxml/xinclude.h>
int main(int argc, char *argv[]) {
char *path = argv[1] ;
xmlDoc *doc ;
xmlParserOption options = XML_PARSE_XINCLUDE ;
doc = xmlReadFile(path,NULL,options) ;
xmlXIncludeProcess(doc) ;
xmlDocFormatDump(stdout,doc,1) ;
return(0) ;
}
--------------------------------------------------------------------------------
...but THIS program generates a segmentation violation:
--------------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <libxml/parser.h>
#include <libxml/xinclude.h>
int main(int argc, char *argv[]) {
char *path = argv[1] ;
xmlDoc *doc ;
doc = xmlParseFile(path) ;
xmlXIncludeProcess(doc) ;
xmlDocFormatDump(stdout,doc,1) ;
return(0) ;
}
--------------------------------------------------------------------------------
Here is the stack trace after the SIGSEGV:
--------------------------------------------------------------------------------
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1075296320 (LWP 4680)]
0x4010b71b in xmlDictOwns (dict=0x805be20, str=0x805b828 "what's up, Doc?")
at dict.c:616
616 if ((str >= pool->array) && (str <= pool->free))
(gdb) where
#0 0x4010b71b in xmlDictOwns (dict=0x805be20, str=0x805b828 "what's up, Doc?")
at dict.c:616
#1 0x400763f7 in xmlFreeNodeList (cur=0x805bc88) at tree.c:3294
#2 0x40076379 in xmlFreeNodeList (cur=0x805bc28) at tree.c:3284
#3 0x40072fcb in xmlFreeDoc (cur=0x805bb28) at tree.c:1115
#4 0x400c2832 in xmlXIncludeLoadDoc (ctxt=0x805c0b8, url=0x804a7b8 "foo.xml",
nr=0) at xinclude.c:1582
#5 0x400c30dc in xmlXIncludeLoadNode (ctxt=0x805c0b8, nr=0) at xinclude.c:1867
#6 0x400c39d3 in xmlXIncludeDoProcess (ctxt=0x805c0b8, doc=0x805bd78,
tree=0x805bf88) at xinclude.c:2140
#7 0x400c3af3 in xmlXIncludeProcessFlags (doc=0x805bd78, flags=0)
at xinclude.c:2200
#8 0x400c3b4b in xmlXIncludeProcess (doc=0x805bd78) at xinclude.c:2219
#9 0x08048526 in main (argc=2, argv=0xbfffdbe4) at curious.c:21
#10 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
--------------------------------------------------------------------------------
Here is the XML file with the XInclude instruction:
--------------------------------------------------------------------------------
<?xml version="1.0"?>
<element xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="foo.xml" />
</element>
--------------------------------------------------------------------------------
And here are the contents of "foo.xml" (to be included):
--------------------------------------------------------------------------------
<?xml version="1.0"?>
<element>what's up, Doc?</element>
--------------------------------------------------------------------------------
Clearly I am missing something about when xmlParseFile versus
xmlReadFile should be used.
I also wonder what the purpose of the third (options) argument to
xmlReadFile is. Setting it to XML_PARSE_INCLUDE doesn't cause XInclude
processing to occur immediately after parsing, as I would have thought it
would. . .
The version of libxml2 is 2.6.4, compiled from source (with no errors)
under RedHat 9.0.
Thanks in advance,
CJG
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]