G
Gazza
I want to define an element type which has child elements which will
have an attribute, but I want the presence of content for these child
elements (which will be simple when present) to be optional. My type is
defined as such
<xsd:complexType name="DistanceStructure">
<xsd:sequence>
<xsd:element name="Value">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:decimal">
<xsd:attribute name="Comment" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="Unit">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="esdalcomm
istanceUnitType">
<xsd:attribute name="Comment" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
This definition allows validation of the following when it appears in
my instance document
<StructureLength>
<Value Comment="STRUCTURE LENGTH COMMENT">1.1</Value>
<Unit Comment="STRUCTURE LENGTH COMMENT">metre</Unit>
</StructureLength>
But the following does not validate
<StructureLength>
<Value Comment="STRUCTURE LENGTH COMMENT"/>
<Unit Comment="STRUCTURE LENGTH COMMENT"/>
</StructureLength>
I need both to be valid possiblilies in my instance document. What can
I do?
have an attribute, but I want the presence of content for these child
elements (which will be simple when present) to be optional. My type is
defined as such
<xsd:complexType name="DistanceStructure">
<xsd:sequence>
<xsd:element name="Value">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:decimal">
<xsd:attribute name="Comment" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="Unit">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="esdalcomm
<xsd:attribute name="Comment" type="xsd:string"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
This definition allows validation of the following when it appears in
my instance document
<StructureLength>
<Value Comment="STRUCTURE LENGTH COMMENT">1.1</Value>
<Unit Comment="STRUCTURE LENGTH COMMENT">metre</Unit>
</StructureLength>
But the following does not validate
<StructureLength>
<Value Comment="STRUCTURE LENGTH COMMENT"/>
<Unit Comment="STRUCTURE LENGTH COMMENT"/>
</StructureLength>
I need both to be valid possiblilies in my instance document. What can
I do?