The following comment has been added to this issue:
Author: Hans Gilde
Created: Tue, 24 Aug 2004 6:13 AM
Body:
Ok, more info here:
First, in my previous post, replace "src/dom4jtest/a.xml" with "entity.xml", the XML
file that's in the unit test.
Second, it seems that we have two distinch issues here:
1) The unit test that fails, which is related to the string() XSLT function.
2) The original post, which does, in fact print bad output. I think that the problem
is with XML CopyOfTag line 52 "...new SAXWriter(output, output)". It's using the
output as both a ContentHandler and a LexicalHandler. The &x; is being output in the
startEntity method of LexicalHandler. The SAX description for this method says
"General entities are reported with their regular names". So, I think that we want
only the ContentHandler, which would change line 52 to "...new SAXWriter(output)".
Here's the Java source that replicates the problem:
public class TestDom4jEntity extends TestCase {
public void testDom4JEntityParsing() throws Exception {
SAXReader xmlReader = new SAXReader(true);
Document doc = xmlReader.read("src/dom4jtest/a.xml");
Object obj = doc.selectObject("string(/a)");
System.out.println("Bad: " + obj);
XMLWriter writer = new XMLWriter(System.out);
//broken
SAXWriter saxWriter = new SAXWriter(writer, writer);
//fixed
//SAXWriter saxWriter = new SAXWriter(writer);
List nodes = doc.selectNodes("/a");
for (Iterator iter = nodes.iterator(); iter.hasNext();) {
Object object = iter.next();
if (object instanceof Node) {
saxWriter.write((Node)object);
} else if (object != null) {
System.out.println(object.toString());
}
}
}
}
---------------------------------------------------------------------
View this comment:
http://issues.apache.org/jira/browse/JELLY-28?page=comments#action_37428
---------------------------------------------------------------------
View the issue:
http://issues.apache.org/jira/browse/JELLY-28
Here is an overview of the issue:
---------------------------------------------------------------------
Key: JELLY-28
Summary: Bad entity processing
Type: Bug
Status: Open
Priority: Blocker
Project: jelly
Components:
core / taglib.core
Fix Fors:
1.0-beta-4
Assignee: james strachan
Reporter: Incze Lajos
Created: Thu, 30 Jan 2003 7:44 PM
Updated: Tue, 24 Aug 2004 6:13 AM
Environment: No special environment.
Description:
Have a file, name it a.xml with this content:
-----------------------------
<?xml version="1.0"?>
<!DOCTYPE a [
<!ENTITY x "y">
]>
<a>&x;</a>
-----------------------------
Run the below simple (maven) jelly script:
-----------------------------
<project default="java:jar"
xmlns:j="jelly:core"
xmlns:x="jelly:xml">
<goal name="emnl:test">
<x:parse var="doc" xml="a.xml"/>
<echo><x:copyOf select="$doc"/></echo>
</goal>
</project>
-----------------------------
The result will be this:
-----------------------------
....
emnl:test:
[echo] <?xml version="1.0" encoding="UTF-8"?>
<a>&x;y</a>
BUILD SUCCESSFUL
-----------------------------
I'm aware of the fact that the bug originally comes from dom4j.
The below dom4j program fragment
-----------------------------
....
SAXReader xmlReader = new SAXReader();
Document doc = xmlReader.read("a.xml");
XMLWriter writer = new XMLWriter(System.out);
writer.write(doc);
writer.flush();
....
-----------------------------
will output this result:
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE a><a>&x;</a>
-----------------------------
which is bad (not even well-formed). I've filed this issue
at the dom4j bugtracker
(http://sourceforge.net/tracker/?group_id=16035&atid=116035)
under the number 676427, with some notes one the possible
resolution.
But as we can see, the jelly xml tag adds a twist to the dom4j bug,
it inserts both the entity and the entity value into the tag.
Thanks, incze
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]