Multiple Schemas

Discussion in 'XML' started by steve_marjoribanks, Jan 24, 2006.

  1. Does anyone know of any good resources about using multiple schemas? I
    am having trouble getting me head round a problem!

    I am writing schema A which imports schema B from another namespace
    (ns) and in S1 I define an element as being <element name="top"
    type="ns:geometry" />. If the 'geometry' complex type is a 'top level'
    complex type which contains lots of other complex types which can
    describe any object, do I need to define all of these (or at least the
    ones I need) again in my schema or does the fact that I've imported the
    top level type mean that any instances of the lower types in my XML
    will be valid?

    Sorry, it's a difficult problem to describe, I'm working with GML which
    is so huge it's hard to get my head round it!

    Thanks

    Steve
     
    steve_marjoribanks, Jan 24, 2006
    #1
    1. Advertising

  2. steve_marjoribanks

    Guest

    steve_marjoribanks a écrit :

    > Does anyone know of any good resources about using multiple schemas? I
    > am having trouble getting me head round a problem!
    >
    > I am writing schema A which imports schema B from another namespace
    > (ns) and in S1 I define an element as being <element name="top"
    > type="ns:geometry" />. If the 'geometry' complex type is a 'top level'
    > complex type which contains lots of other complex types which can
    > describe any object, do I need to define all of these (or at least the
    > ones I need) again in my schema or does the fact that I've imported the
    > top level type mean that any instances of the lower types in my XML
    > will be valid?
    >

    No, you don't. "import" is similar to "include" for the C language.
    You certainly have a syntax problem in your schema definition.
    Have a look at this: http://www.w3schools.com/schema/schema_intro.asp
     
    , Jan 25, 2006
    #2
    1. Advertising

  3. So if I wish import a complex type into my schema which is defined in
    another schema I don't have to define the complex type I want again in
    my schema because the 'import' statement will mean that all of the
    global elements/complex types from that schema will automatically be
    valid in mine? I understand that I don't have to define/declare the
    types again, but I do have to 'ref' or 'name' them, is this correct? So
    if I wanted to use 3 complex types from another schema with namespace
    "http://www.???.com" called, "one", "two" and "three", in my schema I
    would have:

    <schema ...... xmlns:no="http://www.???.org" ....... >
    ..
    <import namespace="http://www.???.com"
    schemaLocation="http://www.???.com/schema.xsd" />
    ..
    ..
    ..
    <element name="1" type="no:eek:ne" .... />
    <element name="2" type="no:two"..... />
    <element name="3" type="no:three" ..... />
    ..
    ..
    </schema>


    Say, for example, complex types one, two and three had 'sub' types and
    'super' types (not the correct terminology but I expect you know what I
    mean) defined in the external schema, would an instance document of my
    schema be valid if it contained instances of these 'sub' and 'super'
    types or would I have to explicitly declare them in my schema?

    Thanks for your help
    Steve
     
    steve_marjoribanks, Jan 25, 2006
    #3
  4. steve_marjoribanks wrote:


    > I understand that I don't have to define/declare the
    > types again, but I do have to 'ref' or 'name' them, is this correct?


    Yes, right, you import the schema for another different namespace and
    then use the elements or types defined there using ref or type with a
    qualified name given.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jan 25, 2006
    #4
  5. steve_marjoribanks

    Guest

    steve_marjoribanks a écrit :

    > So if I wish import a complex type into my schema which is defined in
    > another schema I don't have to define the complex type I want again in
    > my schema because the 'import' statement will mean that all of the
    > global elements/complex types from that schema will automatically be
    > valid in mine? I understand that I don't have to define/declare the
    > types again, but I do have to 'ref' or 'name' them, is this correct? So
    > if I wanted to use 3 complex types from another schema with namespace
    > "http://www.???.com" called, "one", "two" and "three", in my schema I
    > would have:
    >
    > <schema ...... xmlns:no="http://www.???.org" ....... >
    > .
    > <import namespace="http://www.???.com"
    > schemaLocation="http://www.???.com/schema.xsd" />
    > .
    > .
    > .
    > <element name="1" type="no:eek:ne" .... />
    > <element name="2" type="no:two"..... />
    > <element name="3" type="no:three" ..... />
    > .
    > .
    > </schema>
    >
    >
    > Say, for example, complex types one, two and three had 'sub' types and
    > 'super' types (not the correct terminology but I expect you know what I
    > mean) defined in the external schema, would an instance document of my
    > schema be valid if it contained instances of these 'sub' and 'super'
    > types or would I have to explicitly declare them in my schema?
    >
    > Thanks for your help
    > Steve

    Don't you have an application like "xmllint" to quickly validate your
    schemas ?
     
    , Jan 26, 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. Oleg Ogurok

    dynamic color schemas with ASP.NET

    Oleg Ogurok, Jun 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    458
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Jun 8, 2004
  2. Alex Rootham
    Replies:
    2
    Views:
    612
    Richard Tobin
    Aug 28, 2003
  3. Sean Keplinger

    Validating Multiple Schemas

    Sean Keplinger, Oct 15, 2003, in forum: XML
    Replies:
    0
    Views:
    405
    Sean Keplinger
    Oct 15, 2003
  4. Mattias
    Replies:
    1
    Views:
    441
    Martin Honnen
    Dec 4, 2003
  5. Steve George
    Replies:
    1
    Views:
    1,946
    Martin Honnen
    Apr 12, 2005
Loading...

Share This Page