views:

19

answers:

1

Hey,

I've been tasked with building an XSD to validate a given xml, my issue is that some of the XML elements are of the form

<ElementName description="i am an element">1234567</ElementName>

I need to build the XSD that validates the Element 'value' not the attribute so with my increadibly limited experience in building XSDs (I've read the W3C tutorial) i tried this

<xs:element name ="ElementName" type="xs:int">
    <xs:complexType mixed="true">
         <xs:attribute name="description" type="xs:string"/>
    </xs:complexType>
</xs:element>

and lo and behold ... it doesn't work, it says:

"The Type attribute cannot be present with either simpleType or complexType"

i'm sure it's some thing stupid i've done but couldn't find an answer/misinterpreted answers elsewhere !

Thanks in advance

A: 

Mixed types are something different. You need a complex type with simple content:

<xs:element name="ElementName">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:int">
        <xs:attribute name="description" type="xs:string" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>

See also:

lexicore
Perfect Thanks.
Luke