B
Brett Gerhardi
Can anyone explain how I can do the following correctly:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="e"/>
<xs:complexType name="ct1">
<xs:choice>
<xs:any namespace="##any"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="ct2">
<xs:complexContent>
<xs:restriction base="ct1">
<xs:choice>
<xs:element name="e1"/>
<xs:element name="e2"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
This actually validates ok within XMLSpy within itself, it is just when I
try to validate the following document against it I get the error: "The
content model of complex type ct2 is not a valid restriction of the content
model of complex type ct1
<?xml version="1.0" encoding="UTF-8"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="RestrictingAnytype.xsd"/>
What I would ultimately like to do is express that children of ct1 will only
be of a certain type (in another namespace), but there could be a varying
amount of children. I suppose in programming terms I am looking to express a
typed container.
Is there no way to do this using XSD?
Thanks for any help!
-=- Brett
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="e"/>
<xs:complexType name="ct1">
<xs:choice>
<xs:any namespace="##any"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="ct2">
<xs:complexContent>
<xs:restriction base="ct1">
<xs:choice>
<xs:element name="e1"/>
<xs:element name="e2"/>
</xs:choice>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
This actually validates ok within XMLSpy within itself, it is just when I
try to validate the following document against it I get the error: "The
content model of complex type ct2 is not a valid restriction of the content
model of complex type ct1
<?xml version="1.0" encoding="UTF-8"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="RestrictingAnytype.xsd"/>
What I would ultimately like to do is express that children of ct1 will only
be of a certain type (in another namespace), but there could be a varying
amount of children. I suppose in programming terms I am looking to express a
typed container.
Is there no way to do this using XSD?
Thanks for any help!
-=- Brett