473,729 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1459
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************ *****@discussio ns.microsoft.co m> wrote
in message news:E4******** *************** ***********@mic rosoft.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 XmlValidationRe ader.

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************ *****@discussio ns.microsoft.co m> wrote
in message news:E4******** *************** ***********@mic rosoft.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 XmlValidatingRe ader:
using System.IO;
using System.Xml;
using System.Xml.Sche ma;
....
string schemaFielName = this.Server.Map Path("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read( new StreamReader(sc hemaFielName), new
ValidationEvent Handler(this.va lidateSchema));
sch.Compile(new ValidationEvent Handler(this.va lidateSchema), new
XmlUrlResolver) );
if (sch.IsCompiled )
{
XmlValidatingRe ader reader = new XmlValidatingRe ader(new
XmlTextReader(t his.Request.Fil es[0].InputStream));
reader.XmlResol ver = new XmlUrlResolver( );
reader.Schemas. Add(sch);
reader.Validati onEventHandler += new
ValidationEvent Handler(this.va lidateXml);
while(reader.Re ad());
}
....
private void validateSchema( object sender, Validation?Even tArgs 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 XmlValidationRe ader.

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************ *****@discussio ns.microsoft.co m> wrote
in message news:E4******** *************** ***********@mic rosoft.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 XmlValidatingRe ader:
using System.IO;
using System.Xml;
using System.Xml.Sche ma;
...
string schemaFielName = this.Server.Map Path("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read( new StreamReader(sc hemaFielName), new
ValidationEvent Handler(this.va lidateSchema));
sch.Compile(new ValidationEvent Handler(this.va lidateSchema), new
XmlUrlResolver) );
if (sch.IsCompiled )
{
XmlValidatingRe ader reader = new XmlValidatingRe ader(new
XmlTextReader(t his.Request.Fil es[0].InputStream));
reader.XmlResol ver = new XmlUrlResolver( );
reader.Schemas. Add(sch);
reader.Validati onEventHandler += new
ValidationEvent Handler(this.va lidateXml);
while(reader.Re ad());
}
...
private void validateSchema( object sender, Validation?Even tArgs 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 XmlValidationRe ader.

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************ *****@discussio ns.microsoft.co m> wrote
in message news:E4******** *************** ***********@mic rosoft.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(s chemaFielName), new
ValidationEvent Handler(this.va lidateSchema));

"Sergey Poberezovskiy" <Se************ *****@discussio ns.microsoft.co m> wrote
in message news:BD******** *************** ***********@mic rosoft.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 XmlValidatingRe ader:
using System.IO;
using System.Xml;
using System.Xml.Sche ma;
...
string schemaFielName = this.Server.Map Path("~/schemas/Inc_B.xsd");
XmlSchema sch = XmlSchema.Read( new StreamReader(sc hemaFielName), new
ValidationEvent Handler(this.va lidateSchema));
sch.Compile(new ValidationEvent Handler(this.va lidateSchema), new
XmlUrlResolver) );
if (sch.IsCompiled )
{
XmlValidatingRe ader reader = new XmlValidatingRe ader(new
XmlTextReader(t his.Request.Fil es[0].InputStream));
reader.XmlResol ver = new XmlUrlResolver( );
reader.Schemas. Add(sch);
reader.Validati onEventHandler += new
ValidationEvent Handler(this.va lidateXml);
while(reader.Re ad());
}
...
private void validateSchema( object sender, Validation?Even tArgs 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 XmlValidationRe ader.

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************ *****@discussio ns.microsoft.co m> wrote in message news:E4******** *************** ***********@mic rosoft.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
6175
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 itself. Everything you need is available at no costs (except download hassle and installation time). Once your system is set up properly its just a matter of running 'python setup.py build'. No longer waiting for someone else to build binaries and a...
0
2066
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 Unfortunately the binary for Python-2.4 isn't available yet and I'd hate to step back to a previous version. I'm glad I managed to set up my XP machine to being able to compile extensions using the VC++ toolkit which freely availbale from MS. See
9
2069
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
1799
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 "BaseHeader.h" /****************************************************/ /* Constructors/Destructor */
26
2674
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 I've found is to create a new database and import all the objects from the corrupted file. Has anyone else found a solution to this annoying problem? I cannot find anything useful on Microsoft's website and I haven't seen any posts about the...
10
2413
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) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
2
2123
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 my other includes then I get lots of errors like C2011: 'fd_set' : 'struct' type redefinition warning C4005: 'FD_CLR' : macro redefinition which I understand are due to the fact that windows.h is being included in another header file as well as...
2
1871
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 annoying behavior is that the text editor often "hangs" (doesn't let me type) while compiling. Is there a way to fix this so it behaves more like VS6 (editor does not hang while compiling)?
3
1969
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 new format (compiling with /clr:OldSyntax): everything works and compiles fine. Unfortunately, I cannot link to the newly created DLL from any other application/DLL: LNK2019: unresolved external symbol. I've checked the DLL
3
2633
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 the .lib and .dll files. What do I all need to do to get this to properly compile and link. Here is what I have done so far. Inside my main project directory, I added a folder called "OpenGL" and inside this folder are 3 sub-folders,...
0
8917
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
1
9200
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
9142
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
8148
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, and deploymentwithout 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
6022
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
4525
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
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
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
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.