I have this in my xsd:
<xs:element name="Parameter" type="complex">
and I want to define complex like:
<xs:simpleType name="complex">
1 xs:decimal
开发者_高级运维 2 xs:string
</xs:simpleType>
So if the value for Parameter is decimal to take decimal and if value is not decimal to assume that value is string. How to declare my complex type?
You'll need a complexType
together with a choice to express this:
<xs:complexType name="complex">
<xs:choice>
<xs:element name="number" type="xs:decimal"/>
<xs:element name="string" type="xs:string"/>
</xs:choice>
</xs:complexType>
Edit: Based on your comments maybe this is worth a try:
<xs:simpleType name="monat">
<xs:union memberTypes="xs:decimal xs:string"/>
</xs:simpleType>
But JAXB will translate this to String
anyway, so there's no benefit from the union, at least with respect to the generated classes. And that you are using JAXB is just a guess.
精彩评论