Skip to content

CommentXobj shouldn't have child nodes#29

Open
macbarSB wants to merge 2 commits intoapache:trunkfrom
macbarSB:commentxobj-child-nodes-fix
Open

CommentXobj shouldn't have child nodes#29
macbarSB wants to merge 2 commits intoapache:trunkfrom
macbarSB:commentxobj-child-nodes-fix

Conversation

@macbarSB
Copy link

Hello

Current version has an issue, when xml contains comment followed by a whitespace character. This leads to situation, when after first iteration of xpath selection the hasChildNodes() method returns true for CommentXobj instance. With that next usages of selectPath(...) return incorrect result.

Please see code below for reproduction:

        XmlObject xmlObject = XmlObject.Factory.parse("<outerTag><!-- comment with whitespace after it --> <innerTag>textToFind1</innerTag><innerTag>textToFind2</innerTag></outerTag>");
        String xpath = "//innerTag";

        System.out.println(Arrays.stream(xmlObject.selectPath(xpath)).toList().size()); // prints 2
        System.out.println(Arrays.stream(xmlObject.selectPath(xpath)).toList().size()); // prints 0

@pjfanning
Copy link
Member

pjfanning commented Feb 11, 2026

This is a 20 year old project with no major development ongoing.
Changes like this are too risky and no test coverage is a no-no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants