Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

CommentXobj shouldn't have child nodes#29

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

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

Conversation

@macbarSB
Copy link

@macbarSB macbarSB commented Feb 11, 2026

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

Copy link
Member

pjfanning commented Feb 11, 2026
edited
Loading

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /