Restricting the behaviour of an imported complexType

  • Thread starter steve_marjoribanks
  • Start date
S

steve_marjoribanks

I want to import a complex type into my schema which contains a complex
type which includes a choice as shown below:

<choice minOccurs="2" maxOccurs="unbounded">
<element ref="gml:pos"/>
<element ref="gml:pointProperty"/>
<element ref="gml:pointRep">
</choice>

Howver, in my schema I only want to allow the "gml:pos" element to
occur, not the others. Is it possible to restrict the allowable
instances of the imported complexType within my schema? I know I could
just reference the gml:pos element directly but I was wondering if it
is possible to import the complex type and then restrict the values?

Thanks

Steve
 
M

Martin Honnen

steve_marjoribanks said:
I want to import a complex type into my schema which contains a complex
type which includes a choice as shown below:

<choice minOccurs="2" maxOccurs="unbounded">
<element ref="gml:pos"/>
<element ref="gml:pointProperty"/>
<element ref="gml:pointRep">
</choice>

Howver, in my schema I only want to allow the "gml:pos" element to
occur, not the others. Is it possible to restrict the allowable
instances of the imported complexType within my schema? I know I could
just reference the gml:pos element directly but I was wondering if it
is possible to import the complex type and then restrict the values?

Generally you can extend and restrict existing types, see
<http://www.w3.org/TR/xmlschema-0/#DerivByRestrict>
 
S

steve_marjoribanks

I've tried that but it doesn't seem to like it. I created my complex
type and derived it from an existing type. When I had my type exaclt
the same as the existing type it validated fine and when I tried
changing the maxOccurs attribute of elements in my complex type which
were derived from the existing type that was fine too.

However, whenever I tried to remove elements from my type or setting
maxOccurs and minOccurs to 0 it doesn't like it.

In the W3C recommendation it says this should be ok though?!

Ah well, I just referenced gml:pos directly in the end. Thanks anyhow!
 
H

Henry S. Thompson

steve_marjoribanks said:
I've tried that but it doesn't seem to like it. I created my complex
type and derived it from an existing type. When I had my type exaclt
the same as the existing type it validated fine and when I tried
changing the maxOccurs attribute of elements in my complex type which
were derived from the existing type that was fine too.

However, whenever I tried to remove elements from my type or setting
maxOccurs and minOccurs to 0 it doesn't like it.

In the W3C recommendation it says this should be ok though?!

Indeed it is OK -- what schema processor are you using, and what error
message are you getting, for what schema document?

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

steve_marjoribanks

I am using XMLSpy2006 Home edition. I think it is probably a bug in the
software to be honest, I have been informed of a coupld of other bugs
in the system. Unfortunately I can't show you the schema I was using as
it doesn't exist in that form anymore! It was identical to the schema
at http://www.dur.ac.uk/s.j.marjoribanks/geotechml/interpreted.xsd
except that the last complex type, instead of referencing <gml:pos>
directly declared an element of type gml:LineStringType and then
restricted the allowed elements within it to only the <gml:pos>
element. The gml:pos and gml:LineStringType are in the
geometrybasic0d1d as imported at the top of the schema.

However, it's not really an issue now as I am not using that method
anymore, but thanks for enquiring!

Steve
 

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
474,001
Messages
2,570,255
Members
46,853
Latest member
GeorgiaSta

Latest Threads

Top