S
Sandie C
please help a newbie I am so confused by trying to declare a user type, and
then incorporate it into an element that uses the derived type and has an
attribute.
I have included my schema and xml file below. I am using xml spy and the
message I get is Phone must be valid with respect to definition '{no name}'.
Thanks for any help at all.
Sandie
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="LType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="home"/>
<xsd:enumeration value="business"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="PType">
<xsd:restriction base="xsd:string">
<xsd
attern value="[1-9] {3}[0-9]{3}-[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Phone">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="PType">
<xsd:attribute name="Location" type="LType"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="Group">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Member" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Member">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Phone" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
the xml file is
<?xml version="1.0"?>
<Group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\0s\test.xsd">
<Member>
<Phone Location="home">305 555-2919</Phone>
<Phone Location="business">305 555-2910</Phone>
</Member>
<Member>
<Phone Location="home">517 555-8911</Phone>
</Member>
<Member>
<Phone Location="home">481 555-0911</Phone>
<Phone Location="home">481 555-0912</Phone>
<Phone Location="home">481 555-0913</Phone>
<Phone Location="business">481 555-8717</Phone>
</Member>
<Member>
<Phone Location="home">305 555-8551</Phone>
<Phone Location="business">305 555-9090</Phone>
</Member>
<Member>
<Phone Location="business">415 555-5313</Phone>
</Member>
<Member>
<Phone Location="home">441 555-8771</Phone>
</Member>
<Member>
<Phone Location="business">305 555-0817</Phone>
</Member>
<Member>
<Phone Location="home">301 555-0914</Phone>
<Phone Location="home">301 555-0915</Phone>
<Phone Location="home">301 555-0916</Phone>
</Member>
<Member>
<Phone Location="home">301 555-3181</Phone>
<Phone Location="business">301 555-6581</Phone>
</Member>
<Member>
<Phone Location="business">301 555-6866</Phone>
</Member>
</Group>
then incorporate it into an element that uses the derived type and has an
attribute.
I have included my schema and xml file below. I am using xml spy and the
message I get is Phone must be valid with respect to definition '{no name}'.
Thanks for any help at all.
Sandie
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="LType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="home"/>
<xsd:enumeration value="business"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="PType">
<xsd:restriction base="xsd:string">
<xsd
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="Phone">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="PType">
<xsd:attribute name="Location" type="LType"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="Group">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Member" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Member">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="Phone" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
the xml file is
<?xml version="1.0"?>
<Group xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\0s\test.xsd">
<Member>
<Phone Location="home">305 555-2919</Phone>
<Phone Location="business">305 555-2910</Phone>
</Member>
<Member>
<Phone Location="home">517 555-8911</Phone>
</Member>
<Member>
<Phone Location="home">481 555-0911</Phone>
<Phone Location="home">481 555-0912</Phone>
<Phone Location="home">481 555-0913</Phone>
<Phone Location="business">481 555-8717</Phone>
</Member>
<Member>
<Phone Location="home">305 555-8551</Phone>
<Phone Location="business">305 555-9090</Phone>
</Member>
<Member>
<Phone Location="business">415 555-5313</Phone>
</Member>
<Member>
<Phone Location="home">441 555-8771</Phone>
</Member>
<Member>
<Phone Location="business">305 555-0817</Phone>
</Member>
<Member>
<Phone Location="home">301 555-0914</Phone>
<Phone Location="home">301 555-0915</Phone>
<Phone Location="home">301 555-0916</Phone>
</Member>
<Member>
<Phone Location="home">301 555-3181</Phone>
<Phone Location="business">301 555-6581</Phone>
</Member>
<Member>
<Phone Location="business">301 555-6866</Phone>
</Member>
</Group>