473,888 Members | 1,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suppressing DTD look-up via web access when loading XmlDocument

Hi

In one of our test suites we load an xml document (it's actually .svg).
I'm trying to find some way of stopping the eventual call to
HttpWebRequest. GetResponse which I presume it's doing when going to get
the DTD at "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd".
The result is a time-out because this machine is isolated from the
database, the web, everything really :-)

I tried to pass XmlDocument a non-validating reader e.g. XmlTextReader
but the web request was still attempted. I also set its XmlResolver to
null but to no avail.

Would anyone be able to advise me on how to solve this problem? MSDN
seems to suggest the approaches I've already tried so now I'm a little
stuck!

Thanks very much,

Emma.

Nov 23 '05 #1
7 1732
I still am looking for a solution if anyone would be kind enough to
help.

Thanks

Emma

em************* *@fastmail.fm wrote:
Hi

In one of our test suites we load an xml document (it's actually .svg).
I'm trying to find some way of stopping the eventual call to
HttpWebRequest. GetResponse which I presume it's doing when going to get
the DTD at "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd".
The result is a time-out because this machine is isolated from the
database, the web, everything really :-)

I tried to pass XmlDocument a non-validating reader e.g. XmlTextReader
but the web request was still attempted. I also set its XmlResolver to
null but to no avail.

Would anyone be able to advise me on how to solve this problem? MSDN
seems to suggest the approaches I've already tried so now I'm a little
stuck!

Thanks very much,

Emma.


Nov 26 '05 #2
Hi,
I also set its XmlResolver to
null but to no avail.

I am afraid you have to implement your own resolver.

The dtd is on w3c site at http://www.w3.org/TR/SVG11/svgdtd.html. Try
downloading it at
http://www.w3.org/Graphics/SVG/1.1/D...t-20030114.dtd and save
it to your local machine.

To instruct .net to look for the dtd file on local disk, define your
resolver:

public class MyResolver : XmlUrlResolver
{
public override Uri ResolveUri(Uri baseUri, string relativeUri)
{
// you could check for equality instead of ending with
if (relativeUri.To Upper().EndsWit h(".DTD"))
{
return new Uri("relative/absolute path to DTD on local");
}

return base.ResolveUri (baseUri, relativeUri);
}
}

Use the resolver with XmlDocument and/or XmlReader. Example:

XmlDocument doc = new XmlDocument();
doc.XmlResolver = new MyResolver();
doc.Load("sampl e.svg");

Hope it helps,
Thi
http://thith.blogspot.com

Nov 28 '05 #3
Truong Hong Thi wrote:
Hi,
I also set its XmlResolver to
null but to no avail.

I am afraid you have to implement your own resolver.

The dtd is on w3c site at http://www.w3.org/TR/SVG11/svgdtd.html. Try
downloading it at
http://www.w3.org/Graphics/SVG/1.1/D...t-20030114.dtd and save
it to your local machine.

To instruct .net to look for the dtd file on local disk, define your
resolver:

public class MyResolver : XmlUrlResolver
{
public override Uri ResolveUri(Uri baseUri, string relativeUri)
{
// you could check for equality instead of ending with
if (relativeUri.To Upper().EndsWit h(".DTD"))
{
return new Uri("relative/absolute path to DTD on local");
}

return base.ResolveUri (baseUri, relativeUri);
}
}

Use the resolver with XmlDocument and/or XmlReader. Example:

XmlDocument doc = new XmlDocument();
doc.XmlResolver = new MyResolver();
doc.Load("sampl e.svg");

Hope it helps,
Thi
http://thith.blogspot.com


Thanks Truong for your reply.

I will give your suggestion a go once I get into work (although you
will agree that this shouldn't be the only way to do this - something
simpler surely?!).

In fact, encouraged by your reply, I have had just had another look
through the documentation and I think XmlNodeReader might be the most
basic class to use so will try that too.

Good luck with your new blog!

Does anyone else find the XmlTextReader documentation confusing -
here's a little synopsis below. Am I the only one who is confused when
reading it?

XmlTextReader documentation ...

First of all it says:

1. "XmlTextRea der checks the DTD for well-formedness, but does not
validate using the DTD."

then it says:

2. "DTD processing is enabled by default. ... Set the ProhibitDtd
property to true to disable DTD processing." (This is new in 2.0.)

then it says:

3. "XML data can include references to external resources such as a DTD
file. By default external resources are resolved using an
XmlUrlResolver object."

then it says:

4. "Do not allow the XmlReader to open any external resources by
setting the XmlResolver property to a null reference."

So I thought if it wasn't going to use the DTD (point 1) then it
shouldn't need to use its XmlUrlResolver to go and get it. So why does
it?

Point 2 seems to suggest that there is a difference between processing
a DTD and actually using it to validate something: well what's the
point in processing it if it's not going to be using it to validate
something?!

Point 3 is fair enough but point 4 is not true; the request is still
made for the DTD.

Moan over.

Emma

Nov 28 '05 #4
> In fact, encouraged by your reply, I have had just had another look
through the documentation and I think XmlNodeReader might be the most
basic class to use so will try that too.


However a further look shows that I'm in a catch-22 situation! To use
an XmlNodeReader one has to first have an XmlNode and I wonder how we
get one of those! :-)

Nov 28 '05 #5
> However a further look shows that I'm in a catch-22 situation! To use
an XmlNodeReader one has to first have an XmlNode and I wonder how we
get one of those! :-)


And now time to declare that:

i.e. point 4 was correct after all: before, I was setting the
XmlDocument's XmlResolver to null not the XmlTextReader's XmlResolver.

And, if I'd searched properly, I would have found this post mentioning
that solution and Truong's solution as well!

Problem solved!

Emma

PS I still think the docs on XmlTextReader are a little misleading (but
then, so was my post!) :-)

Nov 28 '05 #6
Not that anyone's reading, but I meant, this post:

http://groups.google.co.uk/group/mic...c99a4917a3c416

Emma

Nov 28 '05 #7
Well let me just say that its unique.

----------------------------------
http://community.ihostasp.net
ASP.NET Developer Community
Nov 30 '05 #8

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

Similar topics

5
9838
by: Phil Powell | last post by:
How do I suppress the lines PHP normally delivers to stdout (your browser) if I am doing command-line PHP? e.g. stuff.php: <? echo 'Hello World'; ?> Calling it from a Red Hat 7.3 command-line terminal I would do the
3
5150
by: inhahe | last post by:
Hi i'm a newbie at this and probably always will be, so don't be surprised if I don't know what i'm talking about. but I don't understand why regex look-behinds (and look-aheads) have to be fixed-width patterns. i'm getting the impression that it's supposed to make searching exponentially slower otherwise but i just don't see how.
2
5490
by: Paul Thompson | last post by:
Can I use JavaScript in some way to entirely suppress and control the tab key, so that I perform all functions that tab performs? I can detect the tab key, but can't seem to eliminate it.
7
1323
by: Kenneth P | last post by:
Hi, I've seen many Internet sites that suppress the URL or show the same URL all the time your moving around different pages. You'll only see the real page with it's path in the statusbar way down on the page. How is that done in asp.net? I have an example on this, in sweden, stockholm where I live we have a wellknown kindergarten for older men (warehouse shop) named Clas Ohlson
1
1938
by: Shell | last post by:
Hi, I have an application written in ASP.NET 2.0, I would like it's GUI especially the webpart to look like windows xp like transparent look or 3D look. I have looked at option of Borderstyle but it only enhances textare in the control and not the whole control. Can anyone throw some more light on how could I make my Datagrid and WebParts look like Win XP or 3D look? Thanks,
3
2382
by: b747_440 | last post by:
Hello Newsgroup, I try to resize and move a picturebox. However, after each operation the picture box is being redrawn. This causes flickering. Is it possible to suppress the first redraw and draw both operations at once after they have been completed? I have tried overriding OnPaint, OnBackgroundErase, etc. Double Buffering, AllPaintingInWmPaint, etc. has been set to true. No success so far. Now I'm trying to catch Windows Messages like...
20
2232
by: Maurice | last post by:
Hi all, I have an application, designed in Visual Studio 2005, which will run mainly on Windows XP computers. If I run the application on a Windows XP computer having the Windows XP Theme selected the controls look nice rounded, etc. just like in Windows XP. But if I run the application on a Windows XP computer having the Windows
6
2428
by: Michael B Allen | last post by:
Hi, I have a macro that looks like the following: #define MMSG msgno_loc0(LOC0, LOC1) && msgno_mmsg0 which if used in some code like: MMSG("foo=%s", foo);
5
2486
by: Don Li | last post by:
Hi, A web app server package that I'm using includes a bunch of open source UI components (heavy with javascripts). Inevitably it has bugs, e.g. "undefined" is null or not an object. This naturally erodes confidence for novice web users for the app in question. The techniques that I found and tried after research for suppressing
2
1718
by: puzzled | last post by:
I have "Find" buttons throughout my database, each with focus on a different field (they were created with the wizard, then the focus set to the corresponding field with VB). If i press a find button and change the "Look In" combo to search the form instead of a field, the next "find" button i press defaults to 'Look In' the form, not the field that should have focus. The field that should have focus is available to select in the "Look In" combo...
0
10777
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10882
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10438
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5817
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4243
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3251
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.