Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a schema (a) that imports another schema (z). Then I have yet another schema (b) that imports that same schema (z).

It happens so that XML document (d) conforming to schema (a) can also contain an optional element that conforms to schema (z).

In consequence, when (d) is validated in .NET, I'm having exception "The simpleType 'z:x' has already been declared."

But there is no exception in Oxygen.

I'd like to configure .net the way it does NOT throw this exception. Just to behave like Oxygen.

How?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
284 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...