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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29470</bug_id>
          
          <creation_ts>2016-02-16 08:42:59 +0000</creation_ts>
          <short_desc>[xslt30] Polyfills</short_desc>
          <delta_ts>2016-10-06 18:42:31 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.braaksma</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>125069</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-16 08:42:59 +0000</bug_when>
    <thetext>Javascript programmers have become used to the idea that the function library gradually grows, with different functions being available in different implementations, and the availability of a particular function sometimes preceding and sometimes following standardisation. The solution to the diversity among implementations is the concept of a &quot;polyfill&quot; - a user-written implementation of a standard function designed to fill a gap in a vendor-supplied function library. The result is imperfect, but it goes some way towards achieving the goal of interoperability without stagnation.

We&apos;ve got a similar concept with &lt;xsl:function override-extension-function=&quot;yes&quot;/&gt; which is explicitly designed to allow users to define an implementation of a function that is present in some implementations but not others. However, we have rather crippled the capability by the fact that the function can&apos;t be defined in a reserved namespace.

Suppose there&apos;s a new standard (either XSLT or XPath or some completely separate spec) that decides to define an array:put() method (an omission which I was suprised to discover this morning). This will immediately be added to some products but not to others. Users can work around this using use-when and function-available. They could even bind a variable conditionally to either array:put#3 or my:put#3 and then do dynamic function calls (assuming everyone implements higher-order-functions...). But how much simpler if they could simply write:

&lt;xsl:function name=&quot;array:put&quot; override-extension-function=&quot;yes&quot;&gt;
 &lt;xsl:param name=&quot;array&quot;/&gt;
 &lt;xsl:param name=&quot;index&quot;/&gt;
 &lt;xsl:param name=&quot;value&quot;/&gt;
 &lt;xsl:sequence select=&quot;$array =&gt; array:remove($index) =&gt; array:insert-before($index, $value)&quot;/&gt;
&lt;/xsl:function&gt;

I would suggest the following changes to our rules: 

(a) a user-written function is allowed to be defined in a reserved namespace provided that the override-extension-function attribute is present (it can say either &quot;yes&quot; or &quot;no&quot;, but must be explicit).

(b) an extension function is allowed to be defined in a reserved namespace [OPTION: provided that it conforms with a specification that has been published, proposed, or accepted by the authority for that namespace]. Note that such an extension function can always be overridden by a user function under rule (a).

With these rules, we (that is, anyone acting under W3C process) could put together a one-page spec for an array:put function, publish it as a free-standing W3C spec, and implementors could then legally add it to their processors, without any need for a change in the XSLT spec.

I don&apos;t propose changing the spelling of the override-extension-function attribute to reflect the revised semantics.

Because this change does not require any changes to existing implementations or stylesheets (it permits such changes but does not require them), I see no difficulty with making it during CR.

Michael Kay
Saxonica</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125070</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-16 08:44:37 +0000</bug_when>
    <thetext>Suggested specification outline:

Rules for Polyfill functions

A polyfill is a user-written function in a reserved namespace
A polyfill SHOULD NOT be defined unless it implements a specification issued by the authority for that namespace
A polyfill function MUST specify a value (yes or no) for the override-extension-function attribute [which is interpreted as override-vendor-function...]
Something about having package scope...
?Allow xsl:original

Notes

Valid reasons for using a polyfill include:

The vendor has not implemented the function (e.g. xs:dateTimeStamp)
The vendor&apos;s implementation of the function is non-conformant
The vendor&apos;s implementation of the function does not meet performance requirements
The specification of the function leaves aspects implementation-dependent or -defined, and this causes interoperability problems (e.g. the vendor&apos;s implementation of normalize-unicode does not provide a required normalization form)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125090</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-16 13:47:32 +0000</bug_when>
    <thetext>While recognizing the benefits, we also found some complications:

(a) It&apos;s not clear what the effect on static expressions would be

(b) It could be disruptive for some implementations that make built-in assumptions about the behaviour of built-in functions

(c) We might need rules about compatibility of signatures between a polyfill function and the built-in version.

So we&apos;re abandoning the proposal for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125181</commentid>
    <comment_count>3</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-02-20 15:06:14 +0000</bug_when>
    <thetext>(In reply to Michael Kay from comment #2)
&gt; So we&apos;re abandoning the proposal for now.
For reference, discussion continued in the Public XSLWG Mailing List: https://lists.w3.org/Archives/Public/public-xsl-wg/2016Feb/0009.html</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>