An Error Has Occurred While Opening External Dtd File
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up An error has occurred opening extern DTD (w3.org, xhtml1-transitional.dtd). 503 Server Unavailable up vote 10 down vote favorite 4 I'm trying to do xpath queries over an xhtml document. Using .NET 3.5. The document looks like this:
.... ... Because the document includes various char entities ( and so on), I need to use the DTD, in order to load it with an XmlReader. So my code looks like this: var s = File.OpenRead(fileToRead) var reader = XmlReader.Create(s, new XmlReaderSettings{ ProhibitDtd=false }); But when I run this, it returns An error has occurred while opening external DTD 'http://www.w3.org/TR/xhtml1-transitional.dtd': The remote server returned an error: (503) Server Unavailable. Now, I know why I am getting the 503 error. W3C explained it very clearly. I've seen "workarounds" where people just disable the DTD. This is what ProhibitDtd=true can do, and it eliminates the 503 error. But in my case that leads to other problems - the app doesn't get the entity defintions and so isn't well-formed XML. How can I validate with the DTD, and get the entity definitions, without hitting the w3.org website? I think .NET 4.0 has a nifty built-in capability to handle this situation: the XmlPreloadedResolver. But I need a solution for .NET 3.5. related: - java.io.IOException: Server returned HTTP response code: 503 .net xml xhtml w3c dtd share|improve this question edited Apr 1 '10 at 16:21 asked Apr 1 '10 at 3:49 Cheeso 115k60348569 add a comment| 3 Answers 3 active oldest votes up vote 7 down vote accepted The answer is, I have to provide my own XmlResolver. I don't think this is built-in to .NET 3.5. That's baffling. It's also baffling that it has taken me this long to stumble onto this problem. It's also baffling that I couldn't find someone else who solved this problem already? Ok, so.. the XmlResolver. I created a new class, derived from XmlResolver and over-rode three key things:+ Close submenu KudoZ help network ™ Answer questions Term search Ask question Leaders KudoZ glossaries GBK glossary Other terminology resources Glosspost Dictionaries & references Web term search Personal glossaries Learn more about: Terminology at ProZ.com Jobs & directories + Close submenu Directories Translators & interpreters Companies Blue Board Students Translation teams Translator organizations Search by name Advanced directory Search by email Job postings Browse jobs Order http://stackoverflow.com/questions/2558021/an-error-has-occurred-opening-extern-dtd-w3-org-xhtml1-transitional-dtd-503 translation Post a job Applications Learn more about: Jobs & directories at ProZ.com Member activities + Close submenu Community Forums Certified PRO Network Translation contests Quick polls Exchange Videos Translation news Professional guidelines Mentoring program Press releases Online and offline events In-person conferences Powwows Virtual conferences Calendar Learn more about:Member activities http://www.proz.com/forum/sdl_trados_support/272440-error_while_verifying_a_file_on_trados_2014.html and ProZ.com membership Education + Close submenu On-demand courses Self-paced training Videos One-on-one training References Scheduled courses Webinars In-person training Online training SDL Trados training Knowledgebase Translation industry reports Translation industry wiki Articles Books Scam alert center Trainers Create a course Manage a course About trainers Learn more about: Education at ProZ.com Tools + Close submenu ProZ.com tools TGB (Group buy) Service agreements Community rates Invoicing Unit converter Rate calculator Store Translation tools SDL TRADOS Wordfast memoQ CafeTran Espresso TO3000 Atril Dèjà STAR Transit Across Fluency Wordfinder PerfectIt consistency checker Software comparison tool Learn more about: Tools About + Close submenu Help & documentation Support center Site guidance center FAQ / site documentation ProZ.com basics Site rules Site status ProZ.com About ProZ.com ProZ.com membership ProZ.com Mobile Testimonials Newsletter archive Careers Localization Moderators Translator T.O. blog Hall of fame Privacy policy Technical forums » SDL Trados support » Error while verifyi
get tips & solutions from a community of 418,419 IT Pros & Developers. It's quick & easy. Parsing XHTML P: https://bytes.com/topic/net/answers/460629-parsing-xhtml n/a gizap I'm trying to parse an XHTML document like this: file.html:
Some text
with the following code: XmlReaderSettings xs = new XmlReaderSettings(); xs.ProhibitDtd = false; XmlReader reader = XmlReader.Create("file.html", xs); reader.MoveToContent(); The last line generates the following exception: an error An error has occurred while opening external DTD 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd': Unable to connect to the remote server There is no difference if I'm using XmlReader, XmlDocument.Load... There is no difference if I'm loading XML from file or from string... The following line: xs.ProhibitDtd = true; produces of course an exception: For security reasons DTD is prohibited in this XML document. To an error has enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method. Ok, but I need this DTD! :) How to do it? Feb 23 '06 #1 Post Reply Share this Question 1 Reply P: n/a Martin Honnen gi***@poczta.onet.pl wrote: I'm trying to parse an XHTML document like this: file.html:Some text
with the following code: XmlReaderSettings xs = new XmlReaderSettings(); xs.ProhibitDtd = false; XmlReader reader = XmlReader.Create("file.html", xs); reader.MoveToContent(); The last line generates the following exception: An error has occurred while opening external DTD 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd': Unable to connect to the remote server Works for me if I am connected to the internet. Are you connected? How? Is there any proxy used? Make sure there is no code setting the property xs.XmlResolver to null. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ Feb 23 '06 #2 This discussion thread is closed Start new discussion Replies have been disabled for this discussion. Similar topicwindow using JS andJQuery → DTD errors and XSLTTransformation January 5, 2011 Leave a comment When I happened to work on some XSLT trasformation recently. I planned to use a very simple code as below, XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = System.Net.CredentialCache.DefaultCredentials; XslCompiledTransform xslCompiledTransform = new XslCompiledTransform(); xslCompiledTransform.Load(XslFile, XsltSettings.Default, resolver); string HTMLFilePath = sourceXMLFile + ".htm"; xslCompiledTransform.Transform(sourceXMLFile, HTMLFilePath); I caught an XmlException that says, For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method. Okay, I used XMLReader and ProhibitDTD= false as it said. The code looked like this, XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = System.Net.CredentialCache.DefaultCredentials; XslCompiledTransform xslCompiledTransform = new XslCompiledTransform(); xslCompiledTransform.Load(XslFile, XsltSettings.Default, resolver); XmlReaderSettings settings = new XmlReaderSettings(); settings.ProhibitDtd = false; string HTMLFilePath = sourceXMLFile + ".htm"; xslCompiledTransform.Transform(reader, null, new StreamWriter(HTMLFilePath)); Now I ran into a differnet XmlException (this is better, some improvements:-)), An error has occurred while opening external DTD ‘http://example.url/example.dtd’: The remote server returned an error: (407) Proxy Authentication Required. Ouch.. ! What now, I was wodering what would solve this issue. I understood that this issue happens due to DTD url. During the transformation it tries to load this DTD from its Url. So I have to avoid resolving DTD url during the transformation. Hence i tried setting the reader XmlResolver to NULL. Wow… it worked. At last my code looked like this, //Transforming XML using XSL to HTML XmlUrlResolver resolver = new XmlUrlResolver(); resolver.Credentials = System.Net.CredentialCache.DefaultCredentials; // xsl template for transformation XslCompiledTransform xslCompiledTransform = new XslCompiledTransform(); xslCompiledTransform.Load(Xs