-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.1, 1.2.0
-
generic
-
generic
Name: viR10068 Date: 04/30/2002
The 4.4 "XML Processor Treatment of Entities and References" of
XML 1.0 SE spec says that the ParameterEntity may be used in the
Entity Value and will be resolved as 'Included in literal' (see table).
But the parser failed to parse parameter entity in entity value
(both crimson in JDK 1.4.1 and xerces in JAXP 1.2 build b18).
See the log below for details:
% cat xml_ex.xml
<?xml version="1.0" ?>
<!DOCTYPE root [
<!ELEMENT root ANY>
<!ENTITY % text 'internal'>
<!ENTITY inEntity '%text;' >
]>
<root>data</root>
% cat xml_ex.java
import java.io.PrintStream;
import java.io.File;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import org.xml.sax.helpers.DefaultHandler;
public class xml_ex {
public static void main(String [] args) {
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser parser = spf.newSAXParser();
File xmlFile = new File(args[0]);
parser.parse(xmlFile, new DefaultHandler());
System.out.println("Passed.");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Failed.");
}
}
}
% javac xml_ex.java && java -showversion xml_ex xml_ex.xml
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, mixed mode)
org.xml.sax.SAXParseException: Only external parameter entities may use "%text;" in entity
values.
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3176)
at org.apache.crimson.parser.Parser2.parseLiteral(Parser2.java:763)
at org.apache.crimson.parser.Parser2.maybeEntityDecl(Parser2.java:2655)
at org.apache.crimson.parser.Parser2.maybeMarkupDecl(Parser2.java:1210)
at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1144)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:281)
at xml_ex.main(xml_ex.java:38)
Failed.
% echo $CLASSPATH && /export/ld25/java/dest/jdk1.3.1/solsparc/bin/java -showversion xml_ex
xml_ex.xml
/export/ld25/java/dest/JAXP/jaxp-1.2.0-fcs-b18-24_apr_2002/xalan.jar:.:/export/ld25/java/d
est/JAXP/jaxp-1.2.0-fcs-b18-24_apr_2002/jaxp-api.jar:/export/ld25/java/dest/JAXP/jaxp-1.2.
0-fcs-b18-24_apr_2002/xercesImpl.jar:/export/ld25/java/dest/JAXP/jaxp-1.2.0-fcs-b18-24_apr
_2002/sax.jar:
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
org.xml.sax.SAXParseException: The parameter entity reference "%text;" cannot occur within
markup in the internal subset of the DTD.
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1162)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at xml_ex.main(xml_ex.java:36)
Failed.
%
======================================================================