XML Schema - Custom types and Attributes

Sorrow

Usenet Archive
Joined
Dec 12, 2002
Messages
10
Reaction score
0
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
 

Henry S. Thompson

Usenet Archive
Joined
Jan 14, 2000
Messages
309
Reaction score
0
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
 

Sorrow

Usenet Archive
Joined
Dec 12, 2002
Messages
10
Reaction score
0
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
 

Henry S. Thompson

Usenet Archive
Joined
Jan 14, 2000
Messages
309
Reaction score
0
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
 

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

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top