HighTechTalks DotNet Forums  

CreateDocumentType file not found

Dotnet XML microsoft.public.dotnet.xml


Discuss CreateDocumentType file not found in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Sergei Shelukhin
 
Posts: n/a

Default CreateDocumentType file not found - 10-27-2007 , 10:18 PM






Hi. I need to write xml export that will be used by another
application. That application requires that I add a doctype
delcaration to the document, referencing a certain dtd file. I do not
have the file, and don't really need the declaration myself, it will
be used when the document is read I suppose; how do I get around
"Couldn't find file" excepption thrown by CreateDocumentType?

So far I resorted to building the document without doctype, copying it
to string and injecting the declaration string into it; is there a way
to avoid this?


Reply With Quote
  #2  
Old   
Oleg Tkachenko [MVP]
 
Posts: n/a

Default Re: CreateDocumentType file not found - 10-28-2007 , 06:00 AM






Sergei Shelukhin wrote:
Quote:
Hi. I need to write xml export that will be used by another
application. That application requires that I add a doctype
delcaration to the document, referencing a certain dtd file. I do not
have the file, and don't really need the declaration myself, it will
be used when the document is read I suppose; how do I get around
"Couldn't find file" excepption thrown by CreateDocumentType?

So far I resorted to building the document without doctype, copying it
to string and injecting the declaration string into it; is there a way
to avoid this?

XML parsers, even non validating ones still must check is DTD file exists.
You can either have dummy DTD file or handle DTD file resolving yourself.

--
Oleg Tkachenko [XML MVP, MCPD]
http://www.tkachenko.com/blog | http://www.XmlLab.Net


Reply With Quote
  #3  
Old   
Martin Honnen
 
Posts: n/a

Default Re: CreateDocumentType file not found - 10-28-2007 , 08:36 AM



Sergei Shelukhin wrote:
Quote:
Hi. I need to write xml export that will be used by another
application. That application requires that I add a doctype
delcaration to the document, referencing a certain dtd file. I do not
have the file, and don't really need the declaration myself, it will
be used when the document is read I suppose; how do I get around
"Couldn't find file" excepption thrown by CreateDocumentType?
Have you tried to use XmlWriter and WriteDocType instead to create your XML?
The following example

using (XmlWriter xmlWriter = XmlWriter.Create("Output.xml"))
{
xmlWriter.WriteStartDocument();
xmlWriter.WriteDocType("root", null, "foo.dtd", null);
xmlWriter.WriteElementString("root", "example");
xmlWriter.WriteEndDocument();
}

does not cause any exceptions for me although "foo.dtd" does not exist.



--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.