Skip to content

Element.getContentSize() gives different result with CDATA between v1.1 and v2.0.6 #173

Closed
@oberstnova

Description

@oberstnova

Hello,

just finally migrated from jdom 1.1 to jdom 2.0.6.
However I have an example where org.jdom2.Element.getContentSize() returns another result than the Version 1.1 counterpart did, which breaks some dependent code.

Example:

Document doc = null;
try {
    File f = new File("C:\\...\\RPTXXMLTEST.xml");
    // In Version 1.1 this was new SAXBuilder(false)
    doc = new SAXBuilder( XMLReaders.NONVALIDATING ).build( f );
    Element rootElement = doc.getRootElement();
    System.out.println("Content Size is " + rootElement.getContentSize());
} catch( Exception e ) {
    e.printStackTrace();
}

Corresponding RPTXXMLTEST.xml is getting attached.
RPTXXMLTEST.zip
(Content as it's not much:)

<?xml version="1.0" encoding="UTF-8"?>
<beanparameter1><![CDATA[TEST]]></beanparameter1>

In Version 1.1 the Result was "Content Size is 1" - in 2.0.6 it's "Content Size is 2".
As it is a single element I would await a contentSize of "1".

Is the new behaviour expected and if yes, then why?

Thanks for your efforts.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions