Schema for element with Attributes and Child nodes
I am trying to write xsd type schema for an element that has a custom type to include addition attributes to extend a base type. I am running into trouble getting the syntax right.
<xs:element name="graphs">
<xs:complexType>
<xs:sequence>
<xs:element name="graph"
开发者_运维技巧 minOccurs="1"
maxOccurs="unbounded"
type="graphType">
<!-- child elements -->
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="graphType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="title" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
I thought this would be something very common, but having read many tuts and forums, I cant seem to find an answer that works for me.
Edit: Actually I don't want the parent node (graph) to contain string data, only xml..
I have come up with this..
<xs:element name="graphs">
<xs:complexType>
<xs:sequence>
<xs:element name="graph"
minOccurs="1"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="sequence" type="sequenceType"/>
</xs:sequence>
<xs:attribute name="title" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="sequenceType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
I think it syntactically valid. Does it seem correct?
精彩评论