- From: Eddie Robertsson <eddie@allette.com.au>
- Date: Thu, 25 Jan 2001 11:59:40 +1100
- To: Michael Anderson <michael@research.canon.com.au>
- CC: "Kollu, Kishore" <kishore_kollu@mentorg.com>, "Xml-Schema-Dev (E-mail)" <xmlschema-dev@w3.org>
Michael Anderson wrote:
> "Kollu, Kishore" wrote:
>
> > Hi,
> > Can I define a list element with an attribute? If so how?
> >
> > I would like to have an element like :
> >
> > <terminals n="4">t1 t2 t3 t4</terminals>
>
> Sure, create a complexType with simpleContent that extends your list
> SimpleType by adding an attribute. See the Primer Sections 2.3.1 and
> 2.5.1.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
elementFormDefault="qualified" targetNamespace="www.terminal.org"
xmlns="www.terminal.org">
<xsd:simpleType name="terminalType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="t\d+"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="terminalList">
<xsd:list itemType="terminalType"/>
</xsd:simpleType>
<xsd:complexType name="terminals">
<xsd:simpleContent>
<xsd:extension base="terminalList">
<xsd:attribute name="n" type="xsd:positiveInteger"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:element name="terminal" type="terminals"/>
</xsd:schema>
/Eddie
Received on Wednesday, 24 January 2001 19:57:12 UTC