473,728 Members | 1,924 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 2502
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
4173
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
4658
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
2393
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
2247
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
2813
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
6403
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
6936
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
9424
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...
0
9277
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9198
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
9135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8133
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...
1
6718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6013
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
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.