364,085 Members | 5253 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Help associate xml to xsd (schema) file...

Vagabond Software
P: n/a
Vagabond Software
I have translated a DTD to an XML Schema (XSD) file by hand, and the Schema View in Visual Studio .NET 2003 seems to diplay everything properly.

However, when I specify the schemalocation in my xml files, VS.NET still reports that no schema could be located. Here are the relevant (maybe) portions of the files:

FROM THE SCHEMA FILE (mydoc-v2.xsd)

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

FROM THE XML FILE (myTestDoc.xml):

<mydoc
xmlns="http://tempuri.org/mydoc-v2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="file:///C:/Dev/mydoc-v2.xsd">

VISUAL STUDIO .NET 2003 ERROR MSG:

C:\Dev\myTestDoc.xml(1): Visual Studio could not locate a schema for this document. Validation can only ensure this is a well formed XML document and cannot validate the data against a schema.

Any help with this is greatly appreciated.

- VSW


Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


Priscilla Walmsley
P: n/a
Priscilla Walmsley
Hi,

You have two problems in your instance XML:

1. The namespace in your instance must match the target namespace of your
schema. So, you should change xmlns="http://tempuri.org/mydoc-v2.xsd" to
xmlns="http://tempuri.org/XMLSchema.xsd".

2. The schemaLocation attribute should be the namespace, followed by
whitespace, followed by the schema location. You have only specified the
schema location. So, you should change it to
xs:schemaLocation="http://tempuri.org/XMLSchema.xsd
file:///C:/Dev/mydoc-v2.xsd"

Also, usually people use the prefix "xsi" rather than "xs" for the
http://www.w3.org/2001/XMLSchema-instance namespace. It's not incorrect the
way you have it, but it might be more clear if you used xs instead of xsi in
your instance.

Hope that helps,
Priscilla
------------------------------------------------------------------
Priscilla Walmsley
Author, Definitive XML Schema / XML in Office 2003
http://www.datypic.com
------------------------------------------------------------------

"Vagabond Software" <carlfenley-X-@-X-san.rr.com> wrote in message
news:u1Nv$zkeEHA.3984@TK2MSFTNGP10.phx.gbl...
I have translated a DTD to an XML Schema (XSD) file by hand, and the Schema
View in Visual Studio .NET 2003 seems to diplay everything properly.

However, when I specify the schemalocation in my xml files, VS.NET still
reports that no schema could be located. Here are the relevant (maybe)
portions of the files:

FROM THE SCHEMA FILE (mydoc-v2.xsd)

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

FROM THE XML FILE (myTestDoc.xml):

<mydoc
xmlns="http://tempuri.org/mydoc-v2.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="file:///C:/Dev/mydoc-v2.xsd">

VISUAL STUDIO .NET 2003 ERROR MSG:

C:\Dev\myTestDoc.xml(1): Visual Studio could not locate a schema for this
document. Validation can only ensure this is a well formed XML document and
cannot validate the data against a schema.

Any help with this is greatly appreciated.

- VSW



Nov 12 '05 #2

John Smith
P: n/a
John Smith
I Must add that if you use the validation in Visual Studio using the
menu the xsd must be in the same project as the xml.

I never got it too work without putting both in a project.

Hope this help

"Vagabond Software" <carlfenley-X-@-X-san.rr.com> wrote in message news:<u1Nv$zkeEHA.3984@TK2MSFTNGP10.phx.gbl>...[color=blue]
> I have translated a DTD to an XML Schema (XSD) file by hand, and the
> Schema View in Visual Studio .NET 2003 seems to diplay everything
> properly.
>
> However, when I specify the schemalocation in my xml files, VS.NET still
> reports that no schema could be located. Here are the relevant (maybe)
> portions of the files:
>
> FROM THE SCHEMA FILE (mydoc-v2.xsd)
>
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
> elementFormDefault="qualified"
> xmlns="http://tempuri.org/XMLSchema.xsd"
> xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> FROM THE XML FILE (myTestDoc.xml):
>
> <mydoc
> xmlns="http://tempuri.org/mydoc-v2.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
> xs:schemaLocation="file:///C:/Dev/mydoc-v2.xsd">
>
> VISUAL STUDIO .NET 2003 ERROR MSG:
>
> C:\Dev\myTestDoc.xml(1): Visual Studio could not locate a schema for
> this document. Validation can only ensure this is a well formed XML
> document and cannot validate the data against a schema.
>
> Any help with this is greatly appreciated.
>
> - VSW[/color]
Nov 12 '05 #3

Post your reply

Help answer this question



Didn't find the answer to your .NET Framework question?

You can also browse similar questions: .NET Framework