Connecting Tech Pros Worldwide Forums | Help | Site Map

Migrating XSL stylsheets with msxsl:script from MSXML4 to System.X

Eugen Gulinsky
Guest
 
Posts: n/a
#1: Nov 12 '05
Hello guys,

I am having problems trying to migrate our MSXML4-compatible stylesheets
containing large msxsl:script blocks to a formate understandable by
System.Xml:Xsl.XslTransform. I keep getting JS1135 errors saying that some
variable was not declared. This scripts worked perfectly with MSXML4. Is
there a guide for migraiton from MSXML to .NET or can you just give me some
tips on how to resolve this issues without having to change dozens of
working, already tested and deployaed XSLTs?

Regards,
Eugen Gulinsky

Martin Honnen
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Migrating XSL stylsheets with msxsl:script from MSXML4 to System.X



Eugen Gulinsky wrote:
[color=blue]
> I am having problems trying to migrate our MSXML4-compatible stylesheets
> containing large msxsl:script blocks to a formate understandable by
> System.Xml:Xsl.XslTransform. I keep getting JS1135 errors saying that some
> variable was not declared. This scripts worked perfectly with MSXML4. Is
> there a guide for migraiton from MSXML to .NET or can you just give me some
> tips on how to resolve this issues without having to change dozens of
> working, already tested and deployaed XSLTs?[/color]

Scripting is an extension to XSLT, don't expect that to be portable.
MSXML uses the Active Script engines for JScript or VBScript, .NET while
calling it msxsl:script uses one of the .NET languages and compiles,
even if you use JScript.NET it is a completely different implementation
to the COM based JScript.
What is more important, the object model your "script" operates on when
XSLT/XPath passes in nodes (node sets) is completely different, with
MSXML it is the MSXML XML DOM but within .NET it is not DOM at all, how
the XSLT/XPath types translate into .NET types is documented here:
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXslXslTransformClassTopic.asp>

So you have
Node Set (XPath) as System.Xml.XPath.XPathNodeIterator
and
Result Tree Fragment (XSLT) as System.Xml.XPath.XPathNavigator
and need to use those APIs.


Note also that .NET 2.0 comes with a completely new XSLT implementation
though this document
<http://blogs.msdn.com/xmlteam/archive/2005/09/30/475922.aspx> claims
that migration from MSXML will be a bit easier as far as script is
concerned. But it also says
"In XslCompiledTransform a binding (method name lookup) to script
functions happens at compile time, and stylesheets that are compliable
with XslTranform may throw an exception during compilation with
XslCompiledTransform."
thus if you are now trying to move script in XSLT from MSXML to .NET
consider whether you do it in .NET 2.0 from the beginning.



--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Eugen Gulinsky
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Migrating XSL stylsheets with msxsl:script from MSXML4 to System.X


Hello Martin,

thanks for the fast reply. I also already realized there will be no easy
porting our stylesheets away from legacy MSXML. They make heavy use of the
IXSLProcessor.add_object method to set a custom functions library which is
then being used in the msxsl:script portions. What I will try to do now is to
use MSXML thru an interop assembly to instantiate the right COM objects like
stylesheet and XSLT processor. I will then provide the processor object with
an interop version of the custom functions library and hope the underlying
COM objects will work together ;-) I am of cource open for better suggestions.

Regards,
Eugen

"Martin Honnen" wrote:
[color=blue]
>
> Eugen Gulinsky wrote:
>[color=green]
> > I am having problems trying to migrate our MSXML4-compatible stylesheets
> > containing large msxsl:script blocks to a formate understandable by
> > System.Xml:Xsl.XslTransform. I keep getting JS1135 errors saying that some
> > variable was not declared. This scripts worked perfectly with MSXML4. Is
> > there a guide for migraiton from MSXML to .NET or can you just give me some
> > tips on how to resolve this issues without having to change dozens of
> > working, already tested and deployaed XSLTs?[/color]
>
> Scripting is an extension to XSLT, don't expect that to be portable.
> MSXML uses the Active Script engines for JScript or VBScript, .NET while
> calling it msxsl:script uses one of the .NET languages and compiles,
> even if you use JScript.NET it is a completely different implementation
> to the COM based JScript.
> What is more important, the object model your "script" operates on when
> XSLT/XPath passes in nodes (node sets) is completely different, with
> MSXML it is the MSXML XML DOM but within .NET it is not DOM at all, how
> the XSLT/XPath types translate into .NET types is documented here:
> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXslXslTransformClassTopic.asp>
>
> So you have
> Node Set (XPath) as System.Xml.XPath.XPathNodeIterator
> and
> Result Tree Fragment (XSLT) as System.Xml.XPath.XPathNavigator
> and need to use those APIs.
>
>
> Note also that .NET 2.0 comes with a completely new XSLT implementation
> though this document
> <http://blogs.msdn.com/xmlteam/archive/2005/09/30/475922.aspx> claims
> that migration from MSXML will be a bit easier as far as script is
> concerned. But it also says
> "In XslCompiledTransform a binding (method name lookup) to script
> functions happens at compile time, and stylesheets that are compliable
> with XslTranform may throw an exception during compilation with
> XslCompiledTransform."
> thus if you are now trying to move script in XSLT from MSXML to .NET
> consider whether you do it in .NET 2.0 from the beginning.
>
>
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
>[/color]
Oleg Tkachenko [MVP]
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Migrating XSL stylsheets with msxsl:script from MSXML4 to System.X


Eugen Gulinsky wrote:
[color=blue]
> I am having problems trying to migrate our MSXML4-compatible stylesheets
> containing large msxsl:script blocks to a formate understandable by
> System.Xml:Xsl.XslTransform. I keep getting JS1135 errors saying that some
> variable was not declared. This scripts worked perfectly with MSXML4. Is
> there a guide for migraiton from MSXML to .NET or can you just give me some
> tips on how to resolve this issues without having to change dozens of
> working, already tested and deployaed XSLTs?[/color]

In general there is no easy way. Haven't you been aware that writing
stylesheets that heavily rely on extentions makes them nonportable?
If you have dozens stylesheets, just leave them alone, what's wrong with
MSXML4?
If you still want to upgrade I recommend moving to .NET 2.0 and
XslCompiledTransform instead - JScript.NET 2.0 is more compatible with
JScript at syntax level.

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Closed Thread