473,748 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml schema import help

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 projectCollecti on.
A projectcollecti on is just a set of projects.
Therefore, I wish to include the project customType in the projectCollecti on
namespace.
I therefore have declared two xsd documents: project.xsd and
projectcollecti on.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollecti on.xml.
project.xml validates perfectly, however all of the project tags within
projectcollecti on.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"
elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="ht tp://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="projectTy pe">
<xs:sequence>
<xs:element name="projectDe scription" minOccurs="0" maxOccurs="1" />
<xs:element name="projectMe mberCollection" minOccurs="0"
maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence>
<xs:element name="projectMe mber" minOccurs="0" maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence />
<xs:attribute name="name" type="xs:string " />
</xs:complexType>
<xs:key name="ProjectMe mberNameKey">
<xs:selector xpath=".//mstns:projectMe mber" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsign edInt" />
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="version" type="xs:decima l" />
</xs:complexType>
<xs:element name="project" type="projectTy pe" />
</xs:schema>

projectCollecti on.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectColl ection"
targetNamespace ="http://www.golds.co.uk/ProjectCollecti on"
elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:mstns="ht tp://www.golds.co.uk/ProjectCollecti on"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS ="http://www.golds.co.uk/Project"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http ://www.golds.co.uk/Project"
schemaLocation= "Project.xs d" />
<xs:element name="projectCo llection" type="projectCo llectionType">
<xs:key name="ProjectPr imaryKey" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNa meVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version " />
</xs:key>
</xs:element>
<xs:complexTy pe name="projectCo llectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS :projectType" minOccurs="0"
maxOccurs="unbo unded" />
</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">
<projectDescrip tion>Project Management</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
projectCollecti on.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on">
<project id="1" name="PM" version="1.0">
<projectDescrip tion>Project Management</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescrip tion>This is a description</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
<projectMembe r name="GOLDS\IAM " />
</projectMemberCo llection>
</project>
</projectCollecti on>
Nov 12 '05 #1
4 2504
All <project> elements need to be prefixed so their namespace since it does
not belong to the same namespace as ProjectCollecti on.

<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:projectNS ="http://www.golds.co.uk/Project">
<projectNS:proj ect id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.g la.ac.uk> wrote in message
news:u2******** ******@TK2MSFTN GP09.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 projectCollecti on.
A projectcollecti on is just a set of projects.
Therefore, I wish to include the project customType in the projectCollecti on namespace.
I therefore have declared two xsd documents: project.xsd and
projectcollecti on.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollecti on.xml.
project.xml validates perfectly, however all of the project tags within
projectcollecti on.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"
elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="ht tp://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="projectTy pe">
<xs:sequence>
<xs:element name="projectDe scription" minOccurs="0" maxOccurs="1" />
<xs:element name="projectMe mberCollection" minOccurs="0"
maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence>
<xs:element name="projectMe mber" minOccurs="0" maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence />
<xs:attribute name="name" type="xs:string " />
</xs:complexType>
<xs:key name="ProjectMe mberNameKey">
<xs:selector xpath=".//mstns:projectMe mber" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsign edInt" />
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="version" type="xs:decima l" />
</xs:complexType>
<xs:element name="project" type="projectTy pe" />
</xs:schema>

projectCollecti on.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectColl ection"
targetNamespace ="http://www.golds.co.uk/ProjectCollecti on"
elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:mstns="ht tp://www.golds.co.uk/ProjectCollecti on"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS ="http://www.golds.co.uk/Project"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http ://www.golds.co.uk/Project"
schemaLocation= "Project.xs d" />
<xs:element name="projectCo llection" type="projectCo llectionType">
<xs:key name="ProjectPr imaryKey" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNa meVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version " />
</xs:key>
</xs:element>
<xs:complexTy pe name="projectCo llectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS :projectType" minOccurs="0"
maxOccurs="unbo unded" />
</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">
<projectDescrip tion>Project Management</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
projectCollecti on.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on">
<project id="1" name="PM" version="1.0">
<projectDescrip tion>Project Management</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescrip tion>This is a description</projectDescript ion>
<projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
<projectMembe r name="GOLDS\IAM " />
</projectMemberCo llection>
</project>
</projectCollecti on>

Nov 12 '05 #2
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
elementFormDefa ult="unqualifie d", 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 ProjectCollecti on.

<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"xmlns:projectN S="http://www.golds.co.uk/Project">
<projectNS:proj ect id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.g la.ac.uk> wrote in message
news:u2******* *******@TK2MSFT NGP09.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 projectCollecti on.
A projectcollecti on is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollect ion
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollecti on.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollecti on.xml.
project.xml validates perfectly, however all of the project tags within projectcollecti on.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" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="ht tp://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="projectTy pe">
<xs:sequence>
<xs:element name="projectDe scription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMe mberCollection" minOccurs="0"
maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence>
<xs:element name="projectMe mber" minOccurs="0" maxOccurs="unbo unded"> <xs:complexType >
<xs:sequence />
<xs:attribute name="name" type="xs:string " />
</xs:complexType>
<xs:key name="ProjectMe mberNameKey">
<xs:selector xpath=".//mstns:projectMe mber" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsign edInt" />
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="version" type="xs:decima l" />
</xs:complexType>
<xs:element name="project" type="projectTy pe" />
</xs:schema>

projectCollecti on.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectColl ection"
targetNamespace ="http://www.golds.co.uk/ProjectCollecti on" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:mstns="ht tp://www.golds.co.uk/ProjectCollecti on"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS ="http://www.golds.co.uk/Project"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http ://www.golds.co.uk/Project"
schemaLocation= "Project.xs d" />
<xs:element name="projectCo llection" type="projectCo llectionType"> <xs:key name="ProjectPr imaryKey" msdata:PrimaryK ey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNa meVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version " />
</xs:key>
</xs:element>
<xs:complexTy pe name="projectCo llectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS :projectType" minOccurs="0" maxOccurs="unbo unded" />
</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">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
projectCollecti on.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"> <project id="1" name="PM" version="1.0">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescrip tion>This is a description</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
<projectMembe r name="GOLDS\IAM " />
</projectMemberCo llection>
</project>
</projectCollecti on>

.

Nov 12 '05 #3
Wierdly enough, it now seems to be working. I took out
the projectNS declaration withing the
projectCollecti on.xml file, and it seems to accept
projectNS because it was defined within the
projectCollecti on.xsd file. It just didn't seem to like
the duplicate declaration of projectNS.
My projectCollecti on document now reads:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion
xmlns="http://www.golds.co.uk/ProjectCollecti on">
<projectNS:proj ect id="1" name="PM" version="1.0">
<projectNS:proj ectDescription> Project
Management</projectDescript ion>
<projectNS:proj ectMemberCollec tion>
<projectNS:proj ectMember name="GOLDS\PC" />
</projectMemberCo llection>
</projectNS:proje ct>
<projectNS:proj ect id="2" name="PM" version="1.1">
<projectNS:proj ectDescription> This is a
description</projectNS:proje ctDescription>
<projectNS:proj ectMemberCollec tion>
<projectNS:proj ectMember name="GOLDS\PC" />
<projectNS:proj ectMember name="GOLDS\IAM " />
</projectNS:proje ctMemberCollect ion>
</projectNS:proje ct>
</projectCollecti on>

Bit of a pain having to prefix everything with projectNS,
but the schemas don't validate without the
elementFormDefa ult="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 ProjectCollecti on.

<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"xmlns:projectN S="http://www.golds.co.uk/Project">
<projectNS:proj ect id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.g la.ac.uk> wrote in message
news:u2******* *******@TK2MSFT NGP09.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 projectCollecti on.
A projectcollecti on is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollect ion
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollecti on.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollecti on.xml.
project.xml validates perfectly, however all of the project tags within projectcollecti on.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" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="ht tp://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="projectTy pe">
<xs:sequence>
<xs:element name="projectDe scription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMe mberCollection" minOccurs="0"
maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence>
<xs:element name="projectMe mber" minOccurs="0" maxOccurs="unbo unded"> <xs:complexType >
<xs:sequence />
<xs:attribute name="name" type="xs:string " />
</xs:complexType>
<xs:key name="ProjectMe mberNameKey">
<xs:selector xpath=".//mstns:projectMe mber" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsign edInt" />
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="version" type="xs:decima l" />
</xs:complexType>
<xs:element name="project" type="projectTy pe" />
</xs:schema>

projectCollecti on.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectColl ection"
targetNamespace ="http://www.golds.co.uk/ProjectCollecti on" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:mstns="ht tp://www.golds.co.uk/ProjectCollecti on"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS ="http://www.golds.co.uk/Project"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http ://www.golds.co.uk/Project"
schemaLocation= "Project.xs d" />
<xs:element name="projectCo llection" type="projectCo llectionType"> <xs:key name="ProjectPr imaryKey" msdata:PrimaryK ey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNa meVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version " />
</xs:key>
</xs:element>
<xs:complexTy pe name="projectCo llectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS :projectType" minOccurs="0" maxOccurs="unbo unded" />
</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">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
projectCollecti on.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"> <project id="1" name="PM" version="1.0">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescrip tion>This is a description</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
<projectMembe r name="GOLDS\IAM " />
</projectMemberCo llection>
</project>
</projectCollecti on>

.

Nov 12 '05 #4
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"
elementFormDefa ult="qualified" >
<xs:complexTy pe 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:rootT ype" />
</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 ProjectCollecti on.

<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"xmlns:projectN S="http://www.golds.co.uk/Project">
<projectNS:proj ect id="1" name="PM" version="1.0">
..
..
..


"Iain A. Mcleod" <mc******@dcs.g la.ac.uk> wrote in message
news:u2******* *******@TK2MSFT NGP09.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 projectCollecti on.
A projectcollecti on is just a set of projects.
Therefore, I wish to include the project customType in the
projectCollect ion
namespace.
I therefore have declared two xsd documents:

project.xsd and projectcollecti on.xsd
These both validate.
and two xml documents to test validation:
project.xml and projectcollecti on.xml.
project.xml validates perfectly, however all of the project tags within projectcollecti on.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" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/Project"
xmlns:mstns="ht tp://www.golds.co.uk/Project"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexTy pe name="projectTy pe">
<xs:sequence>
<xs:element name="projectDe scription" minOccurs="0" maxOccurs="1" /> <xs:element name="projectMe mberCollection" minOccurs="0"
maxOccurs="unbo unded">
<xs:complexType >
<xs:sequence>
<xs:element name="projectMe mber" minOccurs="0" maxOccurs="unbo unded"> <xs:complexType >
<xs:sequence />
<xs:attribute name="name" type="xs:string " />
</xs:complexType>
<xs:key name="ProjectMe mberNameKey">
<xs:selector xpath=".//mstns:projectMe mber" />
<xs:field xpath="@name" />
</xs:key>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsign edInt" />
<xs:attribute name="name" type="xs:string " />
<xs:attribute name="version" type="xs:decima l" />
</xs:complexType>
<xs:element name="project" type="projectTy pe" />
</xs:schema>

projectCollecti on.xsd:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ProjectColl ection"
targetNamespace ="http://www.golds.co.uk/ProjectCollecti on" elementFormDefa ult="qualified"
xmlns="http://www.golds.co.uk/ProjectCollecti on"
xmlns:mstns="ht tp://www.golds.co.uk/ProjectCollecti on"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:projectNS ="http://www.golds.co.uk/Project"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:import namespace="http ://www.golds.co.uk/Project"
schemaLocation= "Project.xs d" />
<xs:element name="projectCo llection" type="projectCo llectionType"> <xs:key name="ProjectPr imaryKey" msdata:PrimaryK ey="true"> <xs:selector xpath=".//mstns:project" />
<xs:field xpath="@id" />
</xs:key>
<xs:key name="ProjectNa meVersionKey">
<xs:selector xpath=".//mstns:project" />
<xs:field xpath="@name" />
<xs:field xpath="@version " />
</xs:key>
</xs:element>
<xs:complexTy pe name="projectCo llectionType">
<xs:sequence>
<!-- Project Elements defined in Project.xsd -->
<xs:element name="project" type="projectNS :projectType" minOccurs="0" maxOccurs="unbo unded" />
</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">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
projectCollecti on.xml:

<?xml version="1.0" encoding="utf-8"?>
<projectCollect ion xmlns="http://www.golds.co.uk/ProjectCollecti on"> <project id="1" name="PM" version="1.0">
<projectDescrip tion>Project Management</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
</projectMemberCo llection>
</project>
<project id="2" name="PM" version="1.1">
<projectDescrip tion>This is a description</projectDescript ion> <projectMemberC ollection>
<projectMembe r name="GOLDS\PC" />
<projectMembe r name="GOLDS\IAM " />
</projectMemberCo llection>
</project>
</projectCollecti on>

.

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4174
by: Dennis B. Hansen | last post by:
Hi all... I'm having some problems JAXB compiling som schemas, and was wondering if what i was trying to do is simply wrong... the problem seems to be with my import statements, and I've tried to create a simple example that generates the error (included below). I have two imported schemas, and JAXB seems to only want to import one of them (possibly because they have same namespace (???)).
2
4660
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using (XMLSpy4) but not with Xerces 2.6.0. I've included a really short and simple example to illustrate it. I would like to get some comments on the validation capabilities of Xerces 2.6.0. I though it *fully* supported W3C Schema!
4
2394
by: Gordon Dickens | last post by:
I have target xml to generate from schema. All of the XML instances have the same global element i.e. <base>. I would like to combine all of the schemas into a single schema where I could generate any of the specific instances. sample schema one: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="base">
5
2248
by: Zombie | last post by:
Hi, Can I have 2 namespaces in the same XML schema? In the schema, I wish to declare elements such that some of them belong to one namespace and others belong to a second namespace. Is this possible? Note that both the namespaces should be in the same schema and same xsd file. Could somebody provide a small snippet on how to do this? Thanks for your time.
3
5919
by: Davide Bedin | last post by:
I have a "library" schema with the simple and complex types I commonly use in other schemas and then several other schemas, maybe created by other developers, that import/include the library schema. And then other schemas can extend it..... The classes created by XSD really help to make the development faster and easier. I really would like to use XSD.exe tool as much as possible and to avoid editing the classes defined by the tool. ...
8
2814
by: Poonam | last post by:
Hi, Can some one please help me with (or point me to) a very simple but working code sample that shows how to import XML Schema. I have tried many samples out there on internet but nothing seems to be working. I am trying to import a complex type/simple type element type from an external xml schema. I am using xs:import tag with namespace and schemalocation attributes defined and have also declared xmlns relative to this xml schema. I...
0
1726
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Loan"> <xs:complexType> <xs:sequence> <xs:element name="Borrower" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="BorrID" use="required">
1
6404
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
10
6938
by: gmocnik | last post by:
I am validating XML files on a server which has no internet access and the validadation in C# does not work. Schema with which I am validating has namespaces like: xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#". I have these schemas all locally on the disk, but it does not work. If I try on a computer with internet access then it works just fine. Does someone know what to do. Function with...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9321
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.