Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
ricaudm
Posts: 3

Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Tue Oct 03, 2017 2:46 pm

Hi,

I got the last oXygen 19.1 yesterday, I faced a bug which didn't happen with 19.0.

This is my test case (transformation scenario is using saxon EE 9.7.0.19) :

xml.xml

Code: Select all

<root filePath="../../../grammars/efl/infoCommentaire/xf_infoCommentaire.srng"/>


xsl.xsl

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:els="http://www.lefebvre-sarrut.eu/ns/els"
  xmlns:functx="http://www.functx.com"
  exclude-result-prefixes="#all"
  version="2.0">
 
  <!--<xsl:include href="functx.xsl"/>-->
 
  <!--==========================================-->
  <!--MAIN-->
  <!--==========================================-->
 
  <xsl:template match="/*">
    <xsl:value-of select="els:getFileName(@filePath)"/>
  </xsl:template>
 
  <!--==========================================-->
  <!--FUNCTIONS-->
  <!--==========================================-->
 
  <xsl:function name="els:getFileName" as="xs:string">
    <xsl:param name="filePath" as="xs:string?"/>
    <xsl:param name="withExt" as="xs:boolean"/>
    <xsl:variable name="fileNameWithExt" select="functx:substring-after-last-match($filePath,'/')"/>
    <xsl:variable name="fileNameNoExt" select="functx:substring-before-last-match($fileNameWithExt,'\.')"/>
    <!--DEBUG-->
    <xsl:message>filePath = <xsl:value-of select="$filePath"/></xsl:message>
    <xsl:variable name="localString" select="'../../../grammars/efl/infoCommentaire/xf_infoCommentaire.srng'" as="xs:string"/>
    <xsl:message>$localString = $filePath  is <xsl:value-of select="$localString = $filePath"/></xsl:message>
    <xsl:message>test1 (with $filePath) = <xsl:value-of select="functx:substring-after-last-match($filePath,'/')"/></xsl:message>
    <xsl:message>test2 (with $localString) = <xsl:value-of select="functx:substring-after-last-match($localString,'/')"/></xsl:message>
    <!--/DEBUG-->
    <xsl:variable name="ext" select="els:getFileExt($fileNameWithExt)"/>
    <xsl:sequence select="concat('', $fileNameNoExt, if ($withExt) then (concat('.',$ext)) else (''))"/>
  </xsl:function>
 
  <!--1 arg signature-->
  <xsl:function name="els:getFileName" as="xs:string">
    <xsl:param name="filePath" as="xs:string?"/>
    <xsl:sequence select="els:getFileName($filePath,true())"/>
  </xsl:function>
 
  <xsl:function name="els:getFileExt" as="xs:string">
    <xsl:param name="filePath" as="xs:string?"/>
    <xsl:sequence select="concat('',functx:substring-after-last-match($filePath,'\.'))"/>
  </xsl:function>
 
  <!--==========================================-->
  <!--FUNCTX (copy of used functions)-->
  <!--==========================================-->
  <xsl:function xmlns:functx="http://www.functx.com" name="functx:substring-after-last-match" as="xs:string">
    <xsl:param name="arg" as="xs:string?"/>
    <xsl:param name="regex" as="xs:string"/>
    <xsl:sequence select=" replace($arg,concat('^.*',$regex),'') "/>
  </xsl:function>
 
  <xsl:function xmlns:functx="http://www.functx.com" name="functx:substring-before-last-match" as="xs:string?">
    <xsl:param name="arg" as="xs:string?"/>
    <xsl:param name="regex" as="xs:string"/>
    <xsl:sequence select=" replace($arg,concat('^(.*)',$regex,'.*'),'$1') "/>
  </xsl:function>
 
</xsl:stylesheet>


As output, I get the string "srng.srng" instead of "xf_infoCommentaire.srng"
I add a DEBUG block that show the difference :
When the string comes from the function parameters the functx:substring-after-last-match works like there were a "." instead of the "/" as 2ng arg.
This doesn't happen when descativating the $ext variable to :

Code: Select all

<xsl:variable name="ext" select="'foo'"/>


When lauching the XSLT as command line with various version of saxon I never get this bug.
So I guess it's the good place to report it.

Hope you can reproduce and correcting this.

Kind Regards
Matthieu
Last edited by ricaudm on Tue Oct 03, 2017 4:25 pm, edited 1 time in total.
Radu
Posts: 5088

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Tue Oct 03, 2017 4:23 pm

Hi Matthieu,

I can reproduce the behavior using Saxon EE but Saxon PE seems to properly work with your example and produce the expected output.
I will add an internal issue and see if this is caused by one of our patches or if it's an issue in Saxon. If it's an issue with Saxon I will add an issue on the Saxonica issues list and add the link here.
You mentioned you tested Saxon from the command line, if you did not have a license for it you probably run it as Saxon HE and this is possibly why you did not reproduce the problem.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ricaudm
Posts: 3

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Tue Oct 03, 2017 4:26 pm

Thanks a lot Radu !
Radu
Posts: 5088

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Tue Oct 03, 2017 4:34 pm

Hi Matthieu,

I reproduced the problem from the command line using a licensed Saxon 9.7.0.20 EE and I added an issue for it here:

https://saxonica.plan.io/issues/3467

If Michael Kay, Saxon's owner and main developer finds a fix for this we'll try to ship it in the next Oxygen 19.1 minor bug fix release.
In the meantime if you do not use any schema aware features you can probably use Saxon PE for publishing.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ricaudm
Posts: 3

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Tue Oct 03, 2017 6:27 pm

I thought I made the test with this Saxon EE version but it seems I missed it...

Thanks you for the analyze and reporting the bug to Saxonica.

We actually have a Saxon EE site licence, so I prefer sticking with oXygen 19 (and its Saxon 9.7.0.15 embed version) so my XSLT dev remain equivalent to our production environnement.

Waitin for Mike's answer,
Cheers
Matthieu
Radu
Posts: 5088

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Wed Oct 04, 2017 8:23 am

Hi Matthieu,

It seems that Mike has acknowledged the issue and created some fixes for it both in Saxon 9.7 and 9.8.
I will try to take his fixes and incorporate them in the next Oxygen 19.1 minor bug fix release which will be in about 2-3 weeks. I will update this forum thread when we manage to fix the issue.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 5088

Re: Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)

Mon Nov 13, 2017 3:32 pm

Hi,

Just to update this forum thread, the latest Oxygen 19.1 minor bug fix release kit should have a patch for this issue.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 1 guest