all groups > dotnet xml > march 2006 >
You're in the

dotnet xml

group:

Creating a document type in C#


Creating a document type in C# scottl
3/7/2006 10:13:11 AM
dotnet xml:
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?
Re: Creating a document type in C# scottl
3/7/2006 10:46:29 AM
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

[quoted text, click to view]
Re: Creating a document type in C# Martin Honnen
3/7/2006 7:34:04 PM


[quoted text, click to view]


[quoted text, click to view]

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
Re: Creating a document type in C# Martin Honnen
3/7/2006 8:01:59 PM


[quoted text, click to view]


[quoted text, click to view]

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
AddThis Social Bookmark Button