msxml scripts and xstlArgumentList entension objects. Can I combinethem?

S

steve_h

I think the subject says it all, but just in case:

I know that I can call my own methods during an XSL transformation
using

<xsl:value-of select="myObject.someMethod(arg1)" />

having done something like:

dim xslTrans as System.Xml.Xsl.Xsltransform
dim xsltArg as new System.Xml.XsltArgumentList()
xsltArg.AddExtensionObject("urn:my-object")
....
dim navigator as System.Xml.Xpath.XPathNavigator = ..

xslTrans.transform(navigator, xslArg, myWriter, Nothing)

....
public function someMethod( arg as string) as String
...
end function


and I also know that I can define functions in a script inside
the xsl file using:

<msxsl:script language="VisualBasic" implements-prefix="user">
function myFunc (xx)
...
end function
</msxsl:script>

<xsl-value-of select="user:myFunc( elm/@value ) />


Is there an easy way to combine the two ideas so that my msxml:script
function calls the method of my extension object ?

<msxsl:script language="VisualBasic" implements-prefix="user">
<![CDATA[
function myFunc (xx)
myFunc = myObject.someMethod()
end function
]]>
</msxsl:script>


Steve.
 
J

John Doe

Like you, I would also like an answer to this question...

Also, does the VS debugger work for you with the contents of the msxsl:script tag ?
 
S

steve_h

John said:
Like you, I would also like an answer to this question...

Also, does the VS debugger work for you with the contents of the msxsl:script tag ?


I had't tried it until just now. The only way I could think of doing
this was using 'step into' xsltTrans.transform(....)', but that doesn't
work. The callbacks to myObject.someMethod can be debugged if I place a
breakpoint there, but I can't place break points inside the
msxsl function because it's only a string inside a data file afa
devStudio is concerned.



steve_h said:
I think the subject says it all, but just in case:

I know that I can call my own methods during an XSL transformation
using

<xsl:value-of select="myObject.someMethod(arg1)" />

having done something like:

dim xslTrans as System.Xml.Xsl.Xsltransform
dim xsltArg as new System.Xml.XsltArgumentList()
xsltArg.AddExtensionObject("urn:my-object")
....
dim navigator as System.Xml.Xpath.XPathNavigator = ..

xslTrans.transform(navigator, xslArg, myWriter, Nothing)

...
public function someMethod( arg as string) as String
...
end function


and I also know that I can define functions in a script inside
the xsl file using:

<msxsl:script language="VisualBasic" implements-prefix="user">
function myFunc (xx)
...
end function
</msxsl:script>

<xsl-value-of select="user:myFunc( elm/@value ) />


Is there an easy way to combine the two ideas so that my msxml:script
function calls the method of my extension object ?

<msxsl:script language="VisualBasic" implements-prefix="user">
<![CDATA[
function myFunc (xx)
myFunc = myObject.someMethod()
end function
]]>
</msxsl:script>


Steve.
 
K

Kirk Allen Evans [MVP]

Here is the same reply I put on the microsoft.public.xsl list:

They are processed very differently by the .NET framework, and you should
refrain from using msxsl:script elements within XSLT parsed by managed code.
See Q316775 [1], the assembly cannot be unloaded correctly and may lead to a
memory leak. There are several design patterns that you can use to mitigate
the changes, including dynamically loading an assembly that contains your
extension objects.

Not that it is impossible to do, but I have not seen any vendors that
support script debugging in their XSLT products. For example, Marrowsoft's
Xselerator is one of the best XSLT IDEs and it does not support script
debugging. I have not seen ActiveState's newest release of their XSLT
debugger for .NET, but I have not heard about it being able to debug inlined
script, either.

Your best bet is to simply use extension objects if you are using .NET.

[1] http://support.microsoft.com/default.aspx?scid=kb;EN-US;316775

--
Kirk Allen Evans
Microsoft MVP, ASP.NET
XmlInsider
www.xmlandasp.net
Read my web log at http://weblogs.asp.net/kaevans

steve_h said:
John said:
Like you, I would also like an answer to this question...

Also, does the VS debugger work for you with the contents of the msxsl:script tag ?


I had't tried it until just now. The only way I could think of doing
this was using 'step into' xsltTrans.transform(....)', but that doesn't
work. The callbacks to myObject.someMethod can be debugged if I place a
breakpoint there, but I can't place break points inside the
msxsl function because it's only a string inside a data file afa
devStudio is concerned.



I think the subject says it all, but just in case:

I know that I can call my own methods during an XSL transformation
using

<xsl:value-of select="myObject.someMethod(arg1)" />

having done something like:

dim xslTrans as System.Xml.Xsl.Xsltransform
dim xsltArg as new System.Xml.XsltArgumentList()
xsltArg.AddExtensionObject("urn:my-object")
....
dim navigator as System.Xml.Xpath.XPathNavigator = ..

xslTrans.transform(navigator, xslArg, myWriter, Nothing)

...
public function someMethod( arg as string) as String
...
end function


and I also know that I can define functions in a script inside
the xsl file using:

<msxsl:script language="VisualBasic" implements-prefix="user">
function myFunc (xx)
...
end function
</msxsl:script>

<xsl-value-of select="user:myFunc( elm/@value ) />


Is there an easy way to combine the two ideas so that my msxml:script
function calls the method of my extension object ?

<msxsl:script language="VisualBasic" implements-prefix="user">
<![CDATA[
function myFunc (xx)
myFunc = myObject.someMethod()
end function
]]>
</msxsl:script>


Steve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top