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--->
[color=blue]
>-----Original Message-----
>All <project> elements need to be prefixed so their[/color]
namespace since it does[color=blue]
>not belong to the same namespace as ProjectCollection.
>
> <projectCollection[/color]
xmlns="http://www.golds.co.uk/ProjectCollection"[color=blue]
>xmlns:projectNS="http://www.golds.co.uk/Project">
> <projectNS:project id="1" name="PM" version="1.0">
>..
>..
>..
>
>
>
>
>"Iain A. Mcleod" <mcleodia@dcs.gla.ac.uk> wrote in message
>news:u2VmJDaoEHA.1272@TK2MSFTNGP09.phx.gbl...[color=green]
>> Hi
>>
>> I'm stuck with the following schema validation problem[/color][/color]
in VS.NET 2003:[color=blue][color=green]
>> 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[/color][/color]
the[color=blue]
>projectCollection[color=green]
>> namespace.
>> I therefore have declared two xsd documents:[/color][/color]
project.xsd and[color=blue][color=green]
>> 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[/color][/color]
project tags within[color=blue][color=green]
>> 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"[/color][/color]
targetNamespace="http://www.golds.co.uk/Project"[color=blue][color=green]
>> 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"[/color][/color]
maxOccurs="1" />[color=blue][color=green]
>> <xs:element name="projectMemberCollection" minOccurs="0"
>> maxOccurs="unbounded">
>> <xs:complexType>
>> <xs:sequence>
>> <xs:element name="projectMember" minOccurs="0"[/color][/color]
maxOccurs="unbounded">[color=blue][color=green]
>> <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"
>>[/color][/color]
targetNamespace="http://www.golds.co.uk/ProjectCollection"[color=blue][color=green]
>> 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"[/color][/color]
type="projectCollectionType">[color=blue][color=green]
>> <xs:key name="ProjectPrimaryKey"[/color][/color]
msdata:PrimaryKey="true">[color=blue][color=green]
>> <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"[/color][/color]
minOccurs="0"[color=blue][color=green]
>> 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"[/color][/color]
name="PM"[color=blue][color=green]
>> version="1">
>> <projectDescription>Project[/color][/color]
Management</projectDescription>[color=blue][color=green]
>> <projectMemberCollection>
>> <projectMember name="GOLDS\PC" />
>> </projectMemberCollection>
>> </project>
>>
>>
>> projectCollection.xml:
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <projectCollection[/color][/color]
xmlns="http://www.golds.co.uk/ProjectCollection">[color=blue][color=green]
>> <project id="1" name="PM" version="1.0">
>> <projectDescription>Project[/color][/color]
Management</projectDescription>[color=blue][color=green]
>> <projectMemberCollection>
>> <projectMember name="GOLDS\PC" />
>> </projectMemberCollection>
>> </project>
>> <project id="2" name="PM" version="1.1">
>> <projectDescription>This is a[/color][/color]
description</projectDescription>[color=blue][color=green]
>> <projectMemberCollection>
>> <projectMember name="GOLDS\PC" />
>> <projectMember name="GOLDS\IAM" />
>> </projectMemberCollection>
>> </project>
>> </projectCollection>
>>
>>[/color]
>
>
>.
>[/color]