473,725 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to validating XML against local copy of schema

I need to validate XML documents (orders) against their schema before
processing. The PurchaseOrder schema that we use references 3 other schemas
using the <imports ...> element. Here is the relationship:
- PurchaseOrder.x sd
- Base.xsd
- Item.xsd
- Party.xsd

These schemas are all located at a public Internet location. The imports
elements within the PurchaseOrder schema look like this:
<import namespace="http ://internetLocatio n/Base_v1.4"
schemaLocation= "http://internetLocatio n/Base_v1.4.xsd"/>

I can validate against the PurchaseOrder schema if I use it (and the
referenced schemas) from the Internet. What I'm trying to do, however, is
periodically download the schemas to a local folder and validate against the
local copies instead. I'm doing this so that I can continue to process
orders even if the Internet repository is unavailable for some reason.

My problem is that, when I attempt to add the local copy of the
PurchaseOrder schema to an XmlSchemaCollec tion it errors out because of the
Internet address in the schemaLocation attribute of the import elements (see
above example). If I modify the local copy of the PurchaseOrder schema to
remove that Internet address (for example: schemaLocation= "Base_v1.4. xsd" )
everything works fine (as long as all 4 schemas are in the same folder), but
I really don't want to have to modify the schemas when I make local copies
of them.

Is there a way that I can tell the XmlSchemaCollec tion to use local copies
of the referenced schemas when it reads the imported schemas instead of
trying to use the Internet addresses?

Any assistance would be greatly appreciated!

Mike:o
Nov 12 '05 #1
2 3575

"Mike:o" <mo********@hot mail.com> wrote in message
news:OG******** ******@TK2MSFTN GP09.phx.gbl...

Is there a way that I can tell the XmlSchemaCollec tion to use local copies
of the referenced schemas when it reads the imported schemas instead of
trying to use the Internet addresses?


There is no way to tell the XmlSchemaCollec tion to ignore schema locations
without removing them from the schema.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 12 '05 #2
I havent really played with this, but how about using your own custom
XmlResolver class and faking the resolution to that address to point to the
local file?

-Amol

"Mike:o" <mo********@hot mail.com> wrote in message
news:OG******** ******@TK2MSFTN GP09.phx.gbl...
I need to validate XML documents (orders) against their schema before
processing. The PurchaseOrder schema that we use references 3 other schemas using the <imports ...> element. Here is the relationship:
- PurchaseOrder.x sd
- Base.xsd
- Item.xsd
- Party.xsd

These schemas are all located at a public Internet location. The imports
elements within the PurchaseOrder schema look like this:
<import namespace="http ://internetLocatio n/Base_v1.4"
schemaLocation= "http://internetLocatio n/Base_v1.4.xsd"/>

I can validate against the PurchaseOrder schema if I use it (and the
referenced schemas) from the Internet. What I'm trying to do, however, is
periodically download the schemas to a local folder and validate against the local copies instead. I'm doing this so that I can continue to process
orders even if the Internet repository is unavailable for some reason.

My problem is that, when I attempt to add the local copy of the
PurchaseOrder schema to an XmlSchemaCollec tion it errors out because of the Internet address in the schemaLocation attribute of the import elements (see above example). If I modify the local copy of the PurchaseOrder schema to
remove that Internet address (for example: schemaLocation= "Base_v1.4. xsd" ) everything works fine (as long as all 4 schemas are in the same folder), but I really don't want to have to modify the schemas when I make local copies
of them.

Is there a way that I can tell the XmlSchemaCollec tion to use local copies
of the referenced schemas when it reads the imported schemas instead of
trying to use the Internet addresses?

Any assistance would be greatly appreciated!

Mike:o

Nov 12 '05 #3

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

Similar topics

2
3622
by: Will | last post by:
I have been having problems validating an XForms document against the XForms schema located at http://www.w3.org/MarkUp/Forms/2002/XForms-Schema.xsd. I have reduced the XForm to its bare bones as follows: <?xml version="1.0" encoding="iso-8859-1"?> <xf:model xmlns:xf="http://www.w3.org/2002/xforms"> <xf:instance xmlns=""/> </xf:model>
4
3091
by: billcoumbe | last post by:
any recommendations? I'm looking for something that will just run from the unix command line to validate large (20-50Mb) XML files against an XML DTD. Ideally something that is actively supported and has good documentation! If there's nothing suitable for Solaris a command line program for Windows might do - currently using XMetaL/XMLSpy parsers which aren't really suited to large files.
1
1446
by: Ron Rohrssen | last post by:
I've been working on learning XML schemas and trying to make use of the MS classes for validating data against a schema. So, I've been trying to work through some simple schemas and instances. But, the parser inside of Visual Studio seems to frequently validate against a cached version of the schema. Occassionally I have an XML file that won't validate
6
2427
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting is not absolutely wonderful. So what I want to do is to validate it before I upload it. When I try and do this I get MILLIONS of errors (well lots) complaining about elements like ROOT which are part of the
1
4335
by: Christian | last post by:
Hi, I load an Xml-file "customers.xml" into a DataSet (works fine) but then how do I validate it against a schema (e.g. customers.xsd) ? my customers.xml: <?xml version="1.0" encoding="utf-8"?>| <customers xmlns="http://tempuri.org/customers.xsd"> <Customer ID="1000"> <FirstName>Greg</FirstName>
3
6058
by: Shailendra Batham | last post by:
hi guys I need your suggestions / opinion for doing this the right way. I have a XML and a Schema for the same What I want is when its validated against the schema, it should give custom errors saying what happened and where...... is it possible to do that ? for eg. if the Attribute is missing or invalid in the following element <Watch ID="999d999">
1
4244
by: Craig Beuker | last post by:
Hello, I am experimenting with this XmlValidatingReader and have a question about how it is working (or not working as would be the case) The sample documents and code are included at the end of the post. I am using VS.net 2003, .Net 1.1, Win2k Server I have a simple schema and a simple XML document.
7
4242
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I wrote a method to validate and xml file against a schema. If the file does not conform to the schema, it throws an error. It works fine except for one curious thing. If I try to validate an XDocument (containing schema xml) against a schema url, it validates successfully..... Has anyone ever seen this before or know why it does this. Here is the code:
4
5743
by: agda.karlberg | last post by:
Hello, I need to remove the DTD reference from an xml document, the reason for this is that we want to validate against a schema instead (which we have locally). It takes up to a minute to fetch all documents referred to in the DTD, and as we have no use for them I want to remove the reference. I'm using XmlReaderSettings to pass in the xml document and the schema, but when I loop through the reader it goes and tries to get
0
8752
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
9401
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
9257
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
9174
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,...
1
6702
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
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
4517
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
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
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.