开发者

How do I combine 4 similar XSDs into one?

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" /开发者_如何学JAVA>
            <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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜