Bug in string functions (oxygen 19.1 - functx - saxonEE 9.7.0.19)
Posted: 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
xsl.xsl
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 :
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
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"/>
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>
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'"/>
So I guess it's the good place to report it.
Hope you can reproduce and correcting this.
Kind Regards
Matthieu