Declaring a global ID Attribute

B

Bubba

Hi all,

I've got an XSD file that I need to add support to for an optional ID
attribute on elements. After many hours of tweaking all that I get to
work in my XML file is:

<Container id="CT"> <!-- Valid ID declaration -->
<Stuff id="CT-1">Foo Bar</Stuff> <!-- Invalid ID declaration-->
</Container>

I got this to work by adding an:

<xs:attribute name="id" type="xs:ID"/>
just under by <xs:schema ...> line and then:

<xs:complexType name="Container">
<xs:sequence>
<xs:element name="Stuff" type="StuffText" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id"/> <!-- I added this line -->
</xs:complexType>

From what I've read I can do this by declaring the elements separatley
but the schema is quite large at over 50K, so I'm guessing there MUST be
a way to globally declare the use of an optional ID attribute on elements.

If I change the elementFromDefault to "unqualified" I can get the ID to
work but it then breaks other stuff within the XSD.

Can anyone point me in the right direction here please.

Thanks.
 
B

Bubba

George said:
Hi Bubba,

It is difficult for me to understand very well your message but, in
any case, you might take a look at the XML Schema for XML Schemas as
there it is defined an optional id attribute that can appear on schema
components, so it may be a good example to follow:

http://www.w3.org/TR/xmlschema-1/#normative-schemaSchema

Best Regards,
George

Hi George,

Thanks for the reply, but this is over my head, I can't disclose the
schema here as it's proprietry to the creator and confidential.

All I can say at best is that there are many simpleType definitions
followed by complexType definitions, however none of the complexType are
'wrapped' in <xs:element> tags as I've seen in O'reilly's XML Schema book.

Below is a representation of the structure of the schema I have.

<xs:schema ...>
<xs:simpleType name="Blah">
....
</xs:simpleType>

More simpleTypes

<xs:complexType name="Foo">
<xs:sequence>
<xs:element name="Bar" type="Blah" minOccurs="0" />
<xs:element ... />
...
</xs:sequence>
</xs:complexType>

More complexTypes...

<xs:complexType name="Master">
<xs:sequence>
<xs:element name="B" type="Foo" minOccurs="0"/>
...
</xs:sequence>
</xs:complexType>

and finally

<xs:element name="M" type="Master" />
</xs:schema>

I'm really confused here as I know this 'global' id attribute is
supported but for the life of me I can't work out how to fix this.

I'd really appreciate any help I can get with this.
 
G

George Bina

Hi Bubba,

My suggestion is to try a clean start with just a couple of elements
and types. Chances are that you will solve the problem as you try to
create this simple example but even if you do not figure that out you
will end up with a complete example that will help you define the
exact problem and will increase your chances to get a helpful reply.

Best Regards,
George
 

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
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top