The problem is requesting the following. That the phone should have the attribute type with 3 enumerated values of home, cell, and work. AND the phone should also be restricted to a phone format of (###) ###-####. How do you combine the attribute for enumerated vales AND apply a restricted pattern? XML example:
<donor level="founder">
<name>David Brennan</name>
<address>5133 Oak Street
Windermere, FL 34786</address>
<phone type="home">(407) 555-8981</phone>
<phone type="cell">(407) 555-8189</phone>
<email>dbrennan@delisp.net</email>
<donation>50000.00</donation>
<method>Phone</method>
<effectiveDate>1982-09-01</effectiveDate>
</donor>
xsd code I have so far for phone:
<xs:attribute name="type" type="pType" />
<xs:simpleType name="phoneType">
<xs:restriction base="xs:string">
<xs:pattern value="\(\d{3}\)\s\d{3}-\d{4}" />
</xs:restriction>
</xs:simpleType>
<xs:element name="phone">
<xs:complexType>
<xs:simpleContent>
<xs:extension base ="xs:string">
<xs:attribute ref="type" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="pType">
<xs:restriction base="xs:string">
<xs:enumeration value="home" />
<xs:enumeration value="cell" />
<xs:enumeration value="work" />
</xs:restriction>
</xs:simpleType>
<xs:element name="donor">
<xs:complexType>
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="address"/>
<xs:element ref="phone" minOccurs="1" maxOccurs="unbounded"/>
<xs:element ref="email" minOccurs="0" />
<xs:element ref="donation" />
<xs:element ref="method" />
<xs:element ref="effectiveDate" />
</xs:sequence>
<xs:attribute ref="level" />
</xs:complexType>
</xs:element>
</xs:schema>
Aucun commentaire:
Enregistrer un commentaire