Hi everyone,
I’m experiencing something unexpected when transforming documents with undefined entities using Saxon. I asked on the Saxon mailing list, and Michael Kay suggested I tried asking here too.
I have two XML files, one with an internal DTD (badent-internal.xml), one with an external DTD (badent-external.xml).
Both of them reference an undefined entity (&badent;). When I parse either of them with xmllint, the undefined entity is
reported.
$ xmllint badent-internal.xml
badent-internal.xml:4: parser error : Entity 'badent' not defined
<chapter>&badent;</chapter>
^
When I try to transform them on the command line using Saxon, badent-internal.xml throws an error,
but badent-external.xml is transformed as if the entity reference were not present.
$ java -cp ~/Documents/XML/SaxonHE9-6-0-7J/saxon9he.jar net.sf.saxon.Transform -xsl:simple.xsl -s:badent-internal.xml
Error on line 4 column 18 of badent-internal.xml:
SXXP0003: Error reported by XML parser: The entity "badent" was referenced, but not declared.
org.xml.sax.SAXParseException; systemId: file:/Users/acam0006/Desktop/saxon.entity.test/missing.entity/badent-internal.xml; lineNumber: 4; columnNumber: 18; The entity "badent" was referenced, but not declared.
$ java -cp ~/Documents/XML/SaxonHE9-6-0-7J/saxon9he.jar net.sf.saxon.Transform -xsl:simple.xsl -s:badent-external.xml
<?xml version="1.0" encoding="UTF-8"?><success/>
I expected both files to throw the same error. What is going on?
I have attached the relevant files to this email.