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

Comments in XML will cause native DOM parser to fail #189

Closed
StefanOltmann opened this issue Dec 12, 2023 · 2 comments
Closed

Comments in XML will cause native DOM parser to fail #189

StefanOltmann opened this issue Dec 12, 2023 · 2 comments
Labels
bug Something isn't working indev The issue is fixed/implemented in the dev branch

Comments

@StefanOltmann
Copy link

I'm working on an improvement for https://github.com/Ashampoo/xmpcore where I want it to be more resilient about real-world malformed XMP in some of the Unsplash test images I use to test Ashampoo Photos.

This file can be read on Java, but it fails on the iOS target:
sample_50.xmp.txt

Here is the code used to read the file:
https://github.com/Ashampoo/xmpcore/blob/2815304b1a802c37ec4ac2e9fcd16de242680dec/src/commonMain/kotlin/com/ashampoo/xmp/DomParser.kt#L11

The error says Attempting to add node 8 where not permitted.

The problem with the file is that some fields are repeated. My new code now ignores repeated fields and always takes the first. That may be better than not reading the XMP at all.

Can I somehow configure the parser to skip/ignore such errors, so that I can handle/correct them in the steps after that?

@StefanOltmann
Copy link
Author

I identified the primary issue to be related to the comment in the sample file. The comment was added by me for documentation purposes and was not part of the original file.

Fortunately, this issue is not significant. I believe your implementation could simply skip comment blocks instead of encountering a failure, which should resolve the issue satisfactorily.

@StefanOltmann StefanOltmann changed the title Problem on reading in malformed XML on iOS Comments in XML will cause native DOM parser to fail Dec 13, 2023
@pdvrieze pdvrieze added bug Something isn't working indev The issue is fixed/implemented in the dev branch labels Dec 13, 2023
@pdvrieze
Copy link
Owner

I've found the problem. I've made the platform independent document implementation allow comments outside the document element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working indev The issue is fixed/implemented in the dev branch
Projects
None yet
Development

No branches or pull requests

2 participants