Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Schema: Element with attributes containing only text?

Tags:

xml

xsd

People also ask

What XML schema type can be used to contain other elements and attributes?

A complex element is an XML element that contains other elements and/or attributes.


Try

  <xs:element name="option" type="AttrElement" />

  <xs:complexType name="AttrElement">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="value" type="xs:string">
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

... or the inline equivalent:

<xs:element name="option">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="value" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>