Schema for element with Attributes and Child nodes

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2010-05-31T03:21:10Z Indexed on 2010/05/31 3:22 UTC
Read the original article Hit count: 229

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about Xml

Related posts about xsd