By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,724 Members | 863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,724 IT Pros & Developers. It's quick & easy.

Trying to validating XML against local copy of schema

P: n/a
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.xsd
- 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://internetLocation/Base_v1.4"
schemaLocation="http://internetLocation/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 XmlSchemaCollection 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 XmlSchemaCollection 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
Share this Question
Share on Google+
2 Replies


P: n/a

"Mike:o" <mo********@hotmail.com> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...

Is there a way that I can tell the XmlSchemaCollection 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 XmlSchemaCollection 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

P: n/a
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********@hotmail.com> wrote in message
news:OG**************@TK2MSFTNGP09.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.xsd
- 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://internetLocation/Base_v1.4"
schemaLocation="http://internetLocation/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 XmlSchemaCollection 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 XmlSchemaCollection 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 discussion thread is closed

Replies have been disabled for this discussion.