XML Schema - Custom types and Attributes

S

Sorrow

Say I have the following (simplistic) schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="RootNode">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstChildElement" type="Integer8Type" minOccurs="1"/>
<xs:element name="SecondChildElement" type="Integer8Type"
minOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="Integer8Type">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="99999999"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

I have "Integer8Type" as a custom type. Now, keeping it so that
my "FirstChildElement" element is of "Integer8Type", how can I
define that the "FirstChildElement" element has an attribute? I've
looked everywhere I can think of and I can't find an example that
would keep that element as type "Integer8Type". It always shows
that I'd have to make the "FirstChildElement" element a complex
type.
Could anyone point me in the right direction where I can find the
relevant information on defining attributes for custom typed
elements?

thnx,
Christoph
 
H

Henry S. Thompson

Sorrow said:
I have "Integer8Type" as a custom [simple] type. Now, keeping it so that
my "FirstChildElement" element is of "Integer8Type", how can I
define that the "FirstChildElement" element has an attribute?

You can't get there from here.

If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
S

Sorrow

I have "Integer8Type" as a custom [simple] type. Now, keeping it so
that
You can't get there from here.
If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.

Perhaps you can provide an example? I'm still just learning.

thnx,
Christoph
 
H

Henry S. Thompson

Sorrow said:
I have "Integer8Type" as a custom [simple] type. Now, keeping it
so that my "FirstChildElement" element is of "Integer8Type", how
can I define that the "FirstChildElement" element has an
attribute?
You can't get there from here.
If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.

Perhaps you can provide an example? I'm still just learning.

schemaV1.xsd:

<xs:complexType name="Integer8Type">
<xs:simpleContent>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="99999999"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>

. . .

<xs:element name="FirstChildElement" type="Integer8Type"/>

schemaV2.xsd:

<xs:redefine schemaLocation="schemaV1.xsd">
<xs:complexType name="Integer8Type">
<xs:simpleContent>
<xs:extension base="Integer8Type">
<xs:attribute name="something" type="somethingElse"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:redefine>

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: (e-mail address removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top