Restricting the behaviour of an imported complexType

Discussion in 'XML' started by steve_marjoribanks, Mar 2, 2006.

  1. 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
    steve_marjoribanks, Mar 2, 2006
    #1
    1. Advertising

  2. steve_marjoribanks wrote:

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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 2, 2006
    #2
    1. Advertising

  3. 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!
    steve_marjoribanks, Mar 2, 2006
    #3
  4. steve_marjoribanks writes:

    > 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:
    URL: http://www.ltg.ed.ac.uk/~ht/
    [mail really from me _always_ has this .sig -- mail without it is forged spam]
    Henry S. Thompson, Mar 6, 2006
    #4
  5. 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
    steve_marjoribanks, Mar 6, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Moth
    Replies:
    2
    Views:
    414
  2. Brett Gerhardi

    XSD Restricting Anytype behaviour

    Brett Gerhardi, May 19, 2005, in forum: XML
    Replies:
    1
    Views:
    527
    Brett Gerhardi
    May 19, 2005
  3. Tomasz Lisowski
    Replies:
    4
    Views:
    351
    Tomasz Lisowski
    May 25, 2005
  4. Dun Peal
    Replies:
    10
    Views:
    434
    Chris Rebert
    May 3, 2011
  5. Volker Nicolai
    Replies:
    9
    Views:
    884
    Fabian Pilkowski
    Jul 4, 2005
Loading...

Share This Page