如何将 4 个相似的 XSD 合并为一个?
我想看看是否有一种方法可以根据枚举值加载/卸载其他元素。
我有以下元素类型:
<xs:element name="requestType" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="FUND" />
<xs:enumeration value="GENLDGR" />
<xs:enumeration value="SECDIST" />
<xs:enumeration value="TRAN" />
</xs:restriction>
</xs:simpleType>
</xs:element>
这来自我尝试合并的 4 个 XSD。它们都共享相同的元素,我可以通过继承引用这些元素,这没关系。然而,有些元素说,例如,FUND 可能需要,但 TRAN 不需要,但它们可能是 3 或 4 个顶部。
有没有一种方法可以根据“requestType”的 XML 值来利用我可以限制的其他元素并忽略我不需要的元素?
I'm trying to see if there's a way I can load/unload additional elements based on an enumeration value.
I have a element type of the following:
<xs:element name="requestType" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="FUND" />
<xs:enumeration value="GENLDGR" />
<xs:enumeration value="SECDIST" />
<xs:enumeration value="TRAN" />
</xs:restriction>
</xs:simpleType>
</xs:element>
This is coming from 4 XSDs that I'm trying to merge. They all share same elements which I can reference via inheritance, and that's OK. However, there are elements that say, for example, FUND might need but TRAN does not, but they are, maybe 3 or 4 tops.
Is there a way that based on what the XML values is for "requestType" that I can use that to leverage what other elements I can constrain on and ignore the ones I don't need?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可能正在寻找 XSD 1.1 中称为“条件类型分配”的功能,该功能允许元素的内容模型取决于其属性之一的值。这是 XSD 1.0 令人遗憾的无能之处。
XSD 1.1 功能目前在 Saxon 和 Xerces 中实现(仅据我所知)。
I think you are probably looking for the feature called "conditional type assignment" in XSD 1.1, which allows the content model for an element to depend on the value of one of its attributes. This is a much-lamented inability of XSD 1.0.
The XSD 1.1 feature is currently implemented in Saxon and Xerces (only, as far as I am aware).