Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with complex XSD data type

Status
Not open for further replies.

dlamet

Programmer
Apr 10, 2009
7
US
I have inherited a data type that's a simple token enumeration:

<xsd:simpleType name="OFF_SEVERITY_TYPE">
<xsd:annotation>
<xsd:documentation>Offense Severity</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="F">
<xsd:annotation>
<xsd:documentation>Felony</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="M">
<xsd:annotation>
<xsd:documentation>Misdemeanor</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="I">
<xsd:annotation>
<xsd:documentation>Infraction</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="V">
<xsd:annotation>
<xsd:documentation>Violation</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

I now need to attach this same enum to a statute as "possible severities that a statute can have". So where the offense can only have one of the tokens, statute must be able to have multiples. Anybody know how I can specify that in an XSD? I looked at <xsd:group>, but I couldn't see a way to use it.

Thanks, Dan
 
[tt]<xsd:simpleType name="statuteType">
<xsd:restriction>
<xsd:simpleType>
<xsd:list itemType="OFF_SEVERITY_TYPE" />
</xsd:simpleType>
</xsd:restriction>
</xsd:simpleType>[/tt]
 
tsuji, thanks for the reply.

Looks like this would allow a list of OFF_SEVERITY_TYPE, but would it restrict the list to have only one instance of each value of OFF_SEVERITY_TYPE?

Thanks again, Dan
 
List type has a couple of facets you can play with. If uniqueness is the only need, use the above statuteType as abstract type (or rename it) and further restrict it using the facets. To emulate uniqueness, you may use enumeration facet again. For small number of base type enumeration, it may be a good option. For big number of enumeration admissible set, maybe you could then use pattern facet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top