How to read well formed XML in Java, but skip the schema?

后端 未结 5 1953
自闭症患者
自闭症患者 2020-11-30 10:21

I want to read an XML file that has a schema declaration in it.

And that\'s all I want to do, read it. I don\'t care if it\'s valid, but I want it to be well formed.

5条回答
  •  春和景丽
    2020-11-30 11:02

    The issue here isn't one of validation. Regardless of validation settings, the parser will still attempt to resolve any references in your document, such as entities, DTDs and (sometimes) schemas. It's only later on that it decides to validate using them (or not). You need to plug in an entity resolver to "intercept" these attempts at de-referencing.

    Check out Apache XML Resolver for an easy(ish) way to do this.

提交回复
热议问题