Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with XSD with includes as embedded resources

9 views
Skip to first unread message

Maggie

unread,
Mar 7, 2003, 7:19:59 PM3/7/03
to
I have xsd schemas that are embedded resources. The xsds have
includes. I have written a custom XmlResolver to find the includes. I
have tried loading the schema with an XmlReader and setting the
XmlResolver property on that, and loading the xml doc I want to
validate in an XmlValidatingReader and setting the XmlResolver
property on that, but no matter what I do the custom resolver does NOT
get used to resolve the include references. I have seen suggestions
dating from the Beta 1 or 2 time period saying the XmlSchema.Compile
method and the XmlSchemaCollection.Add method both will take an
XmlResolver, which they do not. What can I do????

Here is what I've tried (doesn't work):

//get the xsd stream from the assembly, where it is an embedded
resource
Assembly assembly = Assembly.GetExecutingAssembly();
System.IO.Stream = assembly.GetManifestResourceStream("MyNamespace.MyXsd.xsd");

//create a reader to read the schema, set the XmlResolver property
XmlValidatingReader schemaReader = new XmlValidatingReader(xsdStream,
XmlNodeType.Document, null);
//my custom resolver
XmlResolver resolver = new XmlEmbeddedResourceResolver();
schemaReader.XmlResolver = resolver;

//create the reader for the xml document
XmlValidatingReader reader = new XmlValidatingReader(xmlDoc,
XmlNodeType.Document, null);
reader.XmlResolver = resolver;
reader.ValidationType = ValidationType.Schema;

//here is where it all blows up because it can't resolve the
references to the
//included schemas. It doesn't even try to use my resolver (I set
breakpoints)
reader.Schemas.Add(null, schemaReader);

Please help!

Dare Obasanjo

unread,
Mar 10, 2003, 2:36:16 PM3/10/03
to
This is an oversight in version 1.0 of the .NET Framework which is fixed in
v1.1 . You can download the beta of v1.1 at
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/netdevfram
ework.asp

--
This post is provided "AS IS" with no warranties, and confers no rights.

"Maggie" <mag...@obscure.org> wrote in message
news:446c4a2d.03030...@posting.google.com...

0 new messages