Discussion:
addParameter method newbie question
(too old to reply)
Marcos Hercules Santos
2006-05-28 14:31:13 UTC
Permalink
Hello people,

This is my first time in this group, and in the start I want to
congratulate for creating this group.

Well, I have an XML called storage and another called tools, in which
there's a
simple operation through a XSL used to compare both XMLs (by the ID
number).

see a piece from my XSL,

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />

<xsl:variable name="tools" select="//tool" />
<xsl:param name="compare-file-name" select="'tools.xml'"/>
<xsl:variable name="second" select="document($compare-file-name)"/>

<xsl:key name="by-model" match="reference" use="id" />

<xsl:template match="/">

Now, I'm doing this through VBA (Excel 2003).
I'm trying on to apply transformNodeToObject in a way to pass another
DOMDocument object for holding the results, with no sucess.

Would anyone point me how XSLT in VBA can pass parameter to tools.xml
and give me a comparation results in my sheet. I' don't know how xsl
load an external xml in this case.

This is my VBA code

Public Sub compare2()
Dim SourceXSL As New MSXML2.DOMDocument40
Dim StorageML As New MSXML2.DOMDocument40
Dim toolXML As New MSXML2.DOMDocument40
Dim GenericXML As New MSXML2.DOMDocument40

'Load the XMLSpreadsheet file into a DOMDocument object.
StorageXML.Load "C:\storage.xml"
tool.Load "C:\tools.xml"

'Load the XSLStyleSheet file into a DOMDocument object.
SourceXSL.Load "C:\comparation.xsl"

'Apply the XSL style sheet to the XML spreadsheet file and send
it
'to the GenericXML DOMDocument object.
'storageXML.transformNodeToObject Stylesheet:=SourceXSL, _
'OutputObject:=GenericXML

StorageXML.transformNodeToObject SourceXSL, GenericXML

'Save the generic XML file as C:\GenericXMLFile.xls
GenericXML.Save ("C:\GenericXMLFile2.xls")
End Sub

What's it's viewed in my sheet? only the XML format from my
Storage.xml file


Any sample is apreciatte


thanx

Marcos Hercules dos Santos
Martin Honnen
2006-05-28 15:50:20 UTC
Permalink
Post by Marcos Hercules Santos
<xsl:param name="compare-file-name" select="'tools.xml'"/>
Dim SourceXSL As New MSXML2.DOMDocument40
Dim StorageML As New MSXML2.DOMDocument40
Dim toolXML As New MSXML2.DOMDocument40
Dim GenericXML As New MSXML2.DOMDocument40
'Load the XMLSpreadsheet file into a DOMDocument object.
StorageXML.Load "C:\storage.xml"
tool.Load "C:\tools.xml"
'Load the XSLStyleSheet file into a DOMDocument object.
SourceXSL.Load "C:\comparation.xsl"
Pseudo code:
Dim SourceXsl = New Msxml2.FreeThreadedDOMDocument40
SourceXsl.async = False
SourceXsl.load "C:\comparation.xsl"
Dim XslTemplate = New Msxml2.XslTemplate40
XslTemplate.stylesheet = SourceXsl
Dim XsltProcessor As IXSLProcessor
Set XsltProcessor = XslTemplate.createProcessor()
XsltProcessor.input = StorageXML
XsltProcessor.addParameter "compare-file-name", "tools.xml"
XsltProcessor.output = GenericXML
XsltProcessor.transform

See the MSDN documentation for more details and examples

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/9ddcd728-2646-494a-8fa4-3b68e8c032b7.asp>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Loading...