Connecting Tech Pros Worldwide Forums | Help | Site Map

Using XSL in VB.net

Rob
Guest
 
Posts: n/a
#1: Nov 18 '06
All I want to do is execute a simple transformation in VB.net.... I know
this has to be simple.

I tried the following as suggested by a web page I found....

Dim xslt as New XslTransform()

xslt.Load("Filename")
xslt.Transform("InFile", "ResultFile")

This appears to be very straightforward to me.

However, this causes an error saying the code is obsolete... (I thought the
whole Framework version concept meant backwards compatability, but I guess
not.) it further says "You should pass XmlResolver to Transform() method"

Can anyone tell me how / where / why to add the XmlResolver ?

Thanks !



Martin Honnen
Guest
 
Posts: n/a
#2: Nov 18 '06

re: Using XSL in VB.net


Rob wrote:
Quote:
All I want to do is execute a simple transformation in VB.net.... I know
this has to be simple.
>
I tried the following as suggested by a web page I found....
>
Dim xslt as New XslTransform()
>
xslt.Load("Filename")
xslt.Transform("InFile", "ResultFile")
>
This appears to be very straightforward to me.
>
However, this causes an error saying the code is obsolete... (I thought the
whole Framework version concept meant backwards compatability, but I guess
not.) it further says "You should pass XmlResolver to Transform() method"
>
Can anyone tell me how / where / why to add the XmlResolver ?
The method overload you use (Transform(String, String)) is obsolete in
..NET 1.x. For security reasons you should use the overload
Transform(String, String, XmlResolver)
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXslXslTransformClassTransformTopic8. asp>
that allows you to pass in a third argument, an XmlResolver, to have the
XSLT document function enabled, or Nothing, to have the XSLT document
function disabled. So the overload with two arguments has been obsoleted
in .NET 1.x to allow for better control by your code whether the XSLT
stylesheet is allowd to use the XSLT document function or not.

So use e.g.
xslt.Transform("InFile", "ResultFile", New XmlUrlResolver())
to allow the stylesheet to use the XSLT document function or use
xslt.Transform("InFile", "ResultFile", Nothing)
to disallow it.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Rob
Guest
 
Posts: n/a
#3: Nov 18 '06

re: Using XSL in VB.net


Thanks Martin...

"Martin Honnen" <mahotrash@yahoo.dewrote in message
news:%23Wv7LqxCHHA.3620@TK2MSFTNGP02.phx.gbl...
Quote:
Rob wrote:
Quote:
>All I want to do is execute a simple transformation in VB.net.... I know
>this has to be simple.
>>
>I tried the following as suggested by a web page I found....
>>
>Dim xslt as New XslTransform()
>>
>xslt.Load("Filename")
>xslt.Transform("InFile", "ResultFile")
>>
>This appears to be very straightforward to me.
>>
>However, this causes an error saying the code is obsolete... (I thought
>the whole Framework version concept meant backwards compatability, but I
>guess not.) it further says "You should pass XmlResolver to Transform()
>method"
>>
>Can anyone tell me how / where / why to add the XmlResolver ?
>
The method overload you use (Transform(String, String)) is obsolete in
.NET 1.x. For security reasons you should use the overload
Transform(String, String, XmlResolver)
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXslXslTransformClassTransformTopic8. asp>
that allows you to pass in a third argument, an XmlResolver, to have the
XSLT document function enabled, or Nothing, to have the XSLT document
function disabled. So the overload with two arguments has been obsoleted
in .NET 1.x to allow for better control by your code whether the XSLT
stylesheet is allowd to use the XSLT document function or not.
>
So use e.g.
xslt.Transform("InFile", "ResultFile", New XmlUrlResolver())
to allow the stylesheet to use the XSLT document function or use
xslt.Transform("InFile", "ResultFile", Nothing)
to disallow it.
>
>
--
>
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Martin Honnen
Guest
 
Posts: n/a
#4: Nov 18 '06

re: Using XSL in VB.net


Martin Honnen wrote:
Quote:
The method overload you use (Transform(String, String)) is obsolete in
.NET 1.x.
Should be "is obsolete in .NET 1.1".

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Closed Thread