sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Nathan Alden's Avatar

XmlValidatingReader and xs:import support


Question posted by: Nathan Alden (Guest) on November 12th, 2005 05:08 AM
Hi all. I have an XML schema that has a couple of <xs:import> tags that
reference (using schemaLocation) schemas as embedded resources in a DLL. For
example:

<xs:import namespace=http://www.my.com/my.xsd
schemaLocation="res://assembly/?MyAssembly,MyAssembly.my.xsd"/>

I've attached a derived XmlResolver class called XmlResourceResolver to the
XmlTextReader that is reading this schema. I've loaded the schema itself
from an embedded resource just fine using the custom resolver. The problem
is it appears as though the resolver is not being called to resolve the
<xs:import> element. This is, of course, leading to a whole mess of "element
not declared" errors later on in the schema.

I read a post over at .NET 247 where a Microsoft support rep stated that a
problem appearing to be the same as this one is indeed a bug with .NET 1.1.
I was wondering if anyone else had either gotten this to successfully work
or is aware of exactly what the bug is.

Thanks,

Nate


3 Answers Posted
Zafar Abbas's Avatar
Guest - n/a Posts
#2: Re: XmlValidatingReader and xs:import support

Did you attach the resolver to the reader or schema collection?

"Nathan Alden" <a@a.com> wrote in message
news:OKEFEGpzFHA.2652@TK2MSFTNGP14.phx.gbl...[color=blue]
> Hi all. I have an XML schema that has a couple of <xs:import> tags that
> reference (using schemaLocation) schemas as embedded resources in a DLL.[/color]
For[color=blue]
> example:
>
> <xs:import namespace=http://www.my.com/my.xsd
> schemaLocation="res://assembly/?MyAssembly,MyAssembly.my.xsd"/>
>
> I've attached a derived XmlResolver class called XmlResourceResolver to[/color]
the[color=blue]
> XmlTextReader that is reading this schema. I've loaded the schema itself
> from an embedded resource just fine using the custom resolver. The problem
> is it appears as though the resolver is not being called to resolve the
> <xs:import> element. This is, of course, leading to a whole mess of[/color]
"element[color=blue]
> not declared" errors later on in the schema.
>
> I read a post over at .NET 247 where a Microsoft support rep stated that a
> problem appearing to be the same as this one is indeed a bug with .NET[/color]
1.1.[color=blue]
> I was wondering if anyone else had either gotten this to successfully work
> or is aware of exactly what the bug is.
>
> Thanks,
>
> Nate
>
>[/color]


Nathan Alden's Avatar
Guest - n/a Posts
#3: Re: XmlValidatingReader and xs:import support

As I stated in my post, I attached the resolver to the XmlTextReader object
I used to read the schema.

"Zafar Abbas" <someone@somewhere.com> wrote in message
news:O7i7193zFHA.2880@TK2MSFTNGP12.phx.gbl...[color=blue]
> Did you attach the resolver to the reader or schema collection?
>
> "Nathan Alden" <a@a.com> wrote in message
> news:OKEFEGpzFHA.2652@TK2MSFTNGP14.phx.gbl...[color=green]
>> Hi all. I have an XML schema that has a couple of <xs:import> tags that
>> reference (using schemaLocation) schemas as embedded resources in a DLL.[/color]
> For[color=green]
>> example:
>>
>> <xs:import namespace=http://www.my.com/my.xsd
>> schemaLocation="res://assembly/?MyAssembly,MyAssembly.my.xsd"/>
>>
>> I've attached a derived XmlResolver class called XmlResourceResolver to[/color]
> the[color=green]
>> XmlTextReader that is reading this schema. I've loaded the schema itself
>> from an embedded resource just fine using the custom resolver. The
>> problem
>> is it appears as though the resolver is not being called to resolve the
>> <xs:import> element. This is, of course, leading to a whole mess of[/color]
> "element[color=green]
>> not declared" errors later on in the schema.
>>
>> I read a post over at .NET 247 where a Microsoft support rep stated that
>> a
>> problem appearing to be the same as this one is indeed a bug with .NET[/color]
> 1.1.[color=green]
>> I was wondering if anyone else had either gotten this to successfully
>> work
>> or is aware of exactly what the bug is.
>>
>> Thanks,
>>
>> Nate
>>
>>[/color]
>
>[/color]


Zafar Abbas's Avatar
Guest - n/a Posts
#4: Re: XmlValidatingReader and xs:import support

You need to pass the resolver to the Compile method of XmlSchema. Attaching
a resolve to the XmlTextReader will not work since reading in the schema
does not resolve imports.

Zafar

"Nathan Alden" <visualcsharpcoder@hotmail.com> wrote in message
news:edhtk2M0FHA.164@TK2MSFTNGP10.phx.gbl...[color=blue]
> As I stated in my post, I attached the resolver to the XmlTextReader[/color]
object[color=blue]
> I used to read the schema.
>
> "Zafar Abbas" <someone@somewhere.com> wrote in message
> news:O7i7193zFHA.2880@TK2MSFTNGP12.phx.gbl...[color=green]
> > Did you attach the resolver to the reader or schema collection?
> >
> > "Nathan Alden" <a@a.com> wrote in message
> > news:OKEFEGpzFHA.2652@TK2MSFTNGP14.phx.gbl...[color=darkred]
> >> Hi all. I have an XML schema that has a couple of <xs:import> tags that
> >> reference (using schemaLocation) schemas as embedded resources in a[/color][/color][/color]
DLL.[color=blue][color=green]
> > For[color=darkred]
> >> example:
> >>
> >> <xs:import namespace=http://www.my.com/my.xsd
> >> schemaLocation="res://assembly/?MyAssembly,MyAssembly.my.xsd"/>
> >>
> >> I've attached a derived XmlResolver class called XmlResourceResolver to[/color]
> > the[color=darkred]
> >> XmlTextReader that is reading this schema. I've loaded the schema[/color][/color][/color]
itself[color=blue][color=green][color=darkred]
> >> from an embedded resource just fine using the custom resolver. The
> >> problem
> >> is it appears as though the resolver is not being called to resolve the
> >> <xs:import> element. This is, of course, leading to a whole mess of[/color]
> > "element[color=darkred]
> >> not declared" errors later on in the schema.
> >>
> >> I read a post over at .NET 247 where a Microsoft support rep stated[/color][/color][/color]
that[color=blue][color=green][color=darkred]
> >> a
> >> problem appearing to be the same as this one is indeed a bug with .NET[/color]
> > 1.1.[color=darkred]
> >> I was wondering if anyone else had either gotten this to successfully
> >> work
> >> or is aware of exactly what the bug is.
> >>
> >> Thanks,
> >>
> >> Nate
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


 
Not the answer you were looking for? Post your question . . .
196,842 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,842 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors