Hi there,
I have a problem with transforming from XML to CSV using a very simple stylesheet.
Following is an example input file
------------------------------------
<CD>
<PROJECT ID="TEST" CODE="TESTCODE"></PROJECT>
<PROJECT ID="TEST2" CODE="TESTCODE2"></PROJECT>
</CD>
Following is the
VB 6 code
----------------------------
Public Function TransformFromDOM(xmlSource As MSXML2.FreeThreadedDOMDocument40, strXSL As String) As FreeThreadedDOMDocument40
On Error GoTo ErrHandler
Dim xmlOutput As New MSXML2.FreeThreadedDOMDocument40
Dim xmlStylesheet As New MSXML2.FreeThreadedDOMDocument40
Dim xslTemplate As New MSXML2.XSLTemplate40
Dim xslProcessor As MSXML2.IXSLProcessor
xmlStylesheet.Load strXSL
If xmlStylesheet.parseError.reason <> "" Then
MsgBox "ERROR: " & xmlStylesheet.parseError.reason & vbCrLf & "SOURCE: " & _
xmlStylesheet.parseError.srcText, vbExclamation, App.Title
Exit Function
End If
Set xslTemplate.stylesheet = xmlStylesheet
Set xslProcessor = xslTemplate.createProcessor
xslProcessor.input = xmlSource
xslProcessor.output = xmlOutput
xslProcessor.Transform
Set TransformFromDOM = xmlOutput
Exit Function
ErrHandler:
MsgBox "ERROR: " & err.Number & " " & err.Description, _
vbCritical, App.Title
Set TransformFromDOM = Nothing
End Function
Now here is the simple transformation which isn't working at all
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output version="1.0" indent="no" method="text" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:apply-templates select="CD"/>
</xsl:template>
<xsl:template match="CD"><xsl:text>Ref,Start,Finish,Title#13;</xsl:text>
<xsl:for-each select="//Project">
<xsl:value-of select="concat( @ID, ',', @CODE)"/>
<xsl:text>#13;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The output being generated is a blank file completely.
Does anyone know what is happening.. Note that when I apply the transformation from within XML Spy using the same XML parser (MSXML4.0) everything works fine.
Thankx in advance
Jonathan