XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
John FoelsterSubject: 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>

Here is my XSL:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />
<xsl:template match="/">
<HTML>
<BODY>

<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.

Postnext
(Deleted User) Subject: Maddening problem MSXML IXSLProcess object
Author: (Deleted User)
Date: 02 May 2006 12:08 PM
Hi John,

How does the AUTO vs the EXPLICIT XML differ? Can you post both the XMLs?

Regards
-Srini

Postnext
(Deleted User) Subject: Maddening problem MSXML IXSLProcess object
Author: (Deleted User)
Date: 02 May 2006 12:21 PM
Hi John

Also, did you try with load, instead of loadXML?

Regards
- Srini

Postnext
John FoelsterSubject: 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.

Postnext
(Deleted User) 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.

Regards
Srini

Postnext
John FoelsterSubject: Maddening problem MSXML IXSLProcess object
Author: John Foelster
Date: 02 May 2006 04:06 PM
I mean it outputs with empty strings as all the merged values.

Postnext
(Deleted User) Subject: Maddening problem MSXML IXSLProcess object
Author: (Deleted User)
Date: 02 May 2006 04:39 PM
Hi John

Here is the VB script that I have (with 'load' statement commented out).

You may want to compare with what I have vs what you have...

Regards
Srini


UnknownMad.xml


UnknownMad.xsl


UnknownForm1.frm


UnknownNoname(19).

Postnext
(Deleted User) Subject: Maddening problem MSXML IXSLProcess object
Author: (Deleted User)
Date: 02 May 2006 05:14 PM
Hi John

Here is a zip file - in case you didn't get the other files..

Regards
Srini


UnknownFiles.zip

Posttop
John FoelsterSubject: Maddening problem MSXML IXSLProcess object
Author: John Foelster
Date: 03 May 2006 04:43 PM
Well, by going through a vigorous debugging with your projrct, I was able to find the problem:

I had hardcoded a reference to the XSL document at the root of my C: drive and then put the new XSL in the App.Path directory.

In the words of the immortal Homer Simpson, D'oh!

Thanks for the help.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.