[Mono-bugs] [Bug 676009] New: XDocument.Load throws "(DTD) is prohibited in this XML"
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Mar 1 13:14:46 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=676009
https://bugzilla.novell.com/show_bug.cgi?id=676009#c0
Summary: XDocument.Load throws "(DTD) is prohibited in this
XML"
Classification: Mono
Product: Mono: Class Libraries
Version: 2.10.x
Platform: x86
OS/Version: Windows 7
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.XML
AssignedTo: atsushi at ximian.com
ReportedBy: kot.begemot at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13)
Gecko/20101203 Firefox/3.6.13
I'm trying to run a in mono for windows and I hit difference in XDocument.Load
behavior between MS and mono frameworks.
Mono gives me an exception if document contains DTD declaration while MS
framework works without complains.
Exception:
================================
Unhandled Exception: System.Xml.XmlException: Document Type Declaration (DTD)
is prohibited in this XML. file:///C:/projects/experimental/
Test/XdocTest/bin/Debug/test.xml Line 2, position 10.
at Mono.Xml2.XmlTextReader.ReadDoctypeDecl () [0x00000] in <filename
unknown>:0
at Mono.Xml2.XmlTextReader.ReadDeclaration () [0x00000] in <filename
unknown>:0
at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0
at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0
at Mono.Xml.XmlFilterReader.Read () [0x00000] in <filename unknown>:0
at Mono.Xml.XmlFilterReader.Read () [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.ReadContent (System.Xml.XmlReader reader,
LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.LoadCore (System.Xml.XmlReader reader,
LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri, LoadOptions options)
[0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri) [0x00000] in <filename
unknown>:0
at XdocTest.Program.Main (System.String[] args) [0x00000] in <filename
unknown>:0
=====================================
Program:
======================================
static void Main(string[] args)
{
string test = @"<?xml version=""1.0""?>
<!DOCTYPE opml SYSTEM ""http://dtd.mycompany.com/opml.dtd"">
<opml></opml>";
var doc = XDocument.Parse(test);
doc = XDocument.Load(new StringReader(test));
doc = XDocument.Load("test.xml");
}
======================================
When loading the same document from string or string reader, it works fine
under Mono, but when calling Load, it fails.
I see in mono source code that XDocument sets s.ProhibitDtd = false when
reading from TextReader but apparently it needs to be set when reading from uri
too in order to replicate MS behavior.
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list