newbie: how to create this kind of schema

M

mcha226

Hi All:
In my XML document, sometimes I have:

<a>xxxxxxxx</a>

and sometimes I have

<a><text>xxxxx xxxxx</text></a>

which can distinguish a long text and a ordinary string.

I am trying to come up with a general schema which will think both are
valid.
I tried to creat a type which can be used for this by using xs:choice.
However I am not really successful as my schema cannot pass the schema
validator.
Can anyone tell me how I can do that? Thanks.
 
H

Henry S. Thompson

In my XML document, sometimes I have:

<a>xxxxxxxx</a>

and sometimes I have

<a><text>xxxxx xxxxx</text></a>

<xs:element name="a">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="text"/>
</xs:sequence>
</xs:complexType>
</xs:element>

Not perfect, as will allow e.g. <a>x<text>xxx xx</text>x</a> as well
as what you want, but closest you can get with W3C XML Schema.

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]
 
M

mcha226

Hehe, I am a newbie, that's why I just found out that the following
schema will not validate.
...
<xs:choice>
<xs:group ref="a"/>
<xs:group ref="b"/>
</xs:choice>
...
...
<xs:group name="a">
<xs:sequence>
<xs:element ref="type"/>
<xs:element ref="gender"/>
</xs:sequence>
</xs:group>
<xs:group name="b">
<xs:sequence>
<xs:element ref="type"/>
<xs:element ref="street"/>
</xs:sequence>
</xs:group>
...
...

So I can't really have 2 groups having the same element when I am
having a choice bewteen these 2 groups. Is this supposed to be the way
it is, and is there a way around it?
Cheers
Mark
 

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
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top