问题描述
我目前有两个XSD方案,一个是另一个的轻型版本。现在我在完整模式中重复了轻版本中的所有内容,但是当我需要进行更改时这会变得很痛苦,并且它反对DRY原则,所以我想知道是否有元素这有助于将另一个模式包含在模式中,因此我可以从轻量级模式继承完全以减少维护障碍。
I currently have two XSD schemes and one is a "light" version of the other. Right now I have everything in the "light" version repeated in the "complete" schema, but this becomes a pain when I need to make a change, and it goes against the DRY principle anyways, so I was wondering if there was an element that served to include another schema into a schema, so I can have my "complete" inherit from the "light" schema to reduce maintenance hurdles.
推荐答案
有两种方法。
< xsd:include schemaLocation =pathToFile/>
应该用于包含相同名称空间的文件。
<xsd:include schemaLocation="pathToFile" />
should be used for including files of the same namespace.
< xsd:import namespace =namespaceschemaLocation =pathToFile />
应该用于不同命名空间中的包含文件。通常,您将指定作为导入模式的targetNamespace给出的命名空间。
<xsd:import namespace="namespace" schemaLocation="pathToFile" />
should be used for include files in a different namespace. Usually you will specify the namespace given as the targetNamespace of the imported schema.
这篇关于我可以让一个XML Schema(XSD)包含另一个XML-Schema吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!