I am trying to transform xml/xsl in a visual basic app. The transform works for straight forward xml/xsl. When using the msxml:scipt I am getting an invalid class string error when setting the xsltemplate.stylesheet. Here is my code
number.xml----
<?xml version='1.0'?>
<data>
<circle>
<radius>12</radius>
</circle>
<circle>
<radius>37.5</radius>
</circle>
</data>
calc.xsl-------
<xsl:stylesheet version="1.0" xmlns:xsl="xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts">
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
public double circumference(double radius){
double pi = 3.14;
double circ = pi*radius*2;
return circ;
}
]]>
</msxsl:script>
<xsl:template match="data">
<circles>
<xsl:for-each select="circle">
<circle>
<xsl:copy-of select="node()"/>
<circumference>
<xsl:value-of select="user:circumference(radius)"/>
</circumference>
</circle>
</xsl:for-each>
</circles>
</xsl:template>
</xsl:stylesheet>
visual basic app code ---
Dim xmlSource As New MSXML2.DOMDocument30
Dim xmlOutput As New MSXML2.DOMDocument30
Dim xslTemplate As New MSXML2.XSLTemplate30
Dim xmlStylesheet As New MSXML2.FreeThreadedDOMDocument30
Dim xslProcessor As MSXML2.IXSLProcessor
xmlSource.Load ("C:\Clients\Netik\InterView Adapters\Transform\number.xml"
If xmlSource.parseError.reason <> "" Then
MsgBox "ERROR: " & xmlSource.parseError.reason & vbCrLf & "SOURCE: " & _
xmlSource.parseError.srcText, vbExclamation, App.Title
End If
xmlStylesheet.Load ("C:\Clients\Netik\InterView Adapters\Transform\calc.xsl"
If xmlStylesheet.parseError.reason <> "" Then
MsgBox "ERROR: " & xmlStylesheet.parseError.reason & vbCrLf & "SOURCE: " & _
xmlStylesheet.parseError.srcText, vbExclamation, App.Title
End If
Set xslTemplate.stylesheet = xmlStylesheet
Set xslProcessor = xslTemplate.createProcessor
xslProcessor.input = xmlSource
xslProcessor.output = xmlOutput
xslProcessor.Transform
Transform = xmlOutput.xml
THANKS,
Steve
number.xml----
<?xml version='1.0'?>
<data>
<circle>
<radius>12</radius>
</circle>
<circle>
<radius>37.5</radius>
</circle>
</data>
calc.xsl-------
<xsl:stylesheet version="1.0" xmlns:xsl="xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts">
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
public double circumference(double radius){
double pi = 3.14;
double circ = pi*radius*2;
return circ;
}
]]>
</msxsl:script>
<xsl:template match="data">
<circles>
<xsl:for-each select="circle">
<circle>
<xsl:copy-of select="node()"/>
<circumference>
<xsl:value-of select="user:circumference(radius)"/>
</circumference>
</circle>
</xsl:for-each>
</circles>
</xsl:template>
</xsl:stylesheet>
visual basic app code ---
Dim xmlSource As New MSXML2.DOMDocument30
Dim xmlOutput As New MSXML2.DOMDocument30
Dim xslTemplate As New MSXML2.XSLTemplate30
Dim xmlStylesheet As New MSXML2.FreeThreadedDOMDocument30
Dim xslProcessor As MSXML2.IXSLProcessor
xmlSource.Load ("C:\Clients\Netik\InterView Adapters\Transform\number.xml"
If xmlSource.parseError.reason <> "" Then
MsgBox "ERROR: " & xmlSource.parseError.reason & vbCrLf & "SOURCE: " & _
xmlSource.parseError.srcText, vbExclamation, App.Title
End If
xmlStylesheet.Load ("C:\Clients\Netik\InterView Adapters\Transform\calc.xsl"
If xmlStylesheet.parseError.reason <> "" Then
MsgBox "ERROR: " & xmlStylesheet.parseError.reason & vbCrLf & "SOURCE: " & _
xmlStylesheet.parseError.srcText, vbExclamation, App.Title
End If
Set xslTemplate.stylesheet = xmlStylesheet
Set xslProcessor = xslTemplate.createProcessor
xslProcessor.input = xmlSource
xslProcessor.output = xmlOutput
xslProcessor.Transform
Transform = xmlOutput.xml
THANKS,
Steve