473,546 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using XSD stored in assembly resource with includes

I am trying to validate an XML file against an XSD that is stored in the
assembly as an embedded resource. I can get it to work as long as the XSD
does not include other XSDs. After a fair amount of searching, I have found
3 possible solutions but none have worked for me. They are:

1. Use the Includes property of XmlSchema to add included XSDs, then call
Compile

XmlSchema mainSchema = XmlSchema.Read( stream1, null );
XmlSchema includeSchema1 = XmlSchema.Read( stream2, null );
XmlSchema includeSchema2 = XmlSchema.Read( stream3, null );

mainSchema.Incl udes.Add( includeSchema1 );
mainSchema.Incl udes.Add( includeSchema1 );
mainSchema.Comp ile( null );

I get a runtime exception from the Compile method: "Specified cast is not
valid"

Reference:
http://groups.google.com/groups?q=+....phx.gbl&rnum=1
2. Write a custom XmlResolver class

I derived directly from XmlResolver. In the GetEntity method, I read in
the resource stream based on the uri and return the stream. The type param
is always undefined so I am not sure what I should be returning, as the
return type is object. Should I return the stream, an XML fragement, a
string, etc.?

When I return a stream, it appears to be ignored by the main XSD file. I
get a runtime exception because elements are not declared (those that are
defined in the XSD includes).

Reference:
http://groups.google.com/groups?q=.n...ft.com&rnum=14

3. Use new XmlSchemaSet class in .Net 2.0

We are using v 1.1, so this method is not available to us.

Reference:
http://groups.google.com/groups?q=+....phx.gbl&rnum=1

I know that my XSD files (resources) are correct, because if I specify the
name of the XSD file as the URL param in XmlValidatingRe ader.Schemas.Ad d, it
works fine.

Does anyone know the correct way to load XML Schemas from an embedded
resource with includes?

Thanks,

-Dave Muoio
Nov 12 '05 #1
2 7659
"David Muoio" <da********@ixi o.com> wrote in message
news:OH******** ******@TK2MSFTN GP15.phx.gbl...
I am trying to validate an XML file against an XSD that is stored in the
assembly as an embedded resource. I can get it to work as long as the XSD
does not include other XSDs. : : 2. Write a custom XmlResolver class
Writing an XmlResolver to load them from embedded resources is definately
the way to go in .NET 1.1, IMO.
Does anyone know the correct way to load XML Schemas from an embedded
resource with includes?
Mark Fussell, a PM on the XML Technologies team at Microsoft, wrote the
following MSDN article that describes how to write an XmlResolver for
loading documents from embedded resources,

http://msdn.microsoft.com/library/en.../cusxmlres.asp
I am not sure what I should be returning, as the return type is object.
Should I return the stream, an XML fragement, a string, etc.?


GetEntity( ) should return the Stream.
Derek Harmon
Nov 12 '05 #2
I now have it working with a custom XmlResolver. My original problem with
this method was due to a bug on my part. Just knowing that writing an
XmlResolver is the method of choice, helped me track it down.

Thanks Derek,

-Dave Muoio

"Derek Harmon" <lo*******@msn. com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"David Muoio" <da********@ixi o.com> wrote in message
news:OH******** ******@TK2MSFTN GP15.phx.gbl...
I am trying to validate an XML file against an XSD that is stored in the
assembly as an embedded resource. I can get it to work as long as the
XSD does not include other XSDs.

: :
2. Write a custom XmlResolver class


Writing an XmlResolver to load them from embedded resources is definately
the way to go in .NET 1.1, IMO.
Does anyone know the correct way to load XML Schemas from an embedded
resource with includes?


Mark Fussell, a PM on the XML Technologies team at Microsoft, wrote the
following MSDN article that describes how to write an XmlResolver for
loading documents from embedded resources,

http://msdn.microsoft.com/library/en.../cusxmlres.asp
I am not sure what I should be returning, as the return type is object.
Should I return the stream, an XML fragement, a string, etc.?


GetEntity( ) should return the Stream.
Derek Harmon

Nov 12 '05 #3

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

Similar topics

0
4697
by: Ben Jones | last post by:
Hi there, I am looking into the ease of implementing the localization/globalization features of .NET using C#. I have a test app which creates a ResourceManager and attempts to load a resource for a specified culture. I created the WinForm application in Visual Studio and added a default *fallback* resource to the main assembly. When I...
1
2316
by: Bilal Farooq via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Bilal Farooq Hi, I have following requirements to achieve: I have some images andI am adding them as a resource to a dll. This dll is then to beused for getting those images by the other clients. Now to do so first I generated a .resx file which includes allthese images in...
12
2036
by: bj7lewis | last post by:
I am working on a project I want to add a few files as resource to access(copy them to FS and use) at runtime. So far in VS.NET IDE, I Add Files to the project and set its Build Action to Embedded Resource... Now where should look next... Any help...
3
10619
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and crackling. I'm using a couple WAVs that ship with Windows, and they play fine outside of my app. This code works, but has the random "scratching" problem: private static void PlayResource(string...
1
11109
by: Screenbert | last post by:
After finding nothing anywhere in google I am posting this so everyone can benefit by it. The formating is not pretty since I copied it from my word document, but you should benefit by it. Managing DHCP Servers using C# They said it was impossible. It couldn't be done. But you can in fact manage DHCP servers using C#. This includes...
0
12323
by: screenbert | last post by:
Managing DHCP Servers using C# They said it was impossible. It couldn't be done. But you can in fact manage DHCP servers using C#. This includes creating and deleting Scopes, SuperScopes, Reservations, Exclusions, Options and so forth. Since the dll that is used was written several years ago by Microsoft, you cannot manage things on the DNS...
5
3081
by: Mukesh | last post by:
Hi i want to use AJAX.net in my Existing Application I have already installed the ajax .net ..net 3.0 and using VS 2005 in the old application i have added a new web form then script manager and then update panel and some control in it to test it. When i run the programme ir does not work . imean ajax does not works
0
1252
by: =?Utf-8?B?cHJhc2hhbnQga3VtYXIgc3JpdmFzdGF2YQ==?= | last post by:
Hi all, I m using asp.net 2.0 version and want to retrieve the particular string from resource file dynamically... Following is the my code ... but in this every time I get exception that resource key not found... ... might be possible as i think that resource file which is being loaded is not fund ... plz suggest me how to find the base...
0
1155
by: =?Utf-8?B?cHJhc2hhbnQga3VtYXIgc3JpdmFzdGF2YQ==?= | last post by:
Hi all, I m using asp.net 2.0 version and want to retrieve the particular string from resource file dynamically... Following is the my code ... but in this every time I get exception that resource key not found... ... might be possible as i think that resource file which is being loaded is not fund ... plz suggest me how to find the base...
0
7435
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...
0
7698
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. ...
0
7947
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...
1
7461
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...
1
5361
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3492
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...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
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...

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.