PC Review


Reply
Thread Tools Rate Thread

Bug found in XmlDocument when using doctype tag (such as for xhtml

 
 
=?Utf-8?B?WXZlc2Rt?=
Guest
Posts: n/a
 
      4th Sep 2004
Consider the following XML document :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
</body>
</html>

Let's see the doctype :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

If you use an XmlDocument to handel this xml file :
XmlDocument doc = new XmlDocument();
doc.Load( path ); //using doc.Load( string path )

the XmlDocument will MODIFY the doctype declaration, by appending []
e.g. :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>

With that modification, you have a MALFORMED document, wich is NOT VALID !!

---------------------------------------------------------------------------------

Don't wait the next service pack to have a fix.
The easyest way to fix it, is to extends the XmlDocument class
And override the
public XmlDocumentType CreateDocumentType( string name, string publicId,
string systemId, string internalSubset ) method.

public override XmlDocumentType CreateDocumentType( string name,
string publicId, string systemId, string internalSubset )
{
if ( internalSubset != null && internalSubset.Length() == 0 )
return base.CreateDocumentType( name, publicId, systemId,
null );
else
return base.CreateDocumentType( name, publicId, systemId,
internalSubset );
}

Normally, if there are no internalSubset the .NET framework should call
this with null and not with an empty string !! Because it doesn't do it, we
have to do it !!


I hope that microsoft will consider and fix this bug.
I hope that this will help .NET programmers.

Yvesdm
--
Computer programmer.
 
Reply With Quote
 
 
 
 
New Member
Join Date: Jul 2012
Posts: 1
 
      10th Jul 2012
hi i have used the code
publicoverrideXmlDocumentType CreateDocumentType(string name, string publicId, string systemId, string internalSubset)
{
if (internalSubset != null && internalSubset.Length() == 0)
returnbase.CreateDocumentType(name, publicId, systemId, null);
else
returnbase.CreateDocumentType(name, publicId, systemId, internalSubset);
}

in my C# code its not working, showing error:no suitable method found to override
can u pls guide me

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlDocument.Save() with null XmlResolver modifies DOCTYPE tag eXavier Microsoft Dot NET 3 13th Mar 2009 01:01 PM
Re: XmlDocument.save bug? Appending [] to the doctype Jeroen Mostert Microsoft C# .NET 2 8th Aug 2008 07:49 PM
Difference between DOCTYPE HTML 4.01 and XHTML 1.0 Tatyana Microsoft ASP .NET 1 8th Aug 2006 11:48 PM
XHTML DOCTYPE & Styles =?Utf-8?B?TWlrZQ==?= Windows XP Internet Explorer 0 30th Nov 2005 11:23 AM
css padding on images not working in XHTML 1.0 doctype Andrew Crowe Windows XP Internet Explorer 0 19th Nov 2003 06:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:11 PM.