R
RolfK
Dear ALL,
I'm writing some first examples to get a better understanding of XSLT/
XPATH2.0.
Please excute this code, any xml input is OK.
I'm using saxon. The example runs perfect with ALTOVA, but fails with
SAXON.
Please refere to line with element <matches> which is quite close to
the error.
Error at choose on line 26 of file:/.....:
No function found matching fn:matches with 2 arguments
Transformation failed: Run-time errors were reported
Any idea ?
Any comments on the rest of the example are very welcome !
(I'm just started to dig into XSLT2.0 stub)
################ xslt #######################
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl
utput method="xml" indent="yes"/>
<xsl:template match="/">
<output>
<analyze>
<xsl:analyze-string select="'@abcd[123]'" regex="(@|#)?(\w+)\[(\d+)
\]">
<xsl:matching-substring>
<m group="1">
<xsl:value-of select="regex-group(1)"/>
</m>
<m group="2">
<xsl:value-of select="regex-group(2)"/>
</m>
<m group="3">
<xsl:value-of select="regex-group(3)"/>
</m>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</analyze>
<functions>
<xsl:for-each
select="('@param[2]','#define','0','H','L','invalid','##','@@','HL')">
<matches>
<xsl:choose>
<xsl:when test="fn:matches(.,'^@\w+\[\d+\]$')">
<item Value="{.}" Type="Parameter"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^#\w+$')">
<item Value="{.}" Type="Define"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^[01ZHLX]{1}$')">
<item Value="{.}" Type="Value"/>
</xsl:when>
<xsl
therwise>
<item Value="{.}" Type="ERROR"/>
</xsl
therwise>
</xsl:choose>
</matches>
<tokenize>
<xsl:variable name="vTokens" select="fn:tokenize(.,'(@)|(#)|(\[)|
(\])')"/>
<tokens count="{count($vTokens)}">
<xsl:for-each select="$vTokens">
<token value="{.}"/>
</xsl:for-each>
</tokens>
</tokenize>
</xsl:for-each>
</functions>
</output>
</xsl:template>
</xsl:transform>
############################
I'm writing some first examples to get a better understanding of XSLT/
XPATH2.0.
Please excute this code, any xml input is OK.
I'm using saxon. The example runs perfect with ALTOVA, but fails with
SAXON.
Please refere to line with element <matches> which is quite close to
the error.
Error at choose on line 26 of file:/.....:
No function found matching fn:matches with 2 arguments
Transformation failed: Run-time errors were reported
Any idea ?
Any comments on the rest of the example are very welcome !
(I'm just started to dig into XSLT2.0 stub)
################ xslt #######################
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl
<xsl:template match="/">
<output>
<analyze>
<xsl:analyze-string select="'@abcd[123]'" regex="(@|#)?(\w+)\[(\d+)
\]">
<xsl:matching-substring>
<m group="1">
<xsl:value-of select="regex-group(1)"/>
</m>
<m group="2">
<xsl:value-of select="regex-group(2)"/>
</m>
<m group="3">
<xsl:value-of select="regex-group(3)"/>
</m>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</analyze>
<functions>
<xsl:for-each
select="('@param[2]','#define','0','H','L','invalid','##','@@','HL')">
<matches>
<xsl:choose>
<xsl:when test="fn:matches(.,'^@\w+\[\d+\]$')">
<item Value="{.}" Type="Parameter"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^#\w+$')">
<item Value="{.}" Type="Define"/>
</xsl:when>
<xsl:when test="fn:matches(.,'^[01ZHLX]{1}$')">
<item Value="{.}" Type="Value"/>
</xsl:when>
<xsl
<item Value="{.}" Type="ERROR"/>
</xsl
</xsl:choose>
</matches>
<tokenize>
<xsl:variable name="vTokens" select="fn:tokenize(.,'(@)|(#)|(\[)|
(\])')"/>
<tokens count="{count($vTokens)}">
<xsl:for-each select="$vTokens">
<token value="{.}"/>
</xsl:for-each>
</tokens>
</tokenize>
</xsl:for-each>
</functions>
</output>
</xsl:template>
</xsl:transform>
############################