Project

Profile

Help

Feature #5558 ยป Re_ [SaxonJS - Feature #5558] Allow clients of SaxonJS to supply a map of custom XPath functions with arbitrary names - 2022-06-19T16_06_11Z.eml

John Lumley, 2022-06-19 18:06

 
X-He-Spam-Score: -1.8
Return-Path: <john@saxonica.com>
Delivered-To: dropbox@plan.io
Received: from m.launch.gmbh ([127.0.0.1])
by m.launch.gmbh with LMTP id sKOpB2ZJr2LnAwAAJzdhvw
for <dropbox@plan.io>; Sun, 19 Jun 2022 18:05:58 +0200
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on m.launch.gmbh
X-Spam-Level:
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DMARC_NONE,
HTML_MESSAGE,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,
SPF_NONE,SPF_NONE_IGNORE,T_SCC_BODY_TEXT_LINE autolearn=ham
autolearn_force=no version=3.4.2
X-Spam-Report:
* -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
* [score: 0.0000]
* -2.0 SPF_NONE_IGNORE m.launch.gmbh does not consider absent SPF
* records
* 0.1 DMARC_NONE DMARC record not found
* 2.0 SPF_NONE SPF record not found
* 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
* -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at
* https://www.dnswl.org/, no trust
* [216.69.139.26 listed in list.dnswl.org]
* 0.0 HTML_MESSAGE BODY: HTML included in message
* 0.0 MIME_QP_LONG_LINE RAW: Quoted-printable line longer than 76
* chars
* -0.0 T_SCC_BODY_TEXT_LINE No description available.
X-Spam-Score: -1.8
Envelope-to: inbox+saxonica+f38e+saxon-js@plan.io
Authentication-Results: m.launch.gmbh; dmarc=none (p=none dis=none) header.from=saxonica.com
Authentication-Results: m.launch.gmbh; spf=none smtp.mailfrom=john@saxonica.com
Authentication-Results: m.launch.gmbh; dkim=none; dkim-atps=neutral
Received: from p3plwbeout26-02.prod.phx3.secureserver.net (p3plsmtp26-02-2.prod.phx3.secureserver.net [216.69.139.26])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(No client certificate requested)
by m.launch.gmbh (Postfix) with ESMTPS id 84B2A80183
for <inbox+saxonica+f38e+saxon-js@plan.io>; Sun, 19 Jun 2022 18:05:56 +0200 (CEST)
Received: from mailex.mailcore.me ([94.136.40.145])
by :WBEOUT: with ESMTP
id 2xQvobqBaFTy72xQwo3vdn; Sun, 19 Jun 2022 09:05:54 -0700
X-CMAE-Analysis: v=2.4 cv=ZYzYiuZA c=1 sm=1 tr=0 ts=62af4962
a=7e6w4QD8YWtpVJ/7+iiidw==:117 a=XXgOmvgD/DgxtqSJiqOVbg==:17
a=JAfHjSUo51sA:10 a=JPEYwPQDsx4A:10 a=zKiKQOHbAAAA:8 a=cQMRii327zD9vi9h6X0A:9
a=QEXdDO2ut3YA:10 a=TeuQqM9sAAAA:8 a=wKCMAhblaHnUOi2IXTUA:9
a=Md4vSm8xouuzcQ6P:21 a=_W_S_7VecoQA:10 a=lIhSIjdgpsPn7NjMZNrW:22
X-SECURESERVER-ACCT: john@saxonica.com
X-SID: 2xQvobqBaFTy7
Received: from host86-186-195-162.range86-186.btcentralplus.com ([86.186.195.162] helo=smtpclient.apple)
by smtp02.mailcore.me with esmtpa (Exim 4.94.2)
(envelope-from <john@saxonica.com>)
id 1o2xQu-000Bsa-Lz
for inbox+saxonica+f38e+saxon-js@plan.io; Sun, 19 Jun 2022 17:05:53 +0100
Content-Type: multipart/alternative; boundary=Apple-Mail-796C48BC-12C1-4E6B-95ED-C890F39AD095
Content-Transfer-Encoding: 7bit
From: John Lumley <john@saxonica.com>
Mime-Version: 1.0 (1.0)
Subject: Re: [SaxonJS - Feature #5558] Allow clients of SaxonJS to supply a map of custom XPath functions with arbitrary names
Date: Sun, 19 Jun 2022 17:05:50 +0100
Message-Id: <302A5824-11EF-4620-9DCD-FD95DEA86807@saxonica.com>
References: <redmine.journal-21085.20220616005821.223@plan.io>
In-Reply-To: <redmine.journal-21085.20220616005821.223@plan.io>
To: Saxonica Developer Community <inbox+saxonica+f38e+saxon-js@plan.io>
X-Mailer: iPad Mail (18H107)
X-Mailcore-Auth: 439400283
X-Mailcore-Domain: 1881035
X-123-reg-Authenticated: john@saxonica.com
X-Originating-IP: 86.186.195.162
X-CMAE-Envelope: MS4xfJQR/SOg+UxR5z9gB5gxKBiHRtGvseFkUlFvu8lXGt5kC31tVoblMhS4erA055uTbHXtZkSY8sFWHzSF1YtyiNB5ItjiMG8q0mA8+NlIQu8D0XmG4ag0
ZMGW+aytwAi4lV42d9aT1g4IgwG2lyV0cyWTGz4lW5G+Mc5RyVfZGEOr0CB8BhWPROKfkI6Bih9Cr4TfkeMl9D1CoGK8HRLubtk=


--Apple-Mail-796C48BC-12C1-4E6B-95ED-C890F39AD095
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable

You will need a mechanism to supply a function type signature, if only to es=
tablish the arity and deeper to declare types of arguments and return. Witho=
ut the latter, especially for arguments, you could get any form of argument s=
upplied at runtime with no hope of any form of graceful type-mismatch recove=
ry, unless your function deliberately does its own runtime type-checking, wh=
ich will probably be expensive=E2=80=A6

John Lumley=20

Sent from my iPad

> On 16 Jun 2022, at 01:58, Saxonica Developer Community <notifications@plan=
.io> wrote:
>=20
> =EF=BB=BF
> --- In your reply, please do not write below this line ---
>=20
> Issue #5558 has been updated by Conal Tuohy.
> Accidentally/stupidly posted the above note instead of previewing it. I ca=
n't see a way to edit or delete it, so ... sorry for the evident misreading o=
f your note: I do see that xsl:function doesn't imply the use of XSLT, and i=
t's just about declaration.
>=20
> I like it; it looks like it will do what I am hoping for. Pre-registering t=
he functions with the runtime is obviously better than passing them to an ev=
aluate call every time.
>=20
> I wonder about the need for an explicit declaration (at the XPath level) o=
f the parameters and return type, though? I can see how it would enable the r=
untime to perform type-coercion when marshaling parameters and results, e.g.=
to convert a number returned by a JS function into an xs:string or somethin=
g if that's how the function's been declared. It seems to me, though, that a=
n implementer at the JS level could just return JavaScript objects that have=
a well-defined mapping anyway; such as arrays, objects, functions, and othe=
rwise you can use SaxonJS.atom to return particular types from their JS func=
tions. Maybe the convenience of having the runtime do that for you is worth i=
t, though, and maybe there's some other reason to have an explicit declarati=
on, which I'm not seeing?
>=20
> Feature #5558: Allow clients of SaxonJS to supply a map of custom XPath fu=
nctions with arbitrary names OPEN
> Author: Conal Tuohy
> Status: In Progress
> Priority: High
> Category: API
> Sprint/Milestone: SaxonJS 3.0
> Start date: 2022-06-10
> Company:
> Contact person:
> Additional contact persons:
> There's an existing mechanism whereby JavaScript functions which are in th=
e global Window scope are automatically made available as XPath functions in=
a "js:" namespace, but this excludes use cases where it's desirable to add c=
ustom implementation functions in some standard namespace, e.g. the EXPath f=
unction libraries, XProc's XPath extension functions, etc.
>=20
> I'd like to see this appear in the API in the same way that params member o=
f the options object appears in the evaluate function; i.e. as an additional=
functions member of options, whose value is a JavaScript object mapping QNa=
mes to JavaScript functions.
>=20
> You have received this notification because you have either subscribed to o=
r are involved in a project on Saxonica Developer Community site. To change y=
our notification preferences, please click here: https://saxonica.plan.io/my=
/account?tour=3Dmail_preferences
>=20
>=20
> This notification was cheerfully delivered by

--Apple-Mail-796C48BC-12C1-4E6B-95ED-C890F39AD095
Content-Type: text/html;
charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto">You will need a mechanism to supply a funct=
ion type signature, if only to establish the arity and deeper to declare typ=
es of arguments and return. Without the latter, especially for arguments, yo=
u could get any form of argument supplied at runtime with no hope of any for=
m of graceful type-mismatch recovery, unless your function deliberately does=
its own runtime type-checking, which will probably be expensive=E2=80=A6<di=
v><br></div><div>John Lumley&nbsp;<br><br><div dir=3D"ltr">Sent from my iPad=
</div><div dir=3D"ltr"><br><blockquote type=3D"cite">On 16 Jun 2022, at 01:5=
8, Saxonica Developer Community &lt;notifications@plan.io&gt; wrote:<br><br>=
</blockquote></div><blockquote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF


<!--[if !mso]><!-- -->
<link href=3D"https://assets.plan.io/stylesheets/fonts.css" rel=3D"styleshee=
t" type=3D"text/css">
<!--<![endif]-->

<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8"><st=
yle>a:link{color:#0088b7}
a:visited{color:#0088b7}
a:hover{color:#0088b7}
a:active{color:#0088b7}</style>

<table class=3D"planio_mail" width=3D"100%" cellspacing=3D"0" cellpadding=3D=
"0" style=3D"border-collapse:collapse;margin-bottom:1em;border:1px solid #bb=
b;padding:4px;border-spacing:0;margin-bottom:0;width:100%;border:none;paddin=
g:0">
<tbody><tr><td class=3D"planio_mail header" style=3D"border:1px solid #bbb;p=
adding:4px;text-align:center;width:100%;font-family:MarketWeb, Helvetica, Ar=
ial, sans-serif;font-size:0.8em;color:#D7D7D7;border:none;padding:0"><p>--- I=
n your reply, please do not write below this line ---</p></td></tr>
<tr><td class=3D"planio_mail" style=3D"border:1px solid #bbb;padding:4px;bor=
der:none;padding:0">Issue <a href=3D"https://saxonica.plan.io/issues/5558?pn=
=3D1#change-21085" style=3D"color:#0088b7">#5558</a> has been updated by Con=
al Tuohy.
<hr style=3D"width:100%;height:1px;background:#ccc;border:0;margin:1.2em 0">=


<ul class=3D"journal details" style=3D"color:#959595;margin-bottom:1.5em">
</ul>

<p>Accidentally/stupidly posted the above note instead of previewing it. I c=
an't see a way to edit or delete it, so ... sorry for the evident misreading=
of your note: I do see that <code style=3D"font-family:Hack, Consolas, Menl=
o, &quot;Liberation Mono&quot;, Courier, monospace;font-size:85%;background-=
color:#ececec;word-wrap:break-word;border-radius:3px;padding:0.2em;margin:0"=
>xsl:function</code> doesn't imply the use of XSLT, and it's just about decl=
aration.</p>
<p>I like it; it looks like it will do what I am hoping for. Pre-registering=
the functions with the runtime is obviously better than passing them to an <=
code style=3D"font-family:Hack, Consolas, Menlo, &quot;Liberation Mono&quot;=
, Courier, monospace;font-size:85%;background-color:#ececec;word-wrap:break-=
word;border-radius:3px;padding:0.2em;margin:0">evaluate</code> call every ti=
me.</p>
<p>I wonder about the need for an explicit declaration (at the XPath level) o=
f the parameters and return type, though? I can see how it would enable the r=
untime to perform type-coercion when marshaling parameters and results, e.g.=
to convert a number returned by a JS function into an xs:string or somethin=
g if that's how the function's been declared. It seems to me, though, that a=
n implementer at the JS level could just return JavaScript objects that have=
a well-defined mapping anyway; such as arrays, objects, functions, and othe=
rwise you can use <code style=3D"font-family:Hack, Consolas, Menlo, &quot;Li=
beration Mono&quot;, Courier, monospace;font-size:85%;background-color:#ecec=
ec;word-wrap:break-word;border-radius:3px;padding:0.2em;margin:0">SaxonJS.at=
om</code> to return particular types from their JS functions. Maybe the conv=
enience of having the runtime do that for you is worth it, though, and maybe=
there's some other reason to have an explicit declaration, which I'm not se=
eing?</p>
<hr style=3D"width:100%;height:1px;background:#ccc;border:0;margin:1.2em 0">=

<h1 style=3D"font-family:&quot;ProximaNova-Bold&quot;, Helvetica, Arial, san=
s-serif;font-weight:normal;margin:0px;font-size:1.3em;line-height:1.4em">
<a href=3D"https://saxonica.plan.io/issues/5558?pn=3D1#change-21085" style=
=3D"color:#0088b7;text-decoration:none">Feature #5558: Allow clients of Saxo=
nJS to supply a map of custom XPath functions with arbitrary names</a>
<span class=3D"badge badge-status-open" style=3D"position:relative;font-we=
ight:bold;font-size:10px;bottom:2px;padding:1px 3px;margin-right:2px;margin-=
left:2px;border-radius:2px;text-transform:uppercase;text-decoration:none;col=
or:#205D86;border:1px solid #205D86">open</span>
</h1>

<ul class=3D"details" style=3D"color:#959595;margin-bottom:1.5em"><li><stron=
g>Author: </strong>Conal Tuohy</li>
<li><strong>Status: </strong>In Progress</li>
<li><strong>Priority: </strong>High</li>
<li><strong>Category: </strong>API</li>
<li><strong>Sprint/Milestone: </strong>SaxonJS 3.0</li>
<li><strong>Start date: </strong>2022-06-10</li>
<li><strong>Company: </strong></li>
<li><strong>Contact person: </strong></li>
<li><strong>Additional contact persons: </strong></li></ul>

<p>There's an existing mechanism whereby JavaScript functions which are in t=
he global Window scope are automatically made available as XPath functions i=
n a "js:" namespace, but this excludes use cases where it's desirable to add=
custom implementation functions in some standard namespace, e.g. the EXPath=
function libraries, XProc's XPath extension functions, etc.</p>
<p>I'd like to see this appear in the API in the same way that <code style=3D=
"font-family:Hack, Consolas, Menlo, &quot;Liberation Mono&quot;, Courier, mo=
nospace;font-size:85%;background-color:#ececec;word-wrap:break-word;border-r=
adius:3px;padding:0.2em;margin:0">params</code> member of the <code style=3D=
"font-family:Hack, Consolas, Menlo, &quot;Liberation Mono&quot;, Courier, mo=
nospace;font-size:85%;background-color:#ececec;word-wrap:break-word;border-r=
adius:3px;padding:0.2em;margin:0">options</code> object appears in the <code=
style=3D"font-family:Hack, Consolas, Menlo, &quot;Liberation Mono&quot;, Co=
urier, monospace;font-size:85%;background-color:#ececec;word-wrap:break-word=
;border-radius:3px;padding:0.2em;margin:0">evaluate</code> function; i.e. as=
an additional <code style=3D"font-family:Hack, Consolas, Menlo, &quot;Liber=
ation Mono&quot;, Courier, monospace;font-size:85%;background-color:#ececec;=
word-wrap:break-word;border-radius:3px;padding:0.2em;margin:0">functions</co=
de> member of <code style=3D"font-family:Hack, Consolas, Menlo, &quot;Libera=
tion Mono&quot;, Courier, monospace;font-size:85%;background-color:#ececec;w=
ord-wrap:break-word;border-radius:3px;padding:0.2em;margin:0">options</code>=
, whose value is a JavaScript object mapping QNames to JavaScript functions.=
</p>


<div itemscope=3D"itemscope" itemtype=3D"http://schema.org/EmailMessage"><di=
v itemscope=3D"itemscope" itemprop=3D"action" itemtype=3D"http://schema.org/=
ViewAction"><link itemprop=3D"url" href=3D"https://saxonica.plan.io/issues/5=
558?pn=3D1#change-21085"><meta itemprop=3D"name" content=3D"View Issue"></di=
v><meta itemprop=3D"description" content=3D"View this issue update on Planio=
"></div>

</td></tr>
<tr><td class=3D"planio_mail footer" style=3D"border:1px solid #bbb;padding:=
4px;font-size:0.8em;width:100%;border:none;padding:0"><hr style=3D"width:100=
%;height:1px;background:#ccc;border:0;margin:1.2em 0"><p>You have received t=
his notification because you have either subscribed to or are involved in a p=
roject on Saxonica Developer Community site.
To change your notification preferences, please click here: <a href=3D"https=
://saxonica.plan.io/my/account?tour=3Dmail_preferences" class=3D"external" s=
tyle=3D"color:#0088b7">https://saxonica.plan.io/my/account?tour=3Dmail_prefe=
rences</a></p></td></tr>
<tr><td class=3D"planio_mail planio_footer" style=3D"border:1px solid #bbb;p=
adding:4px;text-align:center;width:100%;font-family:MarketWeb, Helvetica, Ar=
ial, sans-serif;font-size:1.2em;color:#D7D7D7;border:none;padding:0"><br><di=
v><a href=3D"https://plan.io/" style=3D"color:#0088b7;color:#D7D7D7;text-dec=
oration:none">This notification was cheerfully delivered by</a></div></td></=
tr>
<tr><td class=3D"planio_mail planio_footer_logo" style=3D"border:1px solid #=
bbb;padding:4px;text-align:center;width:100%;border:none;padding:0"><a href=3D=
"https://plan.io/" title=3D"Planio" style=3D"color:#0088b7"><img src=3D"http=
s://assets.plan.io/images/planio_logo_gray_204x50.png" height=3D"25" width=3D=
"102" border=3D"0" alt=3D"Planio" style=3D"vertical-align:middle;border:none=
" data-unique-identifier=3D""></a></td></tr>
</tbody></table>


</div></blockquote></div></body></html>=

--Apple-Mail-796C48BC-12C1-4E6B-95ED-C890F39AD095--
    (1-1/1)