Is it an error to import the same XSD multiple times?

梦想与她 提交于 2019-11-28 02:22:26

The problem arises due to the XSD Recommendation allowing, but not requiring, conformant processors to ignore the import of an XSD from an already encountered namespace. .NET is re-importing, as it is allowed to do. Oxygen is ignoring re-imports, as it is allowed to do.

Both are operating in conformance to the XSD Recommendation. See the last note in 4.2.3 References to schema components across namespaces:

Note: The above is carefully worded so that multiple <import>ing of the same schema document will not constitute a violation of clause 2 of Schema Properties Correct (§3.15.6), but applications are allowed, indeed encouraged, to avoid <import>ing the same schema document more than once to forestall the necessity of establishing identity component by component. Given that the schemaLocation [attribute] is only a hint, it is open to applications to ignore all but the first <import> for a given namespace, regardless of the ·actual value· of schemaLocation, but such a strategy risks missing useful information when new schemaLocations are offered.

Fortunately, Oxygen is based on Xerces, which allows the user to control this behavior via

http://apache.org/xml/features/honour-all-schemaLocations

Unfortunately, the .NET XML/XSD processor is not based on Xerces, and I am unaware of any parallel configuration option in any .NET version. (I will happily update this answer if shown otherwise.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!