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

Add location information to parsed objects and exceptions #95

Merged
merged 7 commits into from
Mar 10, 2024

Conversation

3breadt
Copy link
Owner

@3breadt 3breadt commented Feb 29, 2024

This addresses #90.

For XML property lists the XPath of the node containing the NSObject value is given. Line number information is not provided by the XML parser and would require using a different parser or writing a custom SAX event handler.

For ASCII property lists the line number, column number and absolute offset are given.

For binary property lists the object ID (found within the offset table at the end of the file) and the offset itself are provided.

@HiranChaudhuri
Copy link

Thank you for providing this change. It is definitely better than before (although I could not yet check the product in real life). :-)

To get good location information for XML documents I created a custom SAX handler that would assemble a DOM but also count line information. This data would then be added to the DOM nodes as user data (see https://docs.oracle.com/en/java/javase/17/docs/api/java.xml/org/w3c/dom/Node.html#setUserData(java.lang.String,java.lang.Object,org.w3c.dom.UserDataHandler). When transforming the DOM into an NSObject tree this information can be attached to the nodes again. Or use a SAX handler to create NSObjects directly. Worked marvellously in my setups parsing XML and giving row/column information.

Maybe a feature like 'userData' is anyway a better addon to NSObject than the 'parent' that I requested in the other PR.

@3breadt 3breadt merged commit 961358f into master Mar 10, 2024
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