Skip to content

Add jvm parser configuration #235

@e13mort

Description

@e13mort

Hello. I use your library in one of my projects and have faced with an interesting issue.

In my case I have files with DTD declaration with wrong Url. I don't manage these files so can't remove that declaration manually. So, that incorrect declaration leads to normal work at jvm(android), native and js targets. But, plain jvm (javax.xml) fails with a valid reason The markup declarations contained or pointed to by the document type declaration must be well-formed. In that particular case I'm allowed to ignore that check.

The problem there:

nl.adaptivity.xmlutil.StAXReader.Companion#safeInputFactory has the following code:

return XMLInputFactory.newFactory().apply {
          setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false)
     }

I can't pass any additional properties to that factory. In my case I need to set property javax.xml.stream.supportDTD to false (and it works via debugger).

I see few ways how it might be implemented:

  • create a high-level property somewhere in the nl.adaptivity.xmlutil.serialization.XmlConfig.Builder (I guess). It's gonna blow API a little but will be suitable for my case and kind of easy to implement.
  • Simply disable DTD check in the code above. It's gonna be a downgrade to jvm target but will make the whole library more consistent (as far as it's already not working on other platforms).
  • Add a feature to fully configure platform implementations. Looks like the right way in general but will require more work.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions