473,320 Members | 2,097 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,320 software developers and data experts.

Embedded XSD files with includes

Hi,

(.NET 2.0)

I want to embed the XML schema files into my DLL. However, this schema is
"split" in several files, i.e., they use xs:include. Note that the include is
relative and contains only the name of the file, i.e., the fragments are
supposed to be in the same directory.

For simplicity, suppose we have a main schema "a.xsd", which includes
"b.xsd" and "c.xsd".

In my code, I add the main schema (that includes all others) using:

xmlSettings.Schemas.Add(SCL2006_NAMESPACE, new
XmlTextReader(Assembly.GetExecutingAssembly().GetM anifestResourceStream("a.xsd"));

Now, when I open (validating) an instance file, using:
XmlReader.Create(new XmlTextReader(file, _nt), settings)

there is an exception saying that there is an undefined complex type. This
is because it did not read the included XSDs (b.xsd and c.xsd). How can I
ensure that it would do it?

I tried to solve the problem this way: I added to the xmlSettings.Schemas
all parts of the full schema, i.e, beside "a.xsd", "b.xsd" and "c.xsd".

Then, it works fine - up to a point. If the directory containing the
instance file contains as well one or all files constituting the schema, then
I get an exception that a simple type (from XSD "b.xsd") has already been
declared.

So it looks like it does process the schema files only when loading the
instance file, and looks for includes in the directory where the instance
file is. How can I avoid this behavior?

I've tried to add XmlSchema to the xmlSettings.Schemas, however this does
not solve the problem either...

Thanks for any help!
Jun 14 '06 #1
1 2491
Melbrouff wrote:
Hi,

(.NET 2.0)

I want to embed the XML schema files into my DLL. However, this schema is
"split" in several files, i.e., they use xs:include. Note that the include is
relative and contains only the name of the file, i.e., the fragments are
supposed to be in the same directory.

For simplicity, suppose we have a main schema "a.xsd", which includes
"b.xsd" and "c.xsd".

In my code, I add the main schema (that includes all others) using:

xmlSettings.Schemas.Add(SCL2006_NAMESPACE, new
XmlTextReader(Assembly.GetExecutingAssembly().GetM anifestResourceStream("a.xsd"));

Now, when I open (validating) an instance file, using:
XmlReader.Create(new XmlTextReader(file, _nt), settings)

there is an exception saying that there is an undefined complex type. This
is because it did not read the included XSDs (b.xsd and c.xsd). How can I
ensure that it would do it?

I tried to solve the problem this way: I added to the xmlSettings.Schemas
all parts of the full schema, i.e, beside "a.xsd", "b.xsd" and "c.xsd".

Then, it works fine - up to a point. If the directory containing the
instance file contains as well one or all files constituting the schema, then
I get an exception that a simple type (from XSD "b.xsd") has already been
declared.

So it looks like it does process the schema files only when loading the
instance file, and looks for includes in the directory where the instance
file is. How can I avoid this behavior?

I've tried to add XmlSchema to the xmlSettings.Schemas, however this does
not solve the problem either...

Thanks for any help!


AFAIK, you can't do this. The files are embedded resources, how should
the XmlReader know where to look? A solution would be to extract the
resources and put them on the hard disk, process them and delete the
files afterwards.

HTH,
Andy
Jun 15 '06 #2

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
7
by: Chris | last post by:
Hi I am posting this on both the perl and python groups My intention is not to start a war or anything else, I would just like some pragmatic advice. My apologies to the python group I am...
0
by: Howard Lightstone | last post by:
I know I've seen this elsewhere but I can't seem to find the answer.... I have Python embedded in a Windows application. I want to debug the non- python part of the app without using the debug...
13
by: Alexander May | last post by:
Hi, I love Python! I've been using it for a couple of years now and have found it to be a highly productive language. I evangelize it to my developer friends and am probably responsible for...
0
by: newbie | last post by:
Hi all, I got a problem using the embedded python. I'll be appreciated if some one can show me the way. What i want is, 1.build a dll(test.dll/test.lib) which uses the embedded python, for...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
7
by: H. Williams | last post by:
I know the .Net Cursor class doesn't work with color cursors. So I'm currently using the LoadCursorFromFile API with reflection to set color cursors: here is my code: public static extern...
1
by: jmc | last post by:
The short version: Is there a way to get embedded styles to work on files that are displayed in a page using the shtml Include method? My work intranet site uses Front Page dynamic templates. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.