473,411 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

problems compiling xsd in .Net 2003

Hi,

I have an .xsd document (Inc_B.xsd) that "includes" two more from the same
folder:
<xs:include schemaLocation="Inc.xsd" />
<xs:include schemaLocation="Inc_A.xsd" />
They all have the same
targetNamespace="http://tempuri.org/Inc.xsd"
xmlns:ir="http://tempuri.org/Inc.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

When I try to use xsd utility from .Net command prompt to compile Inc_B.xsd
- I receive the following error:
Could not find file '\Inc_B folder\Inc.xsd'.

I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files -
but as I cannot compile it - validation fails as Inc_B cannot find type
definitions from the other two files.

Could you please help?

Thanks in advance,

Sergey.
Nov 12 '05 #1
5 1447
Includes and Imports are resolved relative to the current schema document.
Are they present in the same folder as the parent schema?

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:E4**********************************@microsof t.com...
Hi,

I have an .xsd document (Inc_B.xsd) that "includes" two more from the same
folder:
<xs:include schemaLocation="Inc.xsd" />
<xs:include schemaLocation="Inc_A.xsd" />
They all have the same
targetNamespace="http://tempuri.org/Inc.xsd"
xmlns:ir="http://tempuri.org/Inc.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

When I try to use xsd utility from .Net command prompt to compile Inc_B.xsd - I receive the following error:
Could not find file '\Inc_B folder\Inc.xsd'.

I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files -
but as I cannot compile it - validation fails as Inc_B cannot find type
definitions from the other two files.

Could you please help?

Thanks in advance,

Sergey.

Nov 12 '05 #2
Zafar,

Yes - they are - I mentioned that in the first sentence..

I may try to explain what I am trying to do:

1. On my website clients need to upload their xml files. Depending on the
client login different schemas should apply.

2. On the server side I need to check whether the file being uploaded is
valid according to my schema (not necessarily the one in the document) - I
add the required schema to the XmlValidationReader.

3. If file passes validation - I can store the info in the database.

The only problem - I cannot COMPILE and hence -validate against added schema
(If I specify that same schema in the document - the document validates just
fine).

"Zafar Abbas" wrote:
Includes and Imports are resolved relative to the current schema document.
Are they present in the same folder as the parent schema?

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:E4**********************************@microsof t.com...
Hi,

I have an .xsd document (Inc_B.xsd) that "includes" two more from the same
folder:
<xs:include schemaLocation="Inc.xsd" />
<xs:include schemaLocation="Inc_A.xsd" />
They all have the same
targetNamespace="http://tempuri.org/Inc.xsd"
xmlns:ir="http://tempuri.org/Inc.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

When I try to use xsd utility from .Net command prompt to compile

Inc_B.xsd
- I receive the following error:
Could not find file '\Inc_B folder\Inc.xsd'.

I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files -
but as I cannot compile it - validation fails as Inc_B cannot find type
definitions from the other two files.

Could you please help?

Thanks in advance,

Sergey.


Nov 12 '05 #3
I managesd to compile in VS 2003 command-line utility - by running xsd from
within the directory where xsd files are.

Still cannot compile schema in code - it errors with "Cannot resolve
schemaLocation attribute" message.

I use the following code to add schema to XmlValidatingReader:
using System.IO;
using System.Xml;
using System.Xml.Schema;
....
string schemaFielName = this.Server.MapPath("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read(new StreamReader(schemaFielName), new
ValidationEventHandler(this.validateSchema));
sch.Compile(new ValidationEventHandler(this.validateSchema), new
XmlUrlResolver));
if (sch.IsCompiled)
{
XmlValidatingReader reader = new XmlValidatingReader(new
XmlTextReader(this.Request.Files[0].InputStream));
reader.XmlResolver = new XmlUrlResolver();
reader.Schemas.Add(sch);
reader.ValidationEventHandler += new
ValidationEventHandler(this.validateXml);
while(reader.Read());
}
....
private void validateSchema(object sender, Validation?EventArgs e)
{
Console.Write(e.Message); // I put a breakpoint here
}

What did I do wrong?
I have tried to set up sch.SourceUri to either physical path or Url just
before sch.Compile - same result...

Please HELP!!!

"Sergey Poberezovskiy" wrote:
Zafar,

Yes - they are - I mentioned that in the first sentence..

I may try to explain what I am trying to do:

1. On my website clients need to upload their xml files. Depending on the
client login different schemas should apply.

2. On the server side I need to check whether the file being uploaded is
valid according to my schema (not necessarily the one in the document) - I
add the required schema to the XmlValidationReader.

3. If file passes validation - I can store the info in the database.

The only problem - I cannot COMPILE and hence -validate against added schema
(If I specify that same schema in the document - the document validates just
fine).

"Zafar Abbas" wrote:
Includes and Imports are resolved relative to the current schema document.
Are they present in the same folder as the parent schema?

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:E4**********************************@microsof t.com...
Hi,

I have an .xsd document (Inc_B.xsd) that "includes" two more from the same
folder:
<xs:include schemaLocation="Inc.xsd" />
<xs:include schemaLocation="Inc_A.xsd" />
They all have the same
targetNamespace="http://tempuri.org/Inc.xsd"
xmlns:ir="http://tempuri.org/Inc.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"

When I try to use xsd utility from .Net command prompt to compile

Inc_B.xsd
- I receive the following error:
Could not find file '\Inc_B folder\Inc.xsd'.

I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files -
but as I cannot compile it - validation fails as Inc_B cannot find type
definitions from the other two files.

Could you please help?

Thanks in advance,

Sergey.


Nov 12 '05 #4
Try to use XML Base attributes.

Like this:
<schema xml:base="/*location folder of your included schemas*/"..

Best, Ed.

Sergey Poberezovskiy писал(а):
I managesd to compile in VS 2003 command-line utility - by running xsd from
within the directory where xsd files are.

Still cannot compile schema in code - it errors with "Cannot resolve
schemaLocation attribute" message.

I use the following code to add schema to XmlValidatingReader:
using System.IO;
using System.Xml;
using System.Xml.Schema;
...
string schemaFielName = this.Server.MapPath("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read(new StreamReader(schemaFielName), new
ValidationEventHandler(this.validateSchema));
sch.Compile(new ValidationEventHandler(this.validateSchema), new
XmlUrlResolver));
if (sch.IsCompiled)
{
XmlValidatingReader reader = new XmlValidatingReader(new
XmlTextReader(this.Request.Files[0].InputStream));
reader.XmlResolver = new XmlUrlResolver();
reader.Schemas.Add(sch);
reader.ValidationEventHandler += new
ValidationEventHandler(this.validateXml);
while(reader.Read());
}
...
private void validateSchema(object sender, Validation?EventArgs e)
{
Console.Write(e.Message); // I put a breakpoint here
}

What did I do wrong?
I have tried to set up sch.SourceUri to either physical path or Url just
before sch.Compile - same result...

Please HELP!!!

"Sergey Poberezovskiy" wrote:
Zafar,

Yes - they are - I mentioned that in the first sentence..

I may try to explain what I am trying to do:

1. On my website clients need to upload their xml files. Depending on the
client login different schemas should apply.

2. On the server side I need to check whether the file being uploaded is
valid according to my schema (not necessarily the one in the document) - I
add the required schema to the XmlValidationReader.

3. If file passes validation - I can store the info in the database.

The only problem - I cannot COMPILE and hence -validate against added schema
(If I specify that same schema in the document - the document validatesjust
fine).

"Zafar Abbas" wrote:
Includes and Imports are resolved relative to the current schema document.
Are they present in the same folder as the parent schema?

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:E4**********************************@microsof t.com...
> Hi,
>
> I have an .xsd document (Inc_B.xsd) that "includes" two more from the same
> folder:
> <xs:include schemaLocation="Inc.xsd" />
> <xs:include schemaLocation="Inc_A.xsd" />
> They all have the same
> targetNamespace="http://tempuri.org/Inc.xsd"
> xmlns:ir="http://tempuri.org/Inc.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
> When I try to use xsd utility from .Net command prompt to compile
Inc_B.xsd
> - I receive the following error:
> Could not find file '\Inc_B folder\Inc.xsd'.
>
> I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files -
> but as I cannot compile it - validation fails as Inc_B cannot find type
> definitions from the other two files.
>
> Could you please help?
>
> Thanks in advance,
>
> Sergey.



Nov 12 '05 #5
The problem is that you are reading the schema as a Stream, in which case
the BaseURI property for XmlSchema is not set. All includes are resolved
relative to the baseURI path of the parent schema, in order to make this
work, try reading using XmlTextReader instead of StreamReader:

XmlSchema sch = XmlSchema.Read(new XmlTextReader(schemaFielName), new
ValidationEventHandler(this.validateSchema));

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote
in message news:BD**********************************@microsof t.com...
I managesd to compile in VS 2003 command-line utility - by running xsd from within the directory where xsd files are.

Still cannot compile schema in code - it errors with "Cannot resolve
schemaLocation attribute" message.

I use the following code to add schema to XmlValidatingReader:
using System.IO;
using System.Xml;
using System.Xml.Schema;
...
string schemaFielName = this.Server.MapPath("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read(new StreamReader(schemaFielName), new
ValidationEventHandler(this.validateSchema));
sch.Compile(new ValidationEventHandler(this.validateSchema), new
XmlUrlResolver));
if (sch.IsCompiled)
{
XmlValidatingReader reader = new XmlValidatingReader(new
XmlTextReader(this.Request.Files[0].InputStream));
reader.XmlResolver = new XmlUrlResolver();
reader.Schemas.Add(sch);
reader.ValidationEventHandler += new
ValidationEventHandler(this.validateXml);
while(reader.Read());
}
...
private void validateSchema(object sender, Validation?EventArgs e)
{
Console.Write(e.Message); // I put a breakpoint here
}

What did I do wrong?
I have tried to set up sch.SourceUri to either physical path or Url just
before sch.Compile - same result...

Please HELP!!!

"Sergey Poberezovskiy" wrote:
Zafar,

Yes - they are - I mentioned that in the first sentence..

I may try to explain what I am trying to do:

1. On my website clients need to upload their xml files. Depending on the client login different schemas should apply.

2. On the server side I need to check whether the file being uploaded is
valid according to my schema (not necessarily the one in the document) - I add the required schema to the XmlValidationReader.

3. If file passes validation - I can store the info in the database.

The only problem - I cannot COMPILE and hence -validate against added schema (If I specify that same schema in the document - the document validates just fine).

"Zafar Abbas" wrote:
Includes and Imports are resolved relative to the current schema document. Are they present in the same folder as the parent schema?

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.com> wrote in message news:E4**********************************@microsof t.com...
> Hi,
>
> I have an .xsd document (Inc_B.xsd) that "includes" two more from the same > folder:
> <xs:include schemaLocation="Inc.xsd" />
> <xs:include schemaLocation="Inc_A.xsd" />
> They all have the same
> targetNamespace="http://tempuri.org/Inc.xsd"
> xmlns:ir="http://tempuri.org/Inc.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
> When I try to use xsd utility from .Net command prompt to compile
Inc_B.xsd
> - I receive the following error:
> Could not find file '\Inc_B folder\Inc.xsd'.
>
> I need to assign 'Inc_B.xsd' as a schema to validate incoming xml files - > but as I cannot compile it - validation fails as Inc_B cannot find type > definitions from the other two files.
>
> Could you please help?
>
> Thanks in advance,
>
> Sergey.

Nov 12 '05 #6

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

Similar topics

6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
0
by: Martin Bless | last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html ...
9
by: Ludwig Moser | last post by:
hello newsgroup! my problem is that after successful compiling the exe is running, but ONLY on my system i am using visual studio .net 2003 J# so: 1) why? 2) what can i do to change this?
2
by: Susan Baker | last post by:
Hi, I have declared a class MyClass in a header file MyClass.h I have then gone onto define the class in MyClass.cpp. This is (roughly) what the definition (.cpp) file looks like: #include...
26
by: jamesbeswick | last post by:
I've been using Access since version 97 and I've migrated to 2003. I've noticed a substantial number of strange ActiveX/OLE and code corruption problems when writing databases. The only solution...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
2
by: Rudy Ray Moore | last post by:
Hi guys, I just upgraded to "Visual Studio .net 2003 7.1 c++" from VS6. Some things I like (proper for loop variable scoping, for example), but some other things are troubling me. One...
3
by: Andreas | last post by:
Hi! I'm currently developing a DLL that makes use of C++ and .net (mixed) using Visual Studio 2003. Now, as I wanted to move to the new Visual Studio 2005, I converted this project into the...
3
by: =?Utf-8?B?VG9kZCBEb2JtZXllcg==?= | last post by:
I am working on developing a program using Visual Studio 2003 but am having problems getting my program to find my GL.h and GLU.h, and I am guessing it will have the same problems trying to link to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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 projectplanning, coding, testing,...
0
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...
0
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...

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.