MENU
Analysis
<xsl:analyze-string>, <xsl:matching-substring>, <xsl:non-matching-substring>, <xsl:fallback>
<xsl:analyze-string> matches a string against a regular expression, processing the matched and non-matched portions separately with <xsl:matching-substring> and <xsl:non-matching-substring>; <xsl:fallback> supplies fallback content for processors that do not support the instruction. The example below matches the regex ^(a.)(..) against the string 'abcdef': the match itself is "abcd", with capturing group 1 = "ab" and group 2 = "cd"; the matched portion outputs group 2 via regex-group(2), while the unmatched remainder ("ef") is wrapped in parentheses.<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:analyze-string select="'abcdef'" regex="^(a.)(..)"
flags="msix">
<xsl:matching-substring>
<xsl:value-of select="regex-group(2)"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
(<xsl:value-of select="."/>)
</xsl:non-matching-substring>
<xsl:fallback>
Your processor does not support this feature.
</xsl:fallback>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>cd
(ef)
<xsl:assert>, <xsl:evaluate>
<xsl:assert> tests a condition and outputs its content as a diagnostic message only when the condition is false, without affecting the result if it is true. <xsl:evaluate> dynamically evaluates an XPath expression supplied as a string. The example below asserts that 101 ge 100 (true, so nothing is emitted), reports a message via <xsl:message select="10 ge 10"/>, and dynamically evaluates the string expression "(9*9)||''".<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:assert test="101 ge 100">
Is smaller than 100.
</xsl:assert>
<xsl:message select="10 ge 10">
Is greater than or equals 10
</xsl:message>
<xsl:evaluate xpath="(9*9)||''"/>
</xsl:template>
</xsl:stylesheet>(The processor reports the message 'true. Is greater than or equals 10'.)
81
<xsl:message> can have the following attributes: terminate ({"yes" | "no"}), error-code ({eqname}).
<xsl:evaluate> can have the following attributes: as (sequence-type), base-uri ({uri}), with-params (expression), context-item (expression), namespace-context (expression), schema-aware ({"yes" | "no"}). The required item type of its xpath attribute is xs:string.