arandomdan
Programmer
I'm trying to restrict the content of an element and its attributes. Here is the relevant portion of my schema where the problem is located:
<xs:element name="name">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="title" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Mr."/>
<xs:enumeration value="Mrs."/>
<xs:enumeration value="Ms."/>
<xs:enumeration value="Miss"/>
<xs:enumeration value="Dr."/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
This only partly accomplishes my goal. The attribute "title" is all set up the way I need it with the appropriate restrictions placed on it. The "name" element, on the other hand, is only restricted to being a string, but I also need to make sure that it's only composed of alphanumeric characters. This needs to be done while keeping the restrictions I have on the title attribute.
I have tried everything (that I could think of) and any restriction I try to put on the "name" element's content results in an invalid schema.
<xs:element name="name">
<xs:complexType mixed="true">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="title" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Mr."/>
<xs:enumeration value="Mrs."/>
<xs:enumeration value="Ms."/>
<xs:enumeration value="Miss"/>
<xs:enumeration value="Dr."/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
This only partly accomplishes my goal. The attribute "title" is all set up the way I need it with the appropriate restrictions placed on it. The "name" element, on the other hand, is only restricted to being a string, but I also need to make sure that it's only composed of alphanumeric characters. This needs to be done while keeping the restrictions I have on the title attribute.
I have tried everything (that I could think of) and any restriction I try to put on the "name" element's content results in an invalid schema.