[Mono-list] System.Xml XmlTextReader 'resolver' ...
Michael Meeks
michael.meeks at novell.com
Mon Nov 13 19:53:40 EST 2006
Hi Atsushi,
On Tue, 2006-11-14 at 09:28 +0900, Atsushi Eno wrote:
> Sadly the patch is wrong - the XmlResolver in XmlReaderSettings is
> used only to resolve DTD or whatever dependent files, not the XML
> stream itself.
Interesting; I'd be interesting to know what source you get that from.
Based on the fact that this code works on MS' .Net 2.0 but not under
Mono, it appears likely that we behave differently, and thus we are in
error. Furthermore, (now I look) MSDN appears to support my view:
http://msdn2.microsoft.com/en-us/library/ms162478.aspx
"inputUri
The URI for the file containing the XML data. The XmlResolver
object on the XmlReaderSettings object is used to convert the
path to a canonical data representation. If XmlResolver is a
null reference (Nothing in Visual Basic), a new XmlUrlResolver
object is used."
ie. currently we are not using the resolver from the XmlReaderSettings
for converting 'inputURI' [ AFAICS ].
> For XML stream, you could just pass the stream itself to one of the
> constructors (for example, by using your XmlResolver.GetEntity()).
I understand that, but given that the existing code works on Win32 this
is a hard sell wrt. changing up-stream.
> XmlResolver could be explicitly set null (which indicates that it
> must skip external entity resolution) and in such case your patch
> causes NullReferenceException. (I will add such case to our tests.)
True - fair cop, it needs a conditional there.
> > This was provoked by OdfConverter - which likes to stuff
>> a whole load of XSLT magic inside the .exe itself :-)
>
> What kind of issue was it?
Doesn't work under Mono when it runs fine under Win32 ;-) stack trace
as follows:
[DEBUG][/tmp/tst.docx] Could not find file "/data/OpenOffice/odf-converter/source/OdfConverterTest/source.xml".( at System.IO.FileStream..ctor (System.String name, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x001f5] in /data/mono/mcs/class/corlib/System.IO/FileStream.cs:221
at System.IO.FileStream..ctor (System.String name, FileMode mode, FileAccess access, FileShare share) [0x00000] in /data/mono/mcs/class/corlib/System.IO/FileStream.cs:121
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.Xml.XmlUrlResolver.GetEntity (System.Uri absoluteUri, System.String role, System.Type ofObjectToReturn) [0x00068] in /data/mono/mcs/class/System.XML/System.Xml/XmlUrlResolver.cs:64
As you see this XmlUrlResolver is used here in error instead of our custom resolver.
at Mono.Xml2.XmlTextReader.GetStreamFromUrl (System.String url, System.String& absoluteUriString) [0x0002c] in /data/mono/mcs/class/System.XML/System.Xml/XmlTextReader.cs:177
at Mono.Xml2.XmlTextReader..ctor (Boolean dummy, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00044] in /data/mono/mcs/class/System.XML/System.Xml/XmlTextReader.cs:133
at System.Xml.XmlTextReader..ctor (Boolean dummy, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00006] in /data/mono/mcs/class/System.XML/System.Xml/XmlTextReader2.cs:134
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext context) [0x00018] in /data/mono/mcs/class/System.XML/System.Xml/XmlReader.cs:313
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings) [0x00000] in /data/mono/mcs/class/System.XML/System.Xml/XmlReader.cs:265
We pass in the correct XmlReaderSettings ...
at CleverAge.OdfConverter.OdfConverterLib.Converter.Transform (System.String inputFile, System.String outputFile) [0x0009e] in /data/OpenOffice/odf-converter/source/OdfConverterLib/Converter.cs:151
at CleverAge.OdfConverter.CommandLineTool.OdfConverterTest.ConvertFile (System.String input, System.String output, Boolean isDirectTransform) [0x00037] in /data/OpenOffice/odf-converter/source/OdfConverterTest/OdfConverterTest.cs:342 )
HTH,
Michael.
--
michael.meeks at novell.com <><, Pseudo Engineer, itinerant idiot
More information about the Mono-list
mailing list