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:complexTyp e name="DistanceS tructure">
<xsd:sequence >
<xsd:element name="Value">
<xsd:complexTyp e>
<xsd:simpleCont ent>
<xsd:extensio n base="xsd:decim al">
<xsd:attribut e name="Comment" type="xsd:strin g"/>
</xsd:extension>
</xsd:simpleConte nt>
</xsd:complexType >
</xsd:element>
<xsd:element name="Unit">
<xsd:complexTyp e>
<xsd:simpleCont ent>
<xsd:extensio n base="esdalcomm :DistanceUnitTy pe">
<xsd:attribut e name="Comment" type="xsd:strin g"/>
</xsd:extension>
</xsd:simpleConte nt>
</xsd:complexType >
</xsd:element>
</xsd:sequence>
</xsd:complexType >
This definition allows validation of the following when it appears in
my instance document
<StructureLengt h>
<Value Comment="STRUCT URE LENGTH COMMENT">1.1</Value>
<Unit Comment="STRUCT URE LENGTH COMMENT">metre</Unit>
</StructureLength >
But the following does not validate
<StructureLengt h>
<Value Comment="STRUCT URE LENGTH COMMENT"/>
<Unit Comment="STRUCT URE 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:complexTyp e name="DistanceS tructure">
<xsd:sequence >
<xsd:element name="Value">
<xsd:complexTyp e>
<xsd:simpleCont ent>
<xsd:extensio n base="xsd:decim al">
<xsd:attribut e name="Comment" type="xsd:strin g"/>
</xsd:extension>
</xsd:simpleConte nt>
</xsd:complexType >
</xsd:element>
<xsd:element name="Unit">
<xsd:complexTyp e>
<xsd:simpleCont ent>
<xsd:extensio n base="esdalcomm :DistanceUnitTy pe">
<xsd:attribut e name="Comment" type="xsd:strin g"/>
</xsd:extension>
</xsd:simpleConte nt>
</xsd:complexType >
</xsd:element>
</xsd:sequence>
</xsd:complexType >
This definition allows validation of the following when it appears in
my instance document
<StructureLengt h>
<Value Comment="STRUCT URE LENGTH COMMENT">1.1</Value>
<Unit Comment="STRUCT URE LENGTH COMMENT">metre</Unit>
</StructureLength >
But the following does not validate
<StructureLengt h>
<Value Comment="STRUCT URE LENGTH COMMENT"/>
<Unit Comment="STRUCT URE LENGTH COMMENT"/>
</StructureLength >
I need both to be valid possiblilies in my instance document. What can
I do?
Comment