Name

[2.0] codepoint-equal()

Determines whether two strings are equal, based on their Unicode codepoints.

Syntax

xs:boolean? codepoint-equal(xs:string?, xs:string?)

Inputs

Two xs:strings to be compared.

Output

This function returns true or false depending on whether the two strings are equal using the Unicode code point collation. This function allows you to compare xs:anyURI values without having to specify a collation. If either argument is the empty sequence, the result is the empty sequence.

Defined in

XQuery 1.0 and XPath 2.0 Functions and Operators section 7.3, “Equality and Comparison of Strings.”

Example

Here is a short stylesheet that tests strings to see whether they are equal:

<?xml version="1.0"?>
<!-- codepoint-equal.xsl -->
<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:text>&#xA;Tests of the codepoint-equal() function:&#xA;</xsl:text>

    <xsl:text>&#xA;  codepoint-equal('A', 'A') = </xsl:text>
    <xsl:value-of select="codepoint-equal('A', 'A')"/>

    <xsl:text>&#xA;  codepoint-equal('A', '&amp;#x41;') = </xsl:text>
    <xsl:value-of select="codepoint-equal('A', '&#x41;')"/>

    <xsl:text>&#xA;  codepoint-equal('A', '&amp;#65;') = </xsl:text>
    <xsl:value-of select="codepoint-equal('A', '&#65;')"/>

    <xsl:text>&#xA;  codepoint-equal('Strasse', 'Stra&amp;#xDF;e') = </xsl:text>
    <xsl:value-of select="codepoint-equal('Strasse', 'Stra&#xDF;e')"/> </xsl:template> </xsl:stylesheet> ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.