473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XmlResolver parameter entity problem

Trying to validate a document with a reference to a DTD ("PUBLIC"
identifier):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE systems-description PUBLIC "-//foo/nono" "">
....

The DTD uses some kind of parameter entity with a reference to an entity
file:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "">
%PTSD;

We have written an "XmlResolver" which translates our PUBLIC IDs to System
IDs (file URLs). Unfortunately, when trying to resolve the "PTSD" entity,
the .NET framwork provides a value of "" to the "relativeUri" parameter of
the "XmlResolver"-"ResolveUri" method (instead of "-//foo/myEntity").

We modified the parameter entity in the DTD the following way:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "ABC">
%PTSD;

and then received the value "ABC" for the "relativeUri" parameter. Seems as
if the framework always uses the SYSTEM identifier instead of the PUBLIC
identifier.

Resolving works fine when trying with a Java (Xerces) based solution.

What is going wrong here?

Thanks,
erwin

Nov 11 '05 #1
4 5289
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
--
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.
"Erwin Gabler" <E.******@EUnet.at> wrote in message
news:bn**********@paperboy.Austria.EU.net...
Trying to validate a document with a reference to a DTD ("PUBLIC"
identifier):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE systems-description PUBLIC "-//foo/nono" "">
...

The DTD uses some kind of parameter entity with a reference to an entity
file:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "">
%PTSD;

We have written an "XmlResolver" which translates our PUBLIC IDs to System
IDs (file URLs). Unfortunately, when trying to resolve the "PTSD" entity,
the .NET framwork provides a value of "" to the "relativeUri" parameter of
the "XmlResolver"-"ResolveUri" method (instead of "-//foo/myEntity").

We modified the parameter entity in the DTD the following way:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "ABC">
%PTSD;

and then received the value "ABC" for the "relativeUri" parameter. Seems as if the framework always uses the SYSTEM identifier instead of the PUBLIC
identifier.

Resolving works fine when trying with a Java (Xerces) based solution.

What is going wrong here?

Thanks,
erwin


Nov 11 '05 #2
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.
Nov 11 '05 #3
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

"Mark Fussell" <mf******@online.microsoft.com> schrieb im Newsbeitrag
news:lZ**************@cpmsftngxa06.phx.gbl...
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.

Nov 11 '05 #4
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

"SQL Server Development Team [MSFT]" <sq****@microsoft.com> schrieb im
Newsbeitrag news:OM**************@tk2msftngp13.phx.gbl...
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
--
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.
"Erwin Gabler" <E.******@EUnet.at> wrote in message
news:bn**********@paperboy.Austria.EU.net...
Trying to validate a document with a reference to a DTD ("PUBLIC"
identifier):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE systems-description PUBLIC "-//foo/nono" "">
...

The DTD uses some kind of parameter entity with a reference to an entity
file:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "">
%PTSD;

We have written an "XmlResolver" which translates our PUBLIC IDs to System IDs (file URLs). Unfortunately, when trying to resolve the "PTSD" entity, the .NET framwork provides a value of "" to the "relativeUri" parameter of the "XmlResolver"-"ResolveUri" method (instead of "-//foo/myEntity").

We modified the parameter entity in the DTD the following way:

<!ENTITY % PTSD PUBLIC "-//foo/myEntity" "ABC">
%PTSD;

and then received the value "ABC" for the "relativeUri" parameter. Seems

as
if the framework always uses the SYSTEM identifier instead of the PUBLIC
identifier.

Resolving works fine when trying with a Java (Xerces) based solution.

What is going wrong here?

Thanks,
erwin



Nov 11 '05 #5

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

Similar topics

1
by: David Madore | last post by:
Hi! Anyone in for a Byzantine discussion on XML well-formedness? Here's the situation: test.xml contains --- test.xml: cut after --- <?xml version="1.0" encoding="us-ascii"?> <!DOCTYPE...
7
by: Jos van Uden | last post by:
Can somebody explain why the following file has the wrong output: <?xml version="1.0" encoding="iso-8859-1"?> <test> <elem>‘bla bla bla’</elem> </test> Expected: ‘bla bla bla’ output: ?bla...
1
by: Ion Chalmers Freeman | last post by:
Um, I think XMLSPY is wrong about this, but it was surprising, so I wanted to check. my dtd has <!ENTITY % en "value"> and <!ATTLIST element attribute CDATA #FIXED "%en;"> so, when I generate...
12
by: Tjerk Wolterink | last post by:
In XHTML the entity nbsp stands for   A normal space like " " is also displayed as an normal space, but multiple spaces like " " are interpreted as 1 space in the xhtml page. So there comes...
1
by: Steven Simpson | last post by:
Hello, If an XML processor encounters a 'PEReference' in a 'markupdecl' (but not in 'EntityValue'), are there circumstances where it does not have to include it (i.e. use the replacement text...
1
by: Michael | last post by:
I am having a problem with scoping of parameters in my XSLT Stylesheet...here is the stylesheet (the xml document is irrelevant for the example) <?xml version="1.0" encoding="UTF-8"?>...
1
by: Chuck | last post by:
I am writing a database program in C#. I have a situation when I type the '(' after typing a method call, VS goes into an infinite loop. I then have to exit VS. Has anyone else had any trouble...
0
by: Frederico Guimar??es via DotNetMonster.com | last post by:
Hi, I'm trying to use the Microsoft.Web.Services2.Messaging. ISoapFormatter but I receive this error: System.Xml.XmlException: Reference to undeclared parameter entity, 'meetingmaker'. at...
3
by: Tuomas Rannikko | last post by:
Hello! I have a simple question about DTDs: Should this be possible? <!DOCTYPE root > In the XML specification I can't find the spot where it says this would be disallowed; however Xerces...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.