Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 7th, 2006, 06:25 PM
scottl
Guest
 
Posts: n/a
Default 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
  #2  
Old March 7th, 2006, 06:45 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Creating a document type in C#



scottl wrote:

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

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/
  #3  
Old March 7th, 2006, 06:55 PM
scottl
Guest
 
Posts: n/a
Default Re: Creating a document type in C#

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:
[color=blue]
>
>
> scottl wrote:
>
>[color=green]
> > The document type declaration is:
> > <!DOCTYPE procedure PUBLIC
> > "-//LMSSC//DTD XML//CAEWriter Minimal Revisable Units 2.0.2//Vulcan//EN"
> > "vulcan-cae.dtd">[/color]
>
> 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/
>[/color]
  #4  
Old March 7th, 2006, 07:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Creating a document type in C#



scottl wrote:

[color=blue]
> 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.[/color]

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/
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles