Hi Erwin,
In the current implementation the public identifier is not used when
resolving
an external identifier. Although this is an optional feature according to
the
XML 1.0 specification, I can see how this is useful for your application. I
opened a customer change request to be addressed in the next release.
Unfortunately there are no workarounds in this case short of using the
system
identifiers instead of the public identifiers given that you're already
overriding
the resolution of the external identifiers. Regards,
Ion Vasilian

Signature
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
> Trying to validate a document with a reference to a DTD ("PUBLIC"
> identifier):
[quoted text clipped - 29 lines]
> Thanks,
> erwin
Mark Fussell - 20 Oct 2003 21:36 GMT
There is a workaround that I have used in the past if you know what your
PUBLIC identier is at resolution time, by throwing an exception. Here is
the example I ran into when using a DTD for RSS 0.91 validation. You can
get this DTD from the URL below.
I had a DTD file that contained PublicId of "-//Netscape
Communications//DTD RSS 0.91//EN" which is *not* resolvable and local copy
of the same DTD with the SystemId of "c:\samplefiles\rss-0.91.dtd" which
can be resolved. e.g.
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"c:\samplefiles\rss-0.91.dtd">
In the the GetEntity method you cannot tell when the SystemId is being
resolved as opposed to the PublicId. Hence you have to look at the supplied
string
and throw an exception to force PublicID not be passed to the GetEntity()
method, which is then called again to resolve the SYSTEMID.
So the (unfortunate) workaround is to throw an exception when resolving a
known PUBLICID e.g.
public override Uri ResolveUri(Uri baseUri, String relativeUri)
{
// check the PublicID value of the DTD and do not resolve
// Throwing exception causes the SystemID to be resolved instead
if (relativeUri == "-//Netscape Communications//DTD RSS 0.91//EN")
throw new XmlException(" Do not resolved PublicID for -//Netscape
Communications//DTD RSS
0.91//EN", null);
Hope this helps.
Mark Fussell
Program Manager - System.Xml
This posting is provided "AS IS" with no warranties, and confers no rights.
Erwin Gabler - 21 Oct 2003 06:26 GMT
Thank you for the hint. Unfortunately my problem works the other way round.
The framework provides me with the SYSTEMID when I need the PUBLICID.
erwin
> There is a workaround that I have used in the past if you know what your
> PUBLIC identier is at resolution time, by throwing an exception. Here is
[quoted text clipped - 33 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Erwin Gabler - 21 Oct 2003 06:31 GMT
OK, thank you for the information.
In my current situation the only reason for reading the DTD and entities is,
that XML loading does not work when a document contains entity references
that cannot be resolved. If would be sufficient if the framework produced
"EntityReference" nodes in the loaded "XmlDocument".
Any way to work around this restriction?
Regards,
erwin
> Hi Erwin,
>
[quoted text clipped - 49 lines]
> > Thanks,
> > erwin
SQL Server Development Team [MSFT] - 21 Oct 2003 22:10 GMT
Hi Erwin,
If you can live without validation and provided that the external entities
in question do not affect the infoset, then turning off validation on the
XmlValidatingReader plus resolving all externals to empty streams will do
just what you're asking for. This simulates a non-validating processor with
external entity resolution disabled. The feasibility of the workaround
depends on the class of documents used by your application. Regards,
Ion Vasilian

Signature
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
> OK, thank you for the information.
>
[quoted text clipped - 66 lines]
> > > Thanks,
> > > erwin
Chris Lovett - 22 Oct 2003 07:54 GMT
and you may also need to set EntityHandling to
EntityHandling.ExpandCharEntities
so that if the document is trying to use entities defined in the external
fragments that you bypassed using your resolver then the reader will simply
return entity reference nodes in the document, otherwise it will report
undefined entity errors.
> Hi Erwin,
>
[quoted text clipped - 83 lines]
> > > > Thanks,
> > > > erwin
Erwin Gabler - 23 Oct 2003 06:32 GMT
Sorry, that does not work. XmlDocument.Load produces an exception when
document contains an unresolvable entity.
"EntityHandling.ExpandCharEntities" does not change the behaviour.
Regards,
erwin
> and you may also need to set EntityHandling to
> EntityHandling.ExpandCharEntities
[quoted text clipped - 102 lines]
> > > > > Thanks,
> > > > > erwin