473,698 Members | 2,295 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 1457
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
6172
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
2064
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
2062
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
1797
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
2669
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
2405
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
2118
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
1870
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
1967
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
2628
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
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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
9028
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
8895
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
8861
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
7728
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
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.