Re: How to define an element with attribute

Wang K H wrote:

> Hi all, I am new to schema and is trying to write a schema. Please
> refer to the example below :<Value POSITION="4">PART</Value>
>
> How do I define the schema for the above element?
>
> Right now, I am writing as :
>
> <xsd:element name="Value" minOccurs="0" maxOccurs="unbounded">
>
> <xsd:complexType>
> <xsd:attribute name="POSITION" type="xsd:positiveInteger"
> use="optional"/>
>
> </xsd:complexType>
>
> </xsd:element>

<xsd:element name="Value" minOccurs="0" maxOccurs="unbounded">
   <xsd:complexType>
      <xsd:simpleContent>
         <xsd:extension base="xsd:string">
            <xsd:attribute name="POSITION" type="positiveInteger"
use="optional"/>
         </xsd:extension>
      </xsd:simpleContent>
   </xsd:complexType>
</xsd:element>

This will give you the element definition you want and in this case the
content of element Value is of type xsd:string.

Cheers,
/Eddie

Received on Friday, 30 March 2001 02:01:38 UTC