Discussion:
[xquery-talk] [saxon] getting around the built in type restriction of a Basic XSLT processor
Ihe Onwuka
2014-12-01 08:06:34 UTC
Permalink
The XSLT 2.0 spec restricts the set of types available in a
non-schema-aware processor. Schema awareness comes only with Saxon-EE.
The extension attribute saxon:allow-all-built-in-types removes the
restriction (making the processor non-conformant), but like all extensions
in the Saxon namespace, it is available only with Saxon-PE or higher.
If it's only the castable test you are after, you could use matches(.,
'\i\c*')
This returns true for matches('1880s','\i\c*') in Saxon XSLT and Zorba.
I have a sequence of keywords which I would like to create as empty
elements if their content constitutes a valid element name but I cannot
execute the following because of the above restriction that prevents the
comparison to xs:NCName
Code is below.
<xsl:for-each select="tokenize(substring-after(.,'&#9;'),'\t')">
<xsl:choose>
<xsl:when test=". castable as xs:NCName">
<xsl:element name="{.}"/>
</xsl:when>
<xsl:otherwise>
<keyword name="{.}"/>
</xsl:otherwise>
</xsl:for-each>
I have tried the allow-all-built-in-types saxon attribute and that hasn't
worked.
Any other suggestions.
Ihe Onwuka
2014-12-01 08:13:47 UTC
Permalink
ah hah... the regex needs to start with a ^ and is '^\i\c*'
Post by Ihe Onwuka
The XSLT 2.0 spec restricts the set of types available in a
non-schema-aware processor. Schema awareness comes only with Saxon-EE.
The extension attribute saxon:allow-all-built-in-types removes the
restriction (making the processor non-conformant), but like all extensions
in the Saxon namespace, it is available only with Saxon-PE or higher.
If it's only the castable test you are after, you could use matches(.,
'\i\c*')
This returns true for matches('1880s','\i\c*') in Saxon XSLT and Zorba.
I have a sequence of keywords which I would like to create as empty
elements if their content constitutes a valid element name but I cannot
execute the following because of the above restriction that prevents the
comparison to xs:NCName
Code is below.
<xsl:for-each select="tokenize(substring-after(.,'&#9;'),'\t')">
<xsl:choose>
<xsl:when test=". castable as xs:NCName">
<xsl:element name="{.}"/>
</xsl:when>
<xsl:otherwise>
<keyword name="{.}"/>
</xsl:otherwise>
</xsl:for-each>
I have tried the allow-all-built-in-types saxon attribute and that hasn't
worked.
Any other suggestions.
Ihe Onwuka
2014-12-01 08:20:26 UTC
Permalink
yes otherwise it would return true for things like man's-hat .
If it's only the castable test you are after, you could use matches(.,
'\i\c*')
This returns true for matches('1880s','\i\c*') in Saxon XSLT and Zorba.
Perhaps the match should be anchored: matches(.,'^\i\c*$')
John Lumley
Loading...