470,848 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

Creating a document type in C#

I'm trying to programmatically create a document type using the
CreateDocumentType method of XmlDocument.

The document type declaration is:
<!DOCTYPE procedure PUBLIC
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN"
"vulcan-cae.dtd">

Using the method generates an error with the second parameter.
CreateDocumentType("project",
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN"
null,
"vulcan-cae.dtd">

I"ve tried various combinations, but can't generate the desired output.
Including "-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units
2.0.2//Vulcan//EN" always generates an error.

Any pointers?
Scott
Mar 7 '06 #1
3 6608


scottl wrote:

The document type declaration is:
<!DOCTYPE procedure PUBLIC
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN"
"vulcan-cae.dtd">


You need e.g. C# (with no line break inside of the string literals)

XmlDocument xmlDocument = new XmlDocument();
XmlDocumentType documentTypeDeclaration =
xmlDocument.CreateDocumentType(
"procedure",
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN",
"vulcan-cae.dtd",
null
);

Note that the system id (e.g. vulcan-cae.dtd) needs to point to an
existing file.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 7 '06 #2
Thanks, however the error isn't on the system parameter, which was a typo by
the way. That should have been the fourth parameter.

The error I get when running the following variant is:
CreateDocumentType("procedure", "-//LMSSC//DTD XML//CAEWriter Minimal
Revisable Units 2.0.2//Vulcan//EN", null,null);

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: The path is not of a legal form.

This text works fine when loading the document with the declaration
pre-existing in the document. Now I'm trying to build the document.

Scott

"Martin Honnen" wrote:


scottl wrote:

The document type declaration is:
<!DOCTYPE procedure PUBLIC
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN"
"vulcan-cae.dtd">


You need e.g. C# (with no line break inside of the string literals)

XmlDocument xmlDocument = new XmlDocument();
XmlDocumentType documentTypeDeclaration =
xmlDocument.CreateDocumentType(
"procedure",
"-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN",
"vulcan-cae.dtd",
null
);

Note that the system id (e.g. vulcan-cae.dtd) needs to point to an
existing file.
--

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

Mar 7 '06 #3


scottl wrote:

The error I get when running the following variant is:
CreateDocumentType("procedure", "-//LMSSC//DTD XML//CAEWriter Minimal
Revisable Units 2.0.2//Vulcan//EN", null,null);

An unhandled exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: The path is not of a legal form.


Hmm, I see that error here with .NET 1.1. When I compile and run with
..NET 2.0 I don't get any error.
I am not sure there is anything wrong with that public id, it rather
looks like you have hit a bug with CreateDocumentType in .NET 1.1.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Don Stefani | last post: by
2 posts views Thread by pshvarts | last post: by
6 posts views Thread by Adam Tilghman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.