<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>14101</bug_id>
          
          <creation_ts>2007-06-12 12:42:47 -0700</creation_ts>
          <short_desc>XSLTProcessor does not accept Nodes as parameter values</short_desc>
          <delta_ts>2022-07-28 13:49:43 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>XML</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=28744</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sjoerd Visscher">sjoerd</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>asaf.mesika</cc>
    
    <cc>bedney</cc>
    
    <cc>bfulgham</cc>
    
    <cc>cafulnecky</cc>
    
    <cc>desamo</cc>
    
    <cc>julian.reschke</cc>
    
    <cc>mail</cc>
    
    <cc>marcus</cc>
    
    <cc>michael.slama</cc>
    
    <cc>mrizzo99</cc>
    
    <cc>rbrandt</cc>
    
    <cc>rniwa</cc>
    
    <cc>robert</cc>
    
    <cc>rwlbuis</cc>
    
    <cc>tobyschachman</cc>
    
    <cc>ydshang</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7762</commentid>
    <comment_count>0</comment_count>
    <who name="Sjoerd Visscher">sjoerd</who>
    <bug_when>2007-06-12 12:42:47 -0700</bug_when>
    <thetext>F.e. assuming doc is the XML document &lt;test/&gt;:

proc.setParameter(null, &quot;test&quot;, doc)

With XSLT:

&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;

  &lt;xsl:param name=&quot;test&quot;/&gt;
  
  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;result&gt;
      &lt;xsl:copy-of select=&quot;$test&quot; /&gt;
    &lt;/result&gt;
  &lt;/xsl:tempate&gt;

&lt;/xsl:stylesheet&gt;

gives:

&lt;result&gt;[object Document]&lt;/result&gt;

where I expected:

&lt;result&gt;&lt;test/&gt;&lt;/result&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7655</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-06-13 13:18:28 -0700</bug_when>
    <thetext>Confirmed, it&apos;s an nsIVariant in Gecko, but a String in WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5909</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-06-29 09:02:02 -0700</bug_when>
    <thetext>What types does Firefox accept in setParameter()?

If I understand the spec correctly, XSLT parameters are just expressions, so the type can be one of boolean, number, string, or node-set. Is there a way to pass an arbitrary node-set, rather than a single Node? Also, can XPathEvaluator result values be used in XSLTProcessor?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72981</commentid>
    <comment_count>3</comment_count>
      <attachid>19582</attachid>
    <who name="Robbert Broersma">mail</who>
    <bug_when>2008-03-07 03:56:30 -0800</bug_when>
    <thetext>Created attachment 19582
Should render Hello World! when this bug is fixed.

I would very much appreciate if this bug is being fixed.

I have attached a test file that will render &quot;Hello World!&quot; when this bug is fixed. Opera and Firefox already succeed, but Safari returns &quot;Hello[object Element]&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72997</commentid>
    <comment_count>4</comment_count>
    <who name="Robbert Broersma">mail</who>
    <bug_when>2008-03-07 09:22:00 -0800</bug_when>
    <thetext>Bug filed in libxslt for this:
http://bugzilla.gnome.org/show_bug.cgi?id=521030</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75040</commentid>
    <comment_count>5</comment_count>
    <who name="toby schachman">tobyschachman</who>
    <bug_when>2008-03-24 19:24:24 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; What types does Firefox accept in setParameter()?
&gt; 
&gt; If I understand the spec correctly, XSLT parameters are just expressions, so
&gt; the type can be one of boolean, number, string, or node-set. Is there a way to
&gt; pass an arbitrary node-set, rather than a single Node? Also, can XPathEvaluator
&gt; result values be used in XSLTProcessor?
&gt; 

In Firefox, one can pass a node-set by setting the parameter to an array of nodes. There may be other ways, I found this out by trial and error.

One more vote here to resolve this bug (at least for single nodes). It&apos;s keeping me from porting my app to Webkit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75043</commentid>
    <comment_count>6</comment_count>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2008-03-24 19:33:18 -0700</bug_when>
    <thetext>Not sure what we can really do here if it&apos;s a bug in libxslt.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75600</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-03-28 02:09:46 -0700</bug_when>
    <thetext>From the WebKit side, the main issue AFAICT is that it&apos;s hard to properly pass a node reference from DOM to libxml2, given that we re-create the document each time for XSLT processing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75633</commentid>
    <comment_count>8</comment_count>
    <who name="Sjoerd Visscher">sjoerd</who>
    <bug_when>2008-03-28 06:20:10 -0700</bug_when>
    <thetext>That is a really limiting way to implement XSLT. If you&apos;d want to implement user defined extension functions, which you can do with MSXML, you would have to be able to get the original node back for nodes that are passed to such functions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88811</commentid>
    <comment_count>9</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-08-19 04:58:19 -0700</bug_when>
    <thetext>*** Bug 20444 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88897</commentid>
    <comment_count>10</comment_count>
    <who name="Jason.Shang">ydshang</who>
    <bug_when>2008-08-19 23:26:13 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; *** Bug 20444 has been marked as a duplicate of this bug. ***

Could you tell me that when the bug could be fixed? Thanks!

more detail:
The following code: 
alert(typeof(proc.getParameter(null,&quot;test&quot;)));
will display &quot;string&quot;.
It sounds as if Safari converts the DOM document node to a string([object Document]) and passes that string into xsl.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>130202</commentid>
    <comment_count>11</comment_count>
    <who name="Charles Fulnecky">cafulnecky</who>
    <bug_when>2009-07-07 07:01:59 -0700</bug_when>
    <thetext>The ability to pass a node-set as a parameter is a critical component for high-performance push/comet  style applications that use XML as an in memory database.  

XSLT provides a performant means of merging an incoming document with an existing client-side model. Javascripted DOM operations are relatively costly for large documents (in excess of 2 megabytes).

Without the ability to pass a node-set we are limited to using URLs which prevents pre-processing and error handling by standard AJAX XMLHttp libraries.

See http://www2.informatik.hu-berlin.de/~obecker/XSLT/#merge</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>192650</commentid>
    <comment_count>12</comment_count>
    <who name="Deirdre Saoirse Moen">desamo</who>
    <bug_when>2010-02-22 14:54:11 -0800</bug_when>
    <thetext>&lt;rdar://problem/7672261&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>204521</commentid>
    <comment_count>13</comment_count>
    <who name="Charles Fulnecky">cafulnecky</who>
    <bug_when>2010-03-26 05:42:12 -0700</bug_when>
    <thetext>The passing of nodes as parameter values is fully supported in the latest versions of:
Internet Explorer
Firefox
Opera</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>286288</commentid>
    <comment_count>14</comment_count>
    <who name="Rick Brandt">rbrandt</who>
    <bug_when>2010-09-28 09:08:52 -0700</bug_when>
    <thetext>Still seeing this over three years later.  As a platform for web-applications this is a pretty big limitation of the web-kit browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538777</commentid>
    <comment_count>15</comment_count>
    <who name="Michael Slama">michael.slama</who>
    <bug_when>2012-01-19 09:56:52 -0800</bug_when>
    <thetext>(In reply to comment #13)
&gt; The passing of nodes as parameter values is fully supported in the latest versions of:
&gt; Internet Explorer
&gt; Firefox
&gt; Opera

We (HP ESSN) are being asked to add support for Chrome in upcoming enterprise Web application releases due to Chrome&apos;s rise in adoption, and this limitation is preventing that for some of our teams. 

We have been successfully using IE and Firefox to pass node-sets as parameters since late 2005 when the good folks at Mozilla (esp. Peter Van Der Beken) fixed their XSLT library to support node-set parameters in version 1.50. See https://bugzilla.mozilla.org/show_bug.cgi?id=248025 (comment #15 is referring to me because I was building Mozilla to test the fix).

Is there a way to move this issue to a higher priority, or perhaps request outside help to get it addressed? This is a critical requirement for our XSLT-heavy Web applications because we need to pass entire documents to the XSLT processor as parameters.

We have a large customer base and the addition of Chrome support within our organization would boost adoption even further IMO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1031650</commentid>
    <comment_count>16</comment_count>
    <who name="William J. Edney">bedney</who>
    <bug_when>2014-08-27 06:57:25 -0700</bug_when>
    <thetext>7 years... wow.

Unfortunately, it looks like this will never get fixed. And with the Blink fork, that makes it even more unlikely that it will be fixed for both codebases, etc.

I have a relatively painless workaround for this bug if anyone is interested: Use JavaScript to grab the &apos;xsl:param&apos; elements in your XSLT document, replace them with &apos;xsl:variable&apos; elements with your &apos;node&apos; content for that parameter as child content and then use that modified XSLT document in the processor.

If folks are still interested enough to want a code snippet, I can paste that here.

Cheers,

- Bill</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498273</commentid>
    <comment_count>17</comment_count>
    <who name="Mike">mrizzo99</who>
    <bug_when>2019-01-25 09:20:16 -0800</bug_when>
    <thetext>Bill

I know it is a long shot at this point (given it is almost 5 years later from the last comment) but I would be interested in the javascript snippet you put together.  I&apos;m working on an old legacy product and am actively looking for a workaround to this issue to expand browser support.  

Thanks Mike.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498356</commentid>
    <comment_count>18</comment_count>
    <who name="William J. Edney">bedney</who>
    <bug_when>2019-01-25 11:39:09 -0800</bug_when>
    <thetext>Mike -

The codebase I was working from 5 years ago has changed, but I found a chunk of code in a temp file that looked to be more-or-less working code (but probably should just be treated as pseudo-code - I&apos;m sure you&apos;ll have to debug a bit):

Assume you have an Array of Objects that contain the parameters you want to feed to the sheet:

params = [
    {name: &apos;foo&apos;, value: &lt;Node&gt;},
    {name: &apos;bar&apos;, value: &lt;Node&gt;),
    ...
];


Assume that &apos;xsltDoc&apos; is the *XSLT* document that you&apos;re using to process the source document and &apos;inputDoc&apos; is the source XML that you&apos;re transforming.

for (i = 0; i &lt; params.length; i++) {

    // Search the style doc to see if there&apos;s an &apos;xsl:param&apos; element with a name matching params[i].name
    paramElem = xsltDoc.evaluate(&apos;//param[@name=&quot;&apos; + params[i].name &apos;&quot;]&apos;, null, XPathResult.ANY_TYPE, null);

    if (paramElem) {

        // Create an &apos;xsl:variable&apos; element and set it&apos;s name to be the same as the &apos;xsl:param&apos;
        newElem = xsltDoc.createElementNS(&apos;http://www.w3.org/1999/XSL/Transform&apos;, &apos;variable&apos;);
        newElem.setAttribute(&apos;name&apos;, params[i].name);

        // Swap in the &apos;xsl:variable&apos; element for the &apos;xsl:param&apos; element
        paramElem.parentNode.replaceChild(newElem, paramElem);

        // Append the parameter node under the &apos;xsl:variable&apos; element
        newElem.appendChild(params[i].value);
    }
}

That&apos;s about it. Go ahead and import the sheet:

processor = new XSLTProcessor();
processor.importStylesheet(xsltDoc);

And then run it through the processor:

resultDoc = processor.transformToDocument(inputDoc);

Note that this approach has the distinct disadvantage of modifying your *XSLT* document. If you need to do multiple transformations, you&apos;ll want to clone the XSLT document and keep a pristine copying before modifying it like this.

I would caution again that the code above is close, but probably has bugs. Sorry I don&apos;t have the original running source to give you.

If you run into issues, feel free to email me directly. My email address is: bedney@technicalpursuit.com

Hope this helps!

Cheers,

- Bill</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498369</commentid>
    <comment_count>19</comment_count>
    <who name="Mike">mrizzo99</who>
    <bug_when>2019-01-25 11:51:33 -0800</bug_when>
    <thetext>Cheers! This is a huge help and I will treat as psuedo-code. I will only bother you if I run into issues I can not work around.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1498376</commentid>
    <comment_count>20</comment_count>
    <who name="William J. Edney">bedney</who>
    <bug_when>2019-01-25 12:02:31 -0800</bug_when>
    <thetext>Mike -

In looking back over this code, I realized that the call to xsltDoc.evaluate() is going to give you back an &apos;XPathResult&apos; object - not the element itself.

More docs can be found here: https://developer.mozilla.org/en-US/docs/Web/API/XPathResult

It was all so long ago... ;-) And the API around &apos;document.evaluate&apos; is pretty weird.

I think what you&apos;ll want is the &apos;.singleNodeValue&apos; of the result.

Sorry in advance to everyone on this bug for the not-quite-interactive debugging session ;-).

Cheers,

- Bill</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887405</commentid>
    <comment_count>21</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-28 12:16:53 -0700</bug_when>
    <thetext>I am still able to reproduce this bug in Safari 15.6 on macOS 12.5 using attached test case and it just shows &apos;Hello[object Element]&apos; and it is same with Chrome Canary 106. Only Firefox Nightly 105 show &quot;Hello World&quot; in this test case. Just wanted to share updated test results. Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>19582</attachid>
            <date>2008-03-07 03:56:30 -0800</date>
            <delta_ts>2008-03-07 03:56:30 -0800</delta_ts>
            <desc>Should render Hello World! when this bug is fixed.</desc>
            <filename>SetParameterTest.html</filename>
            <type>text/html</type>
            <size>1167</size>
            <attacher name="Robbert Broersma">mail</attacher>
            
              <data encoding="base64">PHRpdGxlPlNldFBhcmFtZXRlclRlc3Q8L3RpdGxlPgo8c2NyaXB0IHR5cGU9J3RleHQvamF2YXNj
cmlwdCc+CmZ1bmN0aW9uIHRlc3QoKSB7CiAgdmFyIHBhcnNlciAgICAgPSBuZXcgRE9NUGFyc2Vy
CiAgdmFyIHNlcmlhbGl6ZXIgPSBuZXcgWE1MU2VyaWFsaXplcgoKICB2YXIgeHNsID0gcGFyc2Vy
LnBhcnNlRnJvbVN0cmluZyhbCiAgICAnPHhzbDpzdHlsZXNoZWV0IHZlcnNpb249IjEuMCIgeG1s
bnM6eHNsPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L1hTTC9UcmFuc2Zvcm0iPicsCiAgICAgICc8
eHNsOnBhcmFtIG5hbWU9InBhcmFtIi8+JywKICAgICAgJzx4c2w6dGVtcGxhdGUgbWF0Y2g9Ii8i
PicsCiAgICAgICAgJzxzcGFuPjx4c2w6dmFsdWUtb2Ygc2VsZWN0PSIkcGFyYW0iLz48L3NwYW4+
JywKICAgICAgJzwveHNsOnRlbXBsYXRlPicsCiAgICAnPC94c2w6c3R5bGVzaGVldD4nCiAgXS5q
b2luKCcnKSwgJ2FwcGxpY2F0aW9uL3htbCcpCiAgCiAgdmFyIHhtbCAgPSBwYXJzZXIucGFyc2VG
cm9tU3RyaW5nKCc8bXNnPiBXb3JsZCE8L21zZz4nLCAnYXBwbGljYXRpb24veG1sJykKICB2YXIg
b3V0ICA9IG51bGwKICAKICB2YXIgcHJvY2Vzc29yICA9IG5ldyBYU0xUUHJvY2Vzc29yCiAgcHJv
Y2Vzc29yLmltcG9ydFN0eWxlc2hlZXQoeHNsKQogIHByb2Nlc3Nvci5zZXRQYXJhbWV0ZXIobnVs
bCwgJ3BhcmFtJywgJ0hlbGxvJykKICBvdXQgPSBwcm9jZXNzb3IudHJhbnNmb3JtVG9Eb2N1bWVu
dCh4bWwpCiAgZG9jdW1lbnQuYm9keS5pbm5lckhUTUwgKz0gc2VyaWFsaXplci5zZXJpYWxpemVU
b1N0cmluZyhvdXQpCiAgCiAgcHJvY2Vzc29yID0gbmV3IFhTTFRQcm9jZXNzb3IKICBwcm9jZXNz
b3IuaW1wb3J0U3R5bGVzaGVldCh4c2wpCiAgcHJvY2Vzc29yLnNldFBhcmFtZXRlcihudWxsLCAn
cGFyYW0nLCB4bWwuZG9jdW1lbnRFbGVtZW50KQogIG91dCA9IHByb2Nlc3Nvci50cmFuc2Zvcm1U
b0RvY3VtZW50KHhtbCkKICBkb2N1bWVudC5ib2R5LmlubmVySFRNTCArPSBzZXJpYWxpemVyLnNl
cmlhbGl6ZVRvU3RyaW5nKG91dCkKfQoKd2luZG93Lm9ubG9hZCA9IHRlc3QKPC9zY3JpcHQ+Cjxo
MT5TZXRQYXJhbWV0ZXJUZXN0PC9oMT4KPHA+VGhpcyBzY3JpcHQgc2hvdWxkIG91dHB1dCA8c2Ft
cD5IZWxsbyBXb3JsZCE8L3NhbXA+CjxwcmU+
</data>

          </attachment>
      

    </bug>

</bugzilla>