Array support in 9.7 HE in match pattern

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

Array support in 9.7 HE in match pattern

Martin Honnen-2

As far as I understand it, the new XPath 3.1 type array should be
supported even in the HE of Saxon 9.7. However, when trying to match on
an array, a stylesheet that compiles and runs fine with EE does not
compile with HE.

Here is a reduced test case:

<?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"
   xmlns:fn="http://www.w3.org/2005/xpath-functions"
   xmlns:array="http://www.w3.org/2005/xpath-functions/array"
   exclude-result-prefixes="xs fn array">

<xsl:output indent="yes"/>

<xsl:template name="xsl:initial-template">
   <xsl:apply-templates select="['a', 'b']"/>
</xsl:template>

<xsl:template match=".[. instance of array(xs:string)]">
   <trans key="{.?1}" value="{.?2}"/>
</xsl:template>

</xsl:stylesheet>

With EE I get

<trans key="a" value="b"/>

while HE gives a compilation error:

Saxon-HE 9.7.0.2J from Saxonica
Java version 1.8.0_73
Static error at char 2 in trans/@key on line 17 column 37 of
test2016021802.xsl:
   XPTY0004: Required item type of value of variable $qq:qq27250559 is
function(*); supplied
   value has item type node()


Even when I change the code to use array:get, as in

<xsl:template match=".[. instance of array(xs:string)]">
   <trans key="{array:get(., 1)}" value="{array:get(., 2)}"/>
</xsl:template>

HE complains with the error

Static error at char 12 in trans/@key on line 17 column 61 of
test201602180201.xsl:
   XPTY0004: Required item type of first argument of array:get() is
array(*); supplied value
   has item type node()


Is there some way to match on an array in 9.7 HE or is that match
pattern syntax technically part of XSLT 3.0 and as such not supported by
the HE?


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
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: Array support in 9.7 HE in match pattern

Michael Kay
It's failing because the type-checking code for key="{.?1}" thinks that "." has to be a node. The error is in a completely general path for type-checking patterns [1]; it's assuming the context item type will always be a node. I have yet to discover why such an error on a general path should not cause failures on hundreds of test cases, or why it should cause a failure under HE and not under EE.

I've raised a bug: [2]

Michael Kay
Saxonica

[1] StyleElement.typeCheck(String name, Pattern pattern)
[2] https://saxonica.plan.io/issues/2632


> On 18 Feb 2016, at 17:20, Martin Honnen <[hidden email]> wrote:
>
>
> As far as I understand it, the new XPath 3.1 type array should be
> supported even in the HE of Saxon 9.7. However, when trying to match on
> an array, a stylesheet that compiles and runs fine with EE does not
> compile with HE.
>
> Here is a reduced test case:
>
> <?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"
>  xmlns:fn="http://www.w3.org/2005/xpath-functions"
>  xmlns:array="http://www.w3.org/2005/xpath-functions/array"
>  exclude-result-prefixes="xs fn array">
>
> <xsl:output indent="yes"/>
>
> <xsl:template name="xsl:initial-template">
>  <xsl:apply-templates select="['a', 'b']"/>
> </xsl:template>
>
> <xsl:template match=".[. instance of array(xs:string)]">
>  <trans key="{.?1}" value="{.?2}"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> With EE I get
>
> <trans key="a" value="b"/>
>
> while HE gives a compilation error:
>
> Saxon-HE 9.7.0.2J from Saxonica
> Java version 1.8.0_73
> Static error at char 2 in trans/@key on line 17 column 37 of
> test2016021802.xsl:
>  XPTY0004: Required item type of value of variable $qq:qq27250559 is
> function(*); supplied
>  value has item type node()
>
>
> Even when I change the code to use array:get, as in
>
> <xsl:template match=".[. instance of array(xs:string)]">
>  <trans key="{array:get(., 1)}" value="{array:get(., 2)}"/>
> </xsl:template>
>
> HE complains with the error
>
> Static error at char 12 in trans/@key on line 17 column 61 of
> test201602180201.xsl:
>  XPTY0004: Required item type of first argument of array:get() is
> array(*); supplied value
>  has item type node()
>
>
> Is there some way to match on an array in 9.7 HE or is that match
> pattern syntax technically part of XSLT 3.0 and as such not supported by
> the HE?
>
>
> ------------------------------------------------------------------------------
> Site24x7 APM Insight: Get Deep Visibility into Application Performance
> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
> Monitor end-to-end web transactions and take corrective actions now
> Troubleshoot faster and improve end-user experience. Signup Now!
> http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/saxon-help 



------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...