|
[
Permlink
| « Hide
]
Morgan Delagrange added a comment - 09/Sep/03 05:49 PM
This seems like an extremely critical bug.
Allow me to mention that is so severe that Maven currently prefers to stay
with dom4j-1.4-beta-8 instead of dom4-1.4 release. The bug isdefinitely floating somehwere around dom4j and we would like to have some help of persons that are dom4j-aware. thanks. There is a test case in jelly-tags/xml/test/org/apache/commons/jelly/tags/xml/suite.jelly
The test case reports <test:assertEquals> expected:[y] but was:[&x;].
At least it isn't &x;y. Given that this is basically a dom4j problem... is it really a blocker for Jelly 1.0b4? For me it's not a blocker, but a known beta issue.
Hi,
I couldn't replicate this issue with dom4j. If I parse this xml above and print it out, it seems ok to me: String xml = "<!DOCTYPE a [\n" + this gives the following output: could someone give me some hints about how to create a dom4j junit test that illustrates this problem? thanks, Did you try the original DOM4J code above?
e.g. SAXReader xmlReader = new SAXReader(); Trying the original dom4j code gives as output:
<?xml version="1.0" encoding="UTF-8"?> seems ok to me The problem seems to be in the string() XPath function. I don't know if it's a problem with the way it's used or with dom4j.
Here's the code that replicates what we're doing in Jelly: SAXReader xmlReader = new SAXReader(true); This prints "&x;" .... and maybe it's supposed to, I couldn't find a good definition of string() applied to a node set in my XPath book. FYI to Jelly people, the condition that initially opened this TR isn't broken any more. Outputting that code works fine. 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 { Object obj = doc.selectObject("string(/a)"); XMLWriter writer = new XMLWriter(System.out); We need the lexical handler to allow us access to stuff like
select="$doc/foo/comment()" So, when you transform your XML document, it's supposed to strip out the original comments. If you want comments in your output, you have to put them in CDATA in the original.
How about this: By default, CopyOf won't output lexical data. If you want to access the comments in this mode, you have to use "string($doc/a/comment())" We add in an attribute "lexical" that will cause CopyOf to output lexical information along with the content. In this mode, you should expect the "double entity" issue and any other issue related to outputting lexical data. It's a little inconvenient for the user but the underlying SAX/dom4j classes work this way. I'll submit the patch tomorrow unless you hate it. This sounds doable.
So, by default, the select=".../comment()" wont work unless lexical is set to true, if I'm reading it right. Patches to XML CopyTag and CopyOfTag to add the "lexical" attribute. The CopyOfTag patch also replaces the depricated dom4j selectObject function with evaluate. Also a patch to XML test suite.jelly to test the changes.
select=".../comment()" won't work when lexical="false". Specifically, the select will return the comments to the tag but they won't be output.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||