Is Saxon-JS right by knowing the prefix `fn` in XSLT without it being declared?
Added by Martin Honnen over 2 years ago
I noticed that Saxon-JS doesn't require me to declare the function namespace with prefix fn
but nevertheless allows me to call e.g. fn:substring('foo', 1, 1)
or other function from XPath and XSLT using the prefix fn
.
I wonder whether that is spec compliant, the XSLT 3 spec doesn't predefine fn
, I think, and Saxon Java certainly in XSLT requires me to declare e.g. xmlns:fn="..."
to be able to use it.
Replies (3)
Please register to reply
RE: Is Saxon-JS right by knowing the prefix `fn` in XSLT without it being declared? - Added by Martin Honnen over 2 years ago
To explain in more detail, when I run a file like
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all"
expand-text="yes">
<xsl:template match="/" name="xsl:initial-template">
<xsl:comment>Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
<test>{fn:current-dateTime()}</test>
</xsl:template>
</xsl:stylesheet>
through SaxonCS or Saxon Java (-it -xsl:fn-test1.xsl
) I get an error message like Error at on line 11 column 6 of fn-test1.xsl: XPST0081 Namespace prefix 'fn' has not been declared
while running it with xslt3 -it -xsl:fn-test1.xsl
through SaxonJS outputs the result of the transformation e.g. <?xml version="1.0" encoding="UTF-8"?><!--Run with Saxon-JS 2.3 Node.js--><test>2022-05-26T08:59:56.704+02:00</test>
.
RE: Is Saxon-JS right by knowing the prefix `fn` in XSLT without it being declared? - Added by Martin Honnen over 2 years ago
I guess the "support" for the fn
namespace without declaration in SaxonJS might result from running the XSLT with SaxonJS.XPath.evaluate
through fn:transform
and for XPath.evaluate
the documentation states about the namespaceContext
: "For convenience the usual namespaces for prefixes xml, fn, xs, map, array, math, and saxon are defined by default, but can be overwritten.".
RE: Is Saxon-JS right by knowing the prefix `fn` in XSLT without it being declared? - Added by Norm Tovey-Walsh over 2 years ago
I guess the "support" for the fn namespace without declaration in
SaxonJS might result from running the XSLT with SaxonJS.XPath.evaluate
through fn:transform and for XPath.evaluate the documentation states
about the namespaceContext: "For convenience the usual namespaces for
prefixes xml, fn, xs, map, array, math, and saxon are defined by
default, but can be
overwritten.".
I think that’s a bug, https://saxonica.plan.io/issues/5540
Thank you!
Be seeing you,
norm
--
Norm Tovey-Walsh
Saxonica
Please register to reply