xsl:evaluate problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

xsl:evaluate problem

Toshihiko Makita
I'm testing XSLT 3.0 xsl:evaluate instruction. The following stylesheet
works fine in Saxon-EE 9.7.0.15 (Bundled with oXygen 19.0).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ahf="http://www.antennahouse.com/names/XSLT/Functions/Document"
     exclude-result-prefixes="xs"
     version="3.0">

     <xsl:template match="/">
         <xsl:variable name="currentDate" as="xs:date"
select="current-date()"/>
         <xsl:variable name="nextDate" as="xs:date">
             <xsl:evaluate xpath="'ahf:getNextDate($today)'">
                 <xsl:with-param name="today" select="$currentDate"/>
             </xsl:evaluate>
         </xsl:variable>
         <xsl:message select="'Today is',$currentDate,',thus tomorrow is
',$nextDate"></xsl:message>
     </xsl:template>

     <xsl:function name="ahf:getNextDate" as="xs:date">
         <xsl:param name="prmDate" as="xs:date"/>
         <xsl:variable name="oneDay" as="xs:dayTimeDuration"
select="xs:dayTimeDuration('P1D')"/>
         <xsl:sequence select="$prmDate + $oneDay"/>
     </xsl:function>

</xsl:stylesheet>

[Output]
Today is 2017-08-01+09:00 ,thus tomorrow is  2017-08-02+09:00

However Saxon-EE 9.8.0.3J reports the static error:

C:\Users\toshi\OneDrive\Documents\test\xslt\20170801-evaluate>java -jar
D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar -s:input.xml
-o:output-saxon.xml -xsl:test.xsl -t
Saxon-EE 9.8.0.3J from Saxonica
Java version 1.8.0_60
Using license serial number V005977
Stylesheet compilation time: 1.36231s (1362.310136ms)
Processing
file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
Using parser
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for
file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 9.65357ms
Tree size: 3 nodes, 0 characters, 0 attributes
Error in xsl:evaluate/@xpath on line 11 column 61 of test.xsl:
   XTDE3160: Static error in XPath expression supplied to xsl:evaluate:
Cannot find a  matching 1-argument function named
{http://www.antennahouse.com/names/XSLT/Functions/Document}getNextDate().
Expression:
   {ahf:getNextDate($today)}
Static error in XPath expression supplied to xsl:evaluate: Cannot find a
matching 1-argument function named {http://www.
antennahouse.com/names/XSLT/Functions/Document}getNextDate().
Expression: {ahf:getNextDate($today)}

Are there any changes between these two versions?

Regards,

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xsl:evaluate problem

Michael Kay
I note you're invoking it using the -jar option on the command line, which means that Saxon will be the only thing on the classpath.

Does the extension function call if invoked directly from the stylesheet rather than dynamically using xsl:evaluate?

Try with the -TJ option on the command line which gives diagnostic information about the attempt to load reflexive extension functions.

Michael Kay
Saxonica

> On 1 Aug 2017, at 16:03, Toshihiko Makita <[hidden email]> wrote:
>
> I'm testing XSLT 3.0 xsl:evaluate instruction. The following stylesheet works fine in Saxon-EE 9.7.0.15 (Bundled with oXygen 19.0).
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>    xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:ahf="http://www.antennahouse.com/names/XSLT/Functions/Document"
>    exclude-result-prefixes="xs"
>    version="3.0">
>
>    <xsl:template match="/">
>        <xsl:variable name="currentDate" as="xs:date" select="current-date()"/>
>        <xsl:variable name="nextDate" as="xs:date">
>            <xsl:evaluate xpath="'ahf:getNextDate($today)'">
>                <xsl:with-param name="today" select="$currentDate"/>
>            </xsl:evaluate>
>        </xsl:variable>
>        <xsl:message select="'Today is',$currentDate,',thus tomorrow is ',$nextDate"></xsl:message>
>    </xsl:template>
>
>    <xsl:function name="ahf:getNextDate" as="xs:date">
>        <xsl:param name="prmDate" as="xs:date"/>
>        <xsl:variable name="oneDay" as="xs:dayTimeDuration" select="xs:dayTimeDuration('P1D')"/>
>        <xsl:sequence select="$prmDate + $oneDay"/>
>    </xsl:function>
>
> </xsl:stylesheet>
>
> [Output]
> Today is 2017-08-01+09:00 ,thus tomorrow is  2017-08-02+09:00
>
> However Saxon-EE 9.8.0.3J reports the static error:
>
> C:\Users\toshi\OneDrive\Documents\test\xslt\20170801-evaluate>java -jar D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar -s:input.xml -o:output-saxon.xml -xsl:test.xsl -t
> Saxon-EE 9.8.0.3J from Saxonica
> Java version 1.8.0_60
> Using license serial number V005977
> Stylesheet compilation time: 1.36231s (1362.310136ms)
> Processing file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
> Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
> Building tree for file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml using class net.sf.saxon.tree.tiny.TinyBuilder
> Tree built in 9.65357ms
> Tree size: 3 nodes, 0 characters, 0 attributes
> Error in xsl:evaluate/@xpath on line 11 column 61 of test.xsl:
>  XTDE3160: Static error in XPath expression supplied to xsl:evaluate: Cannot find a  matching 1-argument function named
> {http://www.antennahouse.com/names/XSLT/Functions/Document}getNextDate(). Expression:
>  {ahf:getNextDate($today)}
> Static error in XPath expression supplied to xsl:evaluate: Cannot find a matching 1-argument function named {http://www.
> antennahouse.com/names/XSLT/Functions/Document}getNextDate(). Expression: {ahf:getNextDate($today)}
>
> Are there any changes between these two versions?
>
> Regards,
>
> --
> /*--------------------------------------------------
> Toshihiko Makita
> Development Group. Antenna House, Inc. Ina Branch
> Web site:
> http://www.antenna.co.jp/
> http://www.antennahouse.com/
> --------------------------------------------------*/
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xsl:evaluate problem

Toshihiko Makita
Setting xsl:function/@visiblity="public" solved this problem.

     <xsl:function name="ahf:getNextDate" as="xs:date" visibility="public">
         <xsl:param name="prmDate" as="xs:date"/>
         <xsl:variable name="oneDay" as="xs:dayTimeDuration"
select="xs:dayTimeDuration('P1D')"/>
         <xsl:sequence select="$prmDate + $oneDay"/>
     </xsl:function>

The execution log:

C:\Users\toshi\OneDrive\Documents\test\xslt\20170801-evaluate>java -jar
D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar -s:input.xml
-o:output-saxon.xml -xsl:test.xsl -t -TJ
Saxon-EE 9.8.0.3J from Saxonica
Java version 1.8.0_131
Using license serial number V005977
Saxon evaluation license expires in 14 days
Looking for function {http://www.w3.org/2001/XMLSchema}dayTimeDuration#1
Trying com.saxonica.functions.registry.XSLT30HOFunctionSet
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Trying net.sf.saxon.functions.FunctionLibraryList
Looking for function {http://www.w3.org/2001/XMLSchema}dayTimeDuration#1
Trying com.saxonica.ee.extfn.VendorFunctionSetEE
Trying net.sf.saxon.functions.MathFunctionSet
Trying net.sf.saxon.ma.map.MapFunctionSet
Trying net.sf.saxon.ma.arrays.ArrayFunctionSet
Trying net.sf.saxon.functions.registry.ExsltCommonFunctionSet
Trying com.saxonica.functions.extfn.EXPathFileFunctionSet
Function {http://www.w3.org/2001/XMLSchema}dayTimeDuration not found!
Trying net.sf.saxon.functions.registry.ConstructorFunctionLibrary
Stylesheet compilation time: 316.343825ms
Processing
file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
Using parser
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for
file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 2.016953ms
Tree size: 3 nodes, 0 characters, 0 attributes
Looking for function {http://www.w3.org/2005/xpath-functions}current-date#0
Trying com.saxonica.functions.registry.XSLT30HOFunctionSet
Looking for function
{http://www.antennahouse.com/names/XSLT/Functions/Document}getNextDate#1
Trying com.saxonica.functions.registry.XPath31HOFunctionSet
Trying net.sf.saxon.style.PublicStylesheetFunctionLibrary
Today is 2017-08-02+09:00 ;thus tomorrow is  2017-08-03+09:00
Execution time: 75.120758ms
Memory used: 27,410,536

It seems that there is implementation differences between 9.7.0.15 and
9.8.0.3. Is xsl:function/@visibility="public" indispensable in
xsl:stylesheet module if it is used from xsl:evaluate/@xpath?

Regards,

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/



On 2017/08/02 2:11, Michael Kay wrote:

> I note you're invoking it using the -jar option on the command line, which means that Saxon will be the only thing on the classpath.
>
> Does the extension function call if invoked directly from the stylesheet rather than dynamically using xsl:evaluate?
>
> Try with the -TJ option on the command line which gives diagnostic information about the attempt to load reflexive extension functions.
>
> Michael Kay
> Saxonica
>
>> On 1 Aug 2017, at 16:03, Toshihiko Makita <[hidden email]> wrote:
>>
>> I'm testing XSLT 3.0 xsl:evaluate instruction. The following stylesheet works fine in Saxon-EE 9.7.0.15 (Bundled with oXygen 19.0).
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>     xmlns:xs="http://www.w3.org/2001/XMLSchema"
>> xmlns:ahf="http://www.antennahouse.com/names/XSLT/Functions/Document"
>>     exclude-result-prefixes="xs"
>>     version="3.0">
>>
>>     <xsl:template match="/">
>>         <xsl:variable name="currentDate" as="xs:date" select="current-date()"/>
>>         <xsl:variable name="nextDate" as="xs:date">
>>             <xsl:evaluate xpath="'ahf:getNextDate($today)'">
>>                 <xsl:with-param name="today" select="$currentDate"/>
>>             </xsl:evaluate>
>>         </xsl:variable>
>>         <xsl:message select="'Today is',$currentDate,',thus tomorrow is ',$nextDate"></xsl:message>
>>     </xsl:template>
>>
>>     <xsl:function name="ahf:getNextDate" as="xs:date">
>>         <xsl:param name="prmDate" as="xs:date"/>
>>         <xsl:variable name="oneDay" as="xs:dayTimeDuration" select="xs:dayTimeDuration('P1D')"/>
>>         <xsl:sequence select="$prmDate + $oneDay"/>
>>     </xsl:function>
>>
>> </xsl:stylesheet>
>>
>> [Output]
>> Today is 2017-08-01+09:00 ,thus tomorrow is  2017-08-02+09:00
>>
>> However Saxon-EE 9.8.0.3J reports the static error:
>>
>> C:\Users\toshi\OneDrive\Documents\test\xslt\20170801-evaluate>java -jar D:\My_Documents\Java\SaxonEE9-8-0-3J\saxon9ee.jar -s:input.xml -o:output-saxon.xml -xsl:test.xsl -t
>> Saxon-EE 9.8.0.3J from Saxonica
>> Java version 1.8.0_60
>> Using license serial number V005977
>> Stylesheet compilation time: 1.36231s (1362.310136ms)
>> Processing file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml
>> Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
>> Building tree for file:/C:/Users/toshi/OneDrive/Documents/test/xslt/20170801-evaluate/input.xml using class net.sf.saxon.tree.tiny.TinyBuilder
>> Tree built in 9.65357ms
>> Tree size: 3 nodes, 0 characters, 0 attributes
>> Error in xsl:evaluate/@xpath on line 11 column 61 of test.xsl:
>>   XTDE3160: Static error in XPath expression supplied to xsl:evaluate: Cannot find a  matching 1-argument function named
>> {http://www.antennahouse.com/names/XSLT/Functions/Document}getNextDate(). Expression:
>>   {ahf:getNextDate($today)}
>> Static error in XPath expression supplied to xsl:evaluate: Cannot find a matching 1-argument function named {http://www.
>> antennahouse.com/names/XSLT/Functions/Document}getNextDate(). Expression: {ahf:getNextDate($today)}
>>
>> Are there any changes between these two versions?
>>
>> Regards,
>>
>> --
>> /*--------------------------------------------------
>> Toshihiko Makita
>> Development Group. Antenna House, Inc. Ina Branch
>> Web site:
>> http://www.antenna.co.jp/
>> http://www.antennahouse.com/
>> --------------------------------------------------*/
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
>

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail [hidden email]
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xsl:evaluate problem

Michael Kay

> On 2 Aug 2017, at 01:50, Toshihiko Makita <[hidden email]> wrote:
>
> Setting xsl:function/@visiblity="public" solved this problem.
>
>

That's good. I don't know why I had assumed it was an extension function rather than a stylesheet function.

> It seems that there is implementation differences between 9.7.0.15 and 9.8.0.3. Is xsl:function/@visibility="public" indispensable in xsl:stylesheet module if it is used from xsl:evaluate/@xpath?
>

There were some XSLT 3.0 spec changes between the 2015 CR and the final REC, but more importantly, there was a lot more testing in 9.8 and a lot more attention to details of edge cases particular in the area of packages. In this case the spec didn't change, but the implementation followed it more precisely.

Section 10.4.1 says that the static context for the dynamic XPath expression includes:

        • All user-defined functions present in the containing package provided their visibility is not hidden or private;

Since xsl:function declarations are private by default, this means you must set visibility=public to make the function available for dynamic calling.

This is a good thing from the point of view of optimization, since it means that optimizers can inline or eliminate private functions without worrying about the possibility of dynamic access to the function.

Michael Kay
Saxonica


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: xsl:evaluate problem

Toshihiko Makita
On 2017/08/02 18:28, Michael Kay wrote:
> Section 10.4.1 says that the static context for the dynamic XPath
> expression includes:
> • All user-defined functions present in the containing package provided their visibility is not hidden or private;
> Since xsl:function declarations are private by default, this means you must set visibility=public to make the function available for dynamic calling.

Thank you for your explanation. I could understand the specification and the result of 9.8.0.3 is correct.

Regards,

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...