[Expat-discuss] Parsing External Entities

Michael B. Allen miallen at eskimo.com
Thu Jan 16 02:27:45 EST 2003


On Wed, 15 Jan 2003 09:11:51 -0500
"Karl Waclawek" <karl at waclawek.net> wrote:

> > Now this may be my ignorace of XML but when I run this through my
> > dump program which just regurgitates XML the ExternalEntityRefHandler
> > runs OK and as you can see from the dialog below it completed parsing
> > the DOCTYPE definition however it is not resolving the internal entity
> > 'E'. If I remove 'SYSTEM "err.dtd"' the entity is resolved properly and
> > the program completes successfully. Why does this happen?
> > 
> >   <?xml version="1.0"?>
> >   <?DOCTYPE staff SYSTEM "err.dtd" [
> >      <!ENTITY E "This is a general entity">
> >      <!ELEMENT employeeId (#PCDATA)>
> >   ]><err>
> >   expatdump.c:270:parse: An XML parser error occured: line 6 col 15 off 40: undefined entity:
> >   eneral entity"> ]> <err> The entity is: &E; </err>
> >                                           ^
> >     expatdump.c:352:expatdump: 
> >     expatdump.c:380:main: Failure
> 
> This should work.
> You should provide more detail about how you are setting up
> and calling Expat. Reduce it to a short code example and post it.

Ok. Attached err.c with err.xml and err.dtd gives me:

[miallen at miallen3 tests]$ ./err.o err.xml 
DOCTYPE err [
ENTITY E
ELEMENT employeeId
]
Error parsing external entity: undefined entity
Failure
<err>

> 
> > 
> > Also, using the external entity XML_Parser created with
> > XML_ExternalEntityParserCreate my dump program segfaults if I attempt
> > to free it with XML_ParserFree. I suppose this parser is simply the same
> > parser in a different state and therefore I need not free it?
> 
> No, you must free it. Need more detail.
> Which version of Expat are you using?

1.95.2-2 RPM from RH 7.3

Also, to what extent do we free the XML_Content model in element
declaration handlers? Is that one chunk of memory? Otherwise if I try
to recursively free children I segfault.

Thanks for your help,
Mike

-- 
A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: err.c
Type: application/octet-stream
Size: 4625 bytes
Desc: not available
Url : http://mail.libexpat.org/pipermail/expat-discuss/attachments/20030116/f4102bba/err.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: err.xml
Type: text/xml
Size: 191 bytes
Desc: not available
Url : http://mail.libexpat.org/pipermail/expat-discuss/attachments/20030116/f4102bba/err.xml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: err.dtd
Type: application/octet-stream
Size: 45 bytes
Desc: not available
Url : http://mail.libexpat.org/pipermail/expat-discuss/attachments/20030116/f4102bba/err-0001.obj


More information about the Expat-discuss mailing list