Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifying generated XPath when there is only a single sibiling #2

Closed
wants to merge 1 commit into from
Closed

Conversation

butlermh
Copy link

Hi Lukas,

Thanks for this great library.

I am using jOOX with HTML having heard about it here
http://stackoverflow.com/questions/4746299/generate-get-xpath-from-xml-node-java

When jOOX generates an XPath, it will add [1] even if there is only a single element. For example for a HTML document the generated XPath will start /html[1]/body[1] even though we only expect one html and one body element. This is mainly a problem for human readability.

I have modified the code to add a check to omit the sibling specifier if there is only a single sibling, and I have updated the unit tests accordingly.

What do you think?

… for a HTML document it will start /html[1]/body[1] even though conventionally we only expect one html and one body element. Adding a check to omit the sibiling specifier if there is only a single sibling, and updating the unit tests accordingly
@lukaseder
Copy link
Member

Thanks for the pull request and feedback. I cannot merge this pull request in its current state, as it will break existing functionality.

But I agree that such a distinction might be useful to some users. I will implement a more reusable #122 instead

@lukaseder lukaseder closed this Jun 21, 2013
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