Multiple Schemas

S

steve_marjoribanks

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
 
G

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
 
S

steve_marjoribanks

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
 
M

Martin Honnen

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

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 ?
 

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
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top