Subject:Maddening problem MSXML IXSLProcess object Author:John Foelster Date:02 May 2006 11:15 AM
I'm having issues with using the IXSLProcess object to merge XML data into an XSL template.
Here is my XML:
<record>
<BrandName>My Brand</BrandName>
<CustomerName>ABC Co.</CustomerName>
<ProgramName>Testy Test Test</ProgramName>
<Description>Test test test</Description><ProductNumber>3-246-54545-X</ProductNumber>
<Status>It will be released on 09/01/2006.</Status>
<PublisherName>Tipsy McStagger</PublisherName>
</record>
<p class="bigger">Hello <b><xsl:apply-templates select="record/CustomerName" /></b> employee.</p>
<p class="bigger"><b><xsl:apply-templates select="record/BrandName" /></b> has made a change in the availability of <b><xsl:apply-templates select="record/ProductNumber" /></b>, <B><xsl:apply-templates select="record/Description" /></B> has changed for <B><xsl:apply-templates select="record/ProgramName" /></B>. <xsl:apply-templates select="record/Status" /></p>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Here is the pertinent VB 6.0 code
Public Function GetHTML() As String
Dim xslt As New MSXML2.XSLTemplate30
Dim xslDoc As New MSXML2.FreeThreadedDOMDocument30
Dim xmlDoc As New MSXML2.DOMDocument30
Dim xslProc As IXSLProcessor
On Error GoTo GetHTMLErr
xslDoc.async = False
xslDoc.loadXML mXSLData 'Being a reference to the XSL above
Set xslt.stylesheet = xslDoc
xmlDoc.async = False
xmlDoc.loadXML mXMLData 'Being a reference to the XML above.
Set xslProc = xslt.createProcessor()
xslProc.input = xmlDoc
xslProc.Transform
GetHTMLErr:
Select Case Err.Number
Case 0
GetHTML = xslProc.output
Case Else
GetHTML = Err.Source & vbCrLf & CStr(Err.Number) & ": " & Err.Description
End Select
End Function
The maddening bit is that it worked fine until I added the top two nodes to the document, originally crafted by SQL's FOR XML AUTO clause and now output by the with the EXPLICIT option, and that if you reference the xsl in a <?xml-stylesheet type="text/xsl"> tag, the thing works fine through IE and Stylus.
I'd really appreciate any insight anyone can give.
Subject:Maddening problem MSXML IXSLProcess object Author:John Foelster Date:02 May 2006 03:17 PM Originally Posted: 02 May 2006 03:13 PM
I tried changing the loadXML method for the XML load, but that had no effect. Doing the same for the XSL caused a DLL failure for lack of a valid XSL file.
The XML I posted above is the output of a carefully formatted FOR XML EXPLICIT query. FOR XML AUTO nests each joined table in descending order, in this case producing something like:
<Brand>
<BrandName>My Brand</BrandName>
<Customer>
<CustomerName>ABC Co.</CustomerName>
<Program>
<ProgramName>Testy Test Test</ProgramName>
<Product>
<Description>Test test test</Description>
<ProductNumber>3-246-54545-X</ProductNumber>
<Status>It will be released on 09/01/2006.</Status>
<Publisher>
<PublisherName>Tipsy McStagger</PublisherName>
</Publisher>
</Product>
</Program>
</Customer>
</Brand>
You can see why I went with EXPLICIT.
Can't get this to format for whatever reason.
Subject:Maddening problem MSXML IXSLProcess object Author:(Deleted User) Date:02 May 2006 04:02 PM
Hi John
Could you be more specific on what you mean by 'not working'?
I tried both 'load' and 'loadXML' using the VB Script that you have with the EXPLICIT XML that you specified. It is outputting what is expected, successfully.