OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Transforming documents with undefined entities

The answer is in the XML Spec section 4.1:

 Well-formedness constraint: Entity Declared
 Note that non-validating processors are not obligated to read
 and process entity declarations occurring in parameter entities
 or in the external subset; for such documents

I note in your example that you don't have a
standalone declaration, and so the processor is
allowed to ignore the entity reference:

<!DOCTYPE chapter SYSTEM "external.dtd">

Changing your instance as follows:

<?xml version="1.0" standalone="yes"?>
<!DOCTYPE chapter SYSTEM "external.dtd">

... triggers an error.

I hope this helps.

. . . . . . Ken

At 2016-04-19 08:27 +0000, Andrew Campbell wrote:
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

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
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:
lineNumber: 4; columnNumber: 18; The entity
"badent" was referenced, but not declared.

$ java -cp
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.


Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training @US$45: http://goo.gl/Dd9qBK |
Crane Softwrights Ltd. _ _ _ _ _ _ http://www.CraneSoftwrights.com/x/ |
G Ken Holman _ _ _ _ _ _ _ _ _ _ mailto:gkholman@CraneSoftwrights.com |
Google+ blog _ _ _ _ _ http://plus.google.com/+GKenHolman-Crane/posts |
Legal business disclaimers: _ _ http://www.CraneSoftwrights.com/legal |

This email has been checked for viruses by Avast antivirus software.

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS