[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Problem using transformNode in html transformed from XML


Subject: Re: [xsl] Problem using transformNode in html transformed from XML
From: "Carsten Klein" <carstenklein@xxxxxxxx>
Date: Thu, 21 Mar 2002 09:35:00 +0100

Hi Steve,

well, as far as I can see, you are using a free threaded document
(bug.xml) in conjunction with
a non threaded document (bug.xsl). You should be using both either
as non threaded or free threaded.
I had the same problem in a little project i have done, here is a
code snipped of this

var treeviewXML = new
ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
treeviewXML.async = false;

var treeviewXSL = new
ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
treeviewXSL.async = false;
treeviewXSL.load("treeview.xsl");

When using the free threaded document object you have to create a
processor each time you do the
transformation and a template would be quite useful, if the
transformation is done quite often, to save some
execution time, since the template stores the document in a compiled
state

var treeviewTXSL = new ActiveXObject("Msxml2.XSLTemplate.4.0");
treeviewTXSL.stylesheet = treeviewXSL;

In my transformation routine I use

function transform(aNode, aXMLdoc, aTemplate, aParameters) {
    var vXSLTProc = aTemplate.createProcessor();
    vXSLTProc.input = aXMLdoc;
    if (aParameters)
    for (var vCount=0;vCount<aParameters.length;vCount++)
        vXSLTProc.addParameter(aParameters[vCount][0],
aParameters[vCount][1], aParameters[vCount][2]);
    vXSLTProc.transform();

   aNode.innerHTML = vXSLTProc.output;
}

The transform function takes a dom node (e.g. the DIV you are
talking about), the xml document (fragment) which is going to be
transformed (treeviewXML, bug.xml), the template used (treeviewTXSL)
and optional
parameters array of the form

        array(
            array(<paramName>, <value>, <namespaceURI>) [,
array()...]
        )

    e.g.

        array(
            array(foo", "bar", ""),
            array("john", 1, "")
        )

Please note, that the parameter values may only consist of data
which may eventually evaluate to a string
or number value (dates and the like). The third parameter value is
an optional namespace uri.

See
<a
href="http://msdn.microsoft.com/library/en-us/xmlsdk/htm/xml_mth_ac_
5pgy.asp?frame=true">MSDN library Topic addParameter Method</a> and
others.

This may solve your problems.

Bye

Carsten


_________________________________________________________
Do You Yahoo!?
Get your free @... address at http://mail.yahoo.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xml