It seems it is SAX parser problem. I tested it with JDK 1.6 (
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl) and it printed eights
in test7 attribute. But it gots this attribute value from SAX parser. You
can test this:

public class Test {
private static class Handler extends DefaultHandler {

@Override
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
super.startElement(uri, localName, name, attributes);
System.out.println(MessageFormat.format("element: ",localName));
for (int i = 0; i < attributes.getLength(); i++) {
System.out.println (MessageFormat.format("{0}={1}", attributes.getLocalName(i),
attributes.getValue(i)));
}
System.out.println("");
}
}

public static String xmlString = "<?xml version=\" 1.0\"
encoding=\"UTF-8\"?><Test test1=\"11111 &lt;\" test2=\"22222 &lt;\"
test3=\"33333 &lt;\" test4=\"44444 &lt;\" test5=\"55555 &lt;\" test6=\"66666
&lt;\" test7=\"77777 &lt;\" test8=\"88888 &lt;\" test9=\"99999 &lt;\"
test10=\"101010101010 &lt;\" />";

public static void main(String[] args) throws Exception {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new InputSource(new StringReader(xmlString)),
new Handler());
}
}

Inspect your XML once more, if there is not problem with quotation or
something else – but I think document is OK. If it is correct, report this
bug to Sun – it seems it is bug of their platform's SAX parser.

Filip Jirsák


2007/10/9, David Frankson <[EMAIL PROTECTED]>:
>
> After some odd data corruption errors in my app, I tracked it down to
> dom4j and managed to simplify the error to a short reproducable (with
> 1.6.1) case.  After enough attributes that include a &gt; or &lt;,
> dom4j starts to mess up and duplicate parts of the data from one
> attribute into the value of another.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Test test1="11111 &lt;" test2="22222 &lt;" test3="33333 &lt;"
> test4="44444 &lt;" test5="55555 &lt;" test6="66666 &lt;" test7="77777
> &lt;" test8="88888 &lt;" test9="99999 &lt;" test10="101010101010 &lt;"
> />
>
>
> becomes:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Test test1="11111 &lt;" test2="22222 &lt;" test3="33333 &lt;"
> test4="44444 &lt;" test5="55555 &lt;" test6="66666 &lt;" test7="88888
> &lt;" test8="88888 &lt;" test9="1010101" test10="101010101010 &lt;"/>
>
>
> when passed through dom4j.  Notice test7 and test 9 are corrupted with
> some of the value from test8 and test10 respectively.  I've never dug
> into the dom4j code before, could someone give me a tip on where to
> look to troubleshout this very weird and destructive error?
>
>
>
>
>
>
> Test program:
>
> import org.dom4j.*;
>
> public class ParseTest
> {
>        public static String xmlString = "<?xml version=\"1.0\"
> encoding=\"UTF-8\"?><Test test1=\"11111 &lt;\" test2=\"22222 &lt;\"
> test3=\"33333 &lt;\" test4=\"44444 &lt;\" test5=\"55555 &lt;\"
> test6=\"66666 &lt;\" test7=\"77777 &lt;\" test8=\"88888 &lt;\"
> test9=\"99999 &lt;\" test10=\"101010101010 &lt;\" />";
>
>        public static void main(String[] args) throws Exception
>        {
>                System.out.println(xmlString);
>                Document xml = DocumentHelper.parseText(xmlString);
>                System.out.println(xml.asXML());
>        }
> }
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> dom4j-dev mailing list
> dom4j-dev@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-dev
>



-- 
Filip Jirsák
[EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to