473,387 Members | 1,650 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,387 software developers and data experts.

network error during dtd validation

I'm getting weird errors during transformations --
"System.Net.WebException. The remote server returned an error: (500)
Internal Server Error."

I'm on the 1.0 Framework. I've looked through the stack trace and it seems
to be happending at a call to .Transform as follows (see stack trace below):
oXslTransform.Transform(myXPathDocument,plist,stWr ite);

These XML documents are 3rd party and include a doctype that refers to a dtd
across the network. I'm also getting these sometimes in IE, so it seems
that the vendors DTD is timing out. Is there anyway to disable the
validation of the document, so it doesn't try to call out to the DTD?

Thanks,
Galen

Here's a part of the stack trace:
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofObjectToReturn)
at System.Xml.Schema.DtdParser.ParseDocTypeDecl()
at System.Xml.Schema.DtdParser.Parse()
at System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner)
at System.Xml.XmlTextReader.ParseTag()
at System.Xml.XmlTextReader.ParseRoot()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlValidatingReader.ReadWithCollectText Token()
at System.Xml.XmlValidatingReader.Read()
at System.Xml.XPath.XPathDocument.ReadChildNodes(XPat hContainer parent,
String parentBaseUri, XmlReader reader, PositionInfo positionInfo)
at System.Xml.XPath.XPathDocument.Load(XmlReader reader)
at System.Xml.XPath.XPathDocument.Init(XmlReader reader)
at System.Xml.XPath.XPathDocument..ctor(TextReader reader)

Nov 11 '05 #1
5 4279
Galen Harris wrote:
I'm getting weird errors during transformations --
"System.Net.WebException. The remote server returned an error: (500)
Internal Server Error."

I'm on the 1.0 Framework. I've looked through the stack trace and it seems
to be happending at a call to .Transform as follows (see stack trace below):
oXslTransform.Transform(myXPathDocument,plist,stWr ite);

These XML documents are 3rd party and include a doctype that refers to a dtd
across the network. I'm also getting these sometimes in IE, so it seems
that the vendors DTD is timing out. Is there anyway to disable the
validation of the document, so it doesn't try to call out to the DTD?


In your scenario XML document is not validated actually. DTD is not only about
validation and XPathDocument class has additional requirements about entities
expansion etc, so I don't think it's good idea (if it's feasible at all) to
disable the above behaviour. Instead you can have local version of the DTD in
a file and just to redirect reader to it instead of remote version. Here is
small example:

static void Main(string[] args) {
string xml =
@"<!DOCTYPE root SYSTEM ""http://nowhere.com/my.dtd"">
<root>
<foo/>
<bar/>
</root>";
XmlReader reader = new XmlTextReader(new StringReader(xml));

XmlValidatingReader vr = new XmlValidatingReader(reader);
vr.XmlResolver = new MyResolver();
vr.ValidationType = ValidationType.None;
XPathDocument doc = new XPathDocument(vr);
...
}

public class MyResolver : XmlUrlResolver {
public override object GetEntity(Uri absoluteUri, string role, Type
ofObjectToReturn) {
if (absoluteUri.AbsoluteUri.StartsWith("http://nowhere.com"))
return File.OpenRead(@"c:\local.dtd");
else
return null;
}
}

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
thanks for the response.

what would you suggest, if the xml documents were 3rd party, and i couldn't
edit their contents to change the reference to a local copy of the DTD?
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Galen Harris wrote:
I'm getting weird errors during transformations --
"System.Net.WebException. The remote server returned an error: (500)
Internal Server Error."

I'm on the 1.0 Framework. I've looked through the stack trace and it seems to be happending at a call to .Transform as follows (see stack trace below): oXslTransform.Transform(myXPathDocument,plist,stWr ite);

These XML documents are 3rd party and include a doctype that refers to a dtd across the network. I'm also getting these sometimes in IE, so it seems
that the vendors DTD is timing out. Is there anyway to disable the
validation of the document, so it doesn't try to call out to the DTD?
In your scenario XML document is not validated actually. DTD is not only

about validation and XPathDocument class has additional requirements about entities expansion etc, so I don't think it's good idea (if it's feasible at all) to disable the above behaviour. Instead you can have local version of the DTD in a file and just to redirect reader to it instead of remote version. Here is small example:

static void Main(string[] args) {
string xml =
@"<!DOCTYPE root SYSTEM ""http://nowhere.com/my.dtd"">
<root>
<foo/>
<bar/>
</root>";
XmlReader reader = new XmlTextReader(new StringReader(xml));

XmlValidatingReader vr = new XmlValidatingReader(reader);
vr.XmlResolver = new MyResolver();
vr.ValidationType = ValidationType.None;
XPathDocument doc = new XPathDocument(vr);
...
}

public class MyResolver : XmlUrlResolver {
public override object GetEntity(Uri absoluteUri, string role, Type
ofObjectToReturn) {
if (absoluteUri.AbsoluteUri.StartsWith("http://nowhere.com"))
return File.OpenRead(@"c:\local.dtd");
else
return null;
}
}

--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3
Galen Harris wrote:
thanks for the response.

what would you suggest, if the xml documents were 3rd party, and i couldn't
edit their contents to change the reference to a local copy of the DTD?


Sorry, but you don't have to edit their content! Reread my post, the
whole idea is just to redirect the XML reader to local copy of DTD
instead on remote one, based on DTD URL.
It's well known and well proven technology (derived from SGML catalogs
and XCatalogs), it's standard when working with big DTDs like Docbook DTD.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4
went back and looked at your posting again. i tried it, and it works great.
also, i noticed that i could set the XMLResolver property to null, and that
did the trick as well. i guess this would be easier in cases where i didn't
need anything from the DTD.

thanks for your help!
Nov 11 '05 #5
went back and looked at your posting again. i tried it, and it works great.
also, i noticed that i could set the XMLResolver property to null, and that
did the trick as well. i guess this would be easier in cases where i didn't
need anything from the DTD.

thanks for your help!
Nov 11 '05 #6

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

Similar topics

2
by: SteveS | last post by:
Hello all. This problem is stumping me.... I run a page called "default.aspx". For some reason when I execute this page, I get the error below. It seems to run through the entire code behind...
11
by: TheBurgerMan | last post by:
Hi all. I am using W2K3, .NET2 on a machine running AD and Exchange. I started getting the message below last week. I googled the error and not much was returned, but I did find this;...
0
by: info | last post by:
Hi, Is it possible to include in the Schema validation file, every custom error message for each validation rules? This mean, in the same xsd file we can have the validation rules (patterns)...
2
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application....
1
by: Nathan Sokalski | last post by:
When I click after about 15 minutes on a page I wrote I recieve the following error: Server Error in '/' Application....
0
by: johnkamal | last post by:
Hi, Some times while opening a page, I am getting the following error message, Please help me to rectify the problem. Server Error in '/' Application. General network error. Check your...
6
by: =?Utf-8?B?VGlt?= | last post by:
I have an app that calls a webmethod. Everything works fine except when you, the client, loses network connectivity during the request. When the connection is lost the client applications hangs. ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.