[jdom-interest] Pb with mixed content (in b4)
Vincent Aumont
vincent.aumont at vslab.com
Thu Jun 29 13:01:50 PDT 2000
If an element has mixed content *and* the last component is a string,
hasMixedContent always return 'false'. If the last component is
an element, it works as expected.
Consider the following example:
import java.io.*;
import org.jdom.*;
import org.jdom.input.*;
public class TestMixedContent {
public static void main(String[] args)
{
try {
String mixedContent1 = "<root>a string<element>the
element</element></root>";
String mixedContent2 = "<root>a string<element>the
element</element>another string</root>";
SAXBuilder builder = new
SAXBuilder("org.apache.xerces.parsers.SAXParser");
Document doc1 = builder.build(new
ByteArrayInputStream(mixedContent1.getBytes()));
if (doc1.getRootElement().hasMixedContent())
System.out.println("doc 1 has mixed content");
Document doc2 = builder.build(new
ByteArrayInputStream(mixedContent2.getBytes()));
if (doc2.getRootElement().hasMixedContent())
System.out.println("doc 2 has mixed content");
}
catch (Exception e) {e.printStackTrace();}
}
}
it produces:
doc 1 has mixed content
More information about the jdom-interest
mailing list