Groups | Blog | Home
all groups > dotnet xml > march 2005 >

dotnet xml : What to replace obsolete interfaces with?


BrianProgrammer
3/4/2005 10:21:15 AM
I have this code below, that works like a champ, but two lines are
continually marked as obsolete. See embeded notes.

Private Shared Function TransformHTMLString(ByVal XSLT As String, _
ByVal XHTML As String) _
As String
Dim xdoc As Xml.XmlDocument = New Xml.XmlDocument
xdoc.LoadXml(XHTML)

Dim xsDoc As Xml.XmlDocument = New XmlDocument
xsDoc.LoadXml(XSLT)

'Both lines that are marked as obsolete are tagged that way
'by VS.Net2003. It is because I am passing an XMLDocument
'rather than a resolver

Dim xformer As Xml.Xsl.XslTransform = New Xml.Xsl.XslTransform
xformer.Load(xsDoc) 'Marked as obsolete

Dim writer As StringWriter = New StringWriter
xformer.Transform(xdoc, Nothing, writer) 'Marked as obsolete

Dim rtf As String = writer.ToString()
writer.Close()
Return rtf
End Function

What is the non-obsolete way to do the same thing?
BrianProgrammer
3/4/2005 3:33:12 PM
Thanks.
That was simple and seemed obvious. Just not clear in documentation to
me.
BrianProgrammer
3/4/2005 4:37:08 PM
This version causes an error of:

System.Security.Policy.PolicyException: Exception from HRESULT:
0x80131418. at System.Reflection.Assembly.nLoadImage(Byte[]
rawAssembly, Byte[] rawSymbolStore, Evidence evidence, StackCrawlMark&
stackMark) at System.Reflection.Assembly.Load(Byte[] rawAssembly,
Byte[] rawSymbolStore, Evidence securityEvidence) at
Microsoft.JScript.JSCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames) at
System.CodeDom.Compiler.CodeCompiler.FromDomBatch(CompilerParameters
options, CodeCompileUnit[] ea) at
System.CodeDom.Compiler.CodeCompiler.FromDom(CompilerParameters
options, CodeCompileUnit e) at
System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromDom(CompilerParameters
options, CodeCompileUnit e) at
System.Xml.Xsl.Compiler.CompileAssembly(ScriptingLanguage lang,
Hashtable typeDecls, String nsName, Evidence evidence) at
System.Xml.Xsl.Compiler.CompileScript(Evidence evidence) at
System.Xml.Xsl.Compiler.Compile(NavigatorInput input, XmlResolver
xmlResolver, Evidence evidence) at
System.Xml.Xsl.XslTransform.Compile(XPathNavigator stylesheet,
XmlResolver resolver, Evidence evidence) at
System.Xml.Xsl.XslTransform.Load(XPathNavigator stylesheet, XmlResolver
resolver, Evidence evidence) at
System.Xml.Xsl.XslTransform.Load(IXPathNavigable stylesheet,
XmlResolver resolver, Evidence evidence) at
BFastControls.HtmlToRtf.ConvertToRtf(String XSLT, String XHTML) in
C:\Clients\BBI\BFast2005\BFastControls\HtmlToRtf.vb:line 50

Any Ideas on why?
Ross Presser
3/4/2005 5:29:26 PM
[quoted text, click to view]

[snip]
[quoted text, click to view]

' pass Nothing for the XmlResolver and Evidence parameters
xformer.Load(xsDoc, Nothing, Nothing)

[quoted text, click to view]

' pass Nothing for the XmlResolver parameter
xformer.Transform(xdoc, Nothing, writer, Nothing

--
Ross Presser
BrianProgrammer
3/4/2005 5:54:15 PM
Found my own solution

1. change method from being shared to requiring instantiation
2. change: xformer.Load(xsDoc, Nothing, Nothing)
to: xformer.Load(xsDoc, Nothing, Me.GetType().Assembly.Evidence)

problem solved. What a pain in the butt. lol
AddThis Social Bookmark Button