By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,353 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,353 IT Pros & Developers. It's quick & easy.

xml schema import help

P: n/a
Hi

I'm stuck with the following schema validation problem in VS.NET 2003:
I have two types of xml document and related schema:
project and projectCollection.
A projectcollection is just a set of projects.
Therefore, I wish to include the project customType in the projectCollection
namespace.
I therefore have declared two xsd documents: project.xsd and
projectcollection.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollection.xml.
project.xml validates perfectly, however all of the project tags within
projectcollection.xml are not validated.
Can anyone tell me where I'm going wrong?

Thanks.
Iain Mcleod

The documents are as follows:
project.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Project" targetNamespace="http://www.golds.co.uk/Project"
elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="http://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="projectType">
<xs:sequence>
<xs:element name="projectDescription" minOccurs="0" maxOccurs="1" />
<xs:element name="projectMemberCollection" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="projectMember" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="ProjectMemberNameKey">
<xs:selector xpath=".//mstns:projectMember" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:decimal" />
</xs:complexType>
<xs:element name="project" type="projectType" />
</xs:schema>

projectCollection.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectCollection"
targetNamespace="http://www.golds.co.uk/ProjectCollection"
elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:mstns="http://www.golds.co.uk/ProjectCollection"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS="http://www.golds.co.uk/Project"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http://www.golds.co.uk/Project"
schemaLocation="Project.xsd" />
<xs:element name="projectCollection" type="projectCollectionType">
<xs:key name="ProjectPrimaryKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNameVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version" />
</xs:key>
</xs:element>
<xs:complexType name="projectCollectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS:projectType" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
project.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://www.golds.co.uk/Project" id="1" name="PM"
version="1">
<projectDescription>Project Management</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
projectCollection.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection">
<project id="1" name="PM" version="1.0">
<projectDescription>Project Management</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescription>This is a description</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
<projectMember name="GOLDS\IAM" />
</projectMemberCollection>
</project>
</projectCollection>
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
All <project> elements need to be prefixed so their namespace since it does
not belong to the same namespace as ProjectCollection.

<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:projectNS="http://www.golds.co.uk/Project">
<projectNS:project id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Hi

I'm stuck with the following schema validation problem in VS.NET 2003:
I have two types of xml document and related schema:
project and projectCollection.
A projectcollection is just a set of projects.
Therefore, I wish to include the project customType in the projectCollection namespace.
I therefore have declared two xsd documents: project.xsd and
projectcollection.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollection.xml.
project.xml validates perfectly, however all of the project tags within
projectcollection.xml are not validated.
Can anyone tell me where I'm going wrong?

Thanks.
Iain Mcleod

The documents are as follows:
project.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Project" targetNamespace="http://www.golds.co.uk/Project"
elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="http://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="projectType">
<xs:sequence>
<xs:element name="projectDescription" minOccurs="0" maxOccurs="1" />
<xs:element name="projectMemberCollection" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="projectMember" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="ProjectMemberNameKey">
<xs:selector xpath=".//mstns:projectMember" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:decimal" />
</xs:complexType>
<xs:element name="project" type="projectType" />
</xs:schema>

projectCollection.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectCollection"
targetNamespace="http://www.golds.co.uk/ProjectCollection"
elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:mstns="http://www.golds.co.uk/ProjectCollection"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS="http://www.golds.co.uk/Project"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http://www.golds.co.uk/Project"
schemaLocation="Project.xsd" />
<xs:element name="projectCollection" type="projectCollectionType">
<xs:key name="ProjectPrimaryKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNameVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version" />
</xs:key>
</xs:element>
<xs:complexType name="projectCollectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS:projectType" minOccurs="0"
maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
project.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://www.golds.co.uk/Project" id="1" name="PM"
version="1">
<projectDescription>Project Management</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
projectCollection.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection">
<project id="1" name="PM" version="1.0">
<projectDescription>Project Management</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescription>This is a description</projectDescription>
<projectMemberCollection>
<projectMember name="GOLDS\PC" />
<projectMember name="GOLDS\IAM" />
</projectMemberCollection>
</project>
</projectCollection>

Nov 12 '05 #2

P: n/a
Hi

Thanks for the suggestion, I tried it but still no joy.
It still won't recognise project and and its sub-
elements. Something is really wacky (visual studio?!) I
even tried making both schemas have the same namespace and
using an include instead of an import, and it wouldn't
recognise either of the schemas. I tried making the
elementFormDefault="unqualified", I tried everything!
If anyone knows how visual studio handles xml schema could
they possibly explain it because it's got me absolutely
stumped. I'm really surprised there aren't more posts
like this, it's obviously something I'm doing wrong,
visual studio must be able to handle imports and includes?!

Many thanks
Iain
-----Original Message-----
All <project> elements need to be prefixed so their namespace since it doesnot belong to the same namespace as ProjectCollection.

<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"xmlns:projectNS="http://www.golds.co.uk/Project">
<projectNS:project id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Hi

I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema:
project and projectCollection.
A projectcollection is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollection
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollection.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollection.xml.
project.xml validates perfectly, however all of the project tags within projectcollection.xml are not validated.
Can anyone tell me where I'm going wrong?

Thanks.
Iain Mcleod

The documents are as follows:
project.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Project" targetNamespace="http://www.golds.co.uk/Project" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="http://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="projectType">
<xs:sequence>
<xs:element name="projectDescription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMemberCollection" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="projectMember" minOccurs="0" maxOccurs="unbounded"> <xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="ProjectMemberNameKey">
<xs:selector xpath=".//mstns:projectMember" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:decimal" />
</xs:complexType>
<xs:element name="project" type="projectType" />
</xs:schema>

projectCollection.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectCollection"
targetNamespace="http://www.golds.co.uk/ProjectCollection" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:mstns="http://www.golds.co.uk/ProjectCollection"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS="http://www.golds.co.uk/Project"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http://www.golds.co.uk/Project"
schemaLocation="Project.xsd" />
<xs:element name="projectCollection" type="projectCollectionType"> <xs:key name="ProjectPrimaryKey" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNameVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version" />
</xs:key>
</xs:element>
<xs:complexType name="projectCollectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS:projectType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
project.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://www.golds.co.uk/Project" id="1" name="PM" version="1">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
projectCollection.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"> <project id="1" name="PM" version="1.0">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescription>This is a description</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
<projectMember name="GOLDS\IAM" />
</projectMemberCollection>
</project>
</projectCollection>

.

Nov 12 '05 #3

P: n/a
Wierdly enough, it now seems to be working. I took out
the projectNS declaration withing the
projectCollection.xml file, and it seems to accept
projectNS because it was defined within the
projectCollection.xsd file. It just didn't seem to like
the duplicate declaration of projectNS.
My projectCollection document now reads:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection
xmlns="http://www.golds.co.uk/ProjectCollection">
<projectNS:project id="1" name="PM" version="1.0">
<projectNS:projectDescription>Project
Management</projectDescription>
<projectNS:projectMemberCollection>
<projectNS:projectMember name="GOLDS\PC" />
</projectMemberCollection>
</projectNS:project>
<projectNS:project id="2" name="PM" version="1.1">
<projectNS:projectDescription>This is a
description</projectNS:projectDescription>
<projectNS:projectMemberCollection>
<projectNS:projectMember name="GOLDS\PC" />
<projectNS:projectMember name="GOLDS\IAM" />
</projectNS:projectMemberCollection>
</projectNS:project>
</projectCollection>

Bit of a pain having to prefix everything with projectNS,
but the schemas don't validate without the
elementFormDefault="qualified". Ask Microsoft why - 'cos
I don't understand!

Thanks for your help, I'll post again if I encounter any
more wierd behaviour.

IM
-----Original Message-----
All <project> elements need to be prefixed so their namespace since it doesnot belong to the same namespace as ProjectCollection.

<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"xmlns:projectNS="http://www.golds.co.uk/Project">
<projectNS:project id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Hi

I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema:
project and projectCollection.
A projectcollection is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollection
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollection.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollection.xml.
project.xml validates perfectly, however all of the project tags within projectcollection.xml are not validated.
Can anyone tell me where I'm going wrong?

Thanks.
Iain Mcleod

The documents are as follows:
project.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Project" targetNamespace="http://www.golds.co.uk/Project" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="http://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="projectType">
<xs:sequence>
<xs:element name="projectDescription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMemberCollection" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="projectMember" minOccurs="0" maxOccurs="unbounded"> <xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="ProjectMemberNameKey">
<xs:selector xpath=".//mstns:projectMember" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:decimal" />
</xs:complexType>
<xs:element name="project" type="projectType" />
</xs:schema>

projectCollection.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectCollection"
targetNamespace="http://www.golds.co.uk/ProjectCollection" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:mstns="http://www.golds.co.uk/ProjectCollection"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS="http://www.golds.co.uk/Project"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http://www.golds.co.uk/Project"
schemaLocation="Project.xsd" />
<xs:element name="projectCollection" type="projectCollectionType"> <xs:key name="ProjectPrimaryKey" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNameVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version" />
</xs:key>
</xs:element>
<xs:complexType name="projectCollectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS:projectType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
project.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://www.golds.co.uk/Project" id="1" name="PM" version="1">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
projectCollection.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"> <project id="1" name="PM" version="1.0">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescription>This is a description</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
<projectMember name="GOLDS\IAM" />
</projectMemberCollection>
</project>
</projectCollection>

.

Nov 12 '05 #4

P: n/a
Nope, It's actually still not working.

I found the text below in someone's blog:
located at:
http://www.hanselman.com/blog/PermaLink.aspx?guid=297
He describes the exact same problem that I am having.
Can anyone tell me how I can avoid it with visual studio?

Many thanks
Iain
<---snip--->

Import.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema
targetNamespace="http://www.import.org"
elementFormDefault="qualified">
<xs:complexType name="rootType" >
<xs:sequence>
<xs:element name="child1"
type="xs:string" maxOccurs="2" />
<xs:element name="child2"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

The Outer xsd:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org"
xmlns:tns="http://www.example.org"
xmlns:imp="http://www.import.org">
<xs:import namespace="http://www.import.org"
schemaLocation="file:///c:/import.xsd"/>
<xs:element name="root" type="imp:rootType" />
</xs:schema>
This schema appears to be valid – in fact, the .NET
framework agrees. But when you try and run the outer
schema through xsd.exe, you get the following error:

C:\>xsd /c root.xsd
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 1.1.4322.573]
Copyright (C) Microsoft Corporation 1998-2002. All rights
reserved.

Schema validation warning:
Type 'http://www.import.org:rootType' is not declared. An
error occurred at file:///C:/root.xsd, (10, 3).

Warning: Schema could not be validated. Class generation
may fail or may produce incorrect results.

Error: Error generating classes for schema 'root'.
- The datatype 'http://www.import.org:rootType' is
missing.

Update: Tomas was kind enough to point out not only that I
had originally posted the same schema TWICE, doh! But
also, more importantly, that XSD.EXE doesn't resolve
schemaLocation on imports or includes, presuambly because
the W3C Schema spec describes the schemaLocation attribute
as a hint, not a true location.

I'm back in business as I ran XSD.EXE again with all
necessary files specified on the commandline, in order to
give XSD.EXE a choice of namespaces - as opposed to hoping
it would somehow glean my intent!

<---snip--->


-----Original Message-----
All <project> elements need to be prefixed so their namespace since it doesnot belong to the same namespace as ProjectCollection.

<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"xmlns:projectNS="http://www.golds.co.uk/Project">
<projectNS:project id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.gla.ac.uk> wrote in message
news:u2**************@TK2MSFTNGP09.phx.gbl...
Hi

I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema:
project and projectCollection.
A projectcollection is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollection
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollection.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollection.xml.
project.xml validates perfectly, however all of the project tags within projectcollection.xml are not validated.
Can anyone tell me where I'm going wrong?

Thanks.
Iain Mcleod

The documents are as follows:
project.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Project" targetNamespace="http://www.golds.co.uk/Project" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="http://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="projectType">
<xs:sequence>
<xs:element name="projectDescription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMemberCollection" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="projectMember" minOccurs="0" maxOccurs="unbounded"> <xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
<xs:key name="ProjectMemberNameKey">
<xs:selector xpath=".//mstns:projectMember" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="version" type="xs:decimal" />
</xs:complexType>
<xs:element name="project" type="projectType" />
</xs:schema>

projectCollection.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectCollection"
targetNamespace="http://www.golds.co.uk/ProjectCollection" elementFormDefault="qualified"
xmlns="http://www.golds.co.uk/ProjectCollection"
xmlns:mstns="http://www.golds.co.uk/ProjectCollection"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS="http://www.golds.co.uk/Project"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http://www.golds.co.uk/Project"
schemaLocation="Project.xsd" />
<xs:element name="projectCollection" type="projectCollectionType"> <xs:key name="ProjectPrimaryKey" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNameVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version" />
</xs:key>
</xs:element>
<xs:complexType name="projectCollectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS:projectType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:schema>
project.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://www.golds.co.uk/Project" id="1" name="PM" version="1">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
projectCollection.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollection xmlns="http://www.golds.co.uk/ProjectCollection"> <project id="1" name="PM" version="1.0">
<projectDescription>Project Management</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
</projectMemberCollection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescription>This is a description</projectDescription> <projectMemberCollection>
<projectMember name="GOLDS\PC" />
<projectMember name="GOLDS\IAM" />
</projectMemberCollection>
</project>
</projectCollection>

.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.