mirror of
https://github.com/alexandrev/xslt-lab.git
synced 2026-09-18 19:43:16 +00:00
53e90ef86e
Full coverage of XSLT 1.0, 2.0 and 3.0 elements and XPath functions: - 59 XSLT elements (xsl:stylesheet → xsl:use-accumulators) - 170 XPath functions (1.0 node/string/numeric/boolean, 2.0 sequence/ date/QName/string, 3.0 HOF/map/array/JSON/streaming) Each page: description, parameters table, return value, 2 runnable Saxon examples with input XML + stylesheet + output, notes, cross-links. xsltCompletions.js: all 229 entries now have blogSlug for hover links. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2.9 KiB
2.9 KiB
title, description, date, version, versionLabel, category, syntax, tags
| title | description | date | version | versionLabel | category | syntax | tags | ||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| upper-case() | Converts every character of a string to its Unicode uppercase equivalent using locale-independent Unicode case mapping. | 2026-04-18T00:00:00Z | 2.0 | XSLT 2.0 | string function | upper-case(string) |
|
Description
upper-case() returns a copy of the input string with every character converted to uppercase according to Unicode case mappings. The conversion is locale-independent and uses the Unicode default case folding rules — it does not consider language-specific rules (e.g., Turkish dotless-i). For language-sensitive uppercasing, a collation-aware approach or custom extension function is needed.
If the argument is an empty sequence, the function returns the empty string "".
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
string |
xs:string? | Yes | The string to convert. |
Return value
xs:string — the input string with all characters mapped to uppercase.
Examples
Basic uppercase conversion
Input XML:
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<msg>Hello, World!</msg>
<msg>xslt is powerful</msg>
<msg>Ärger mit Ü</msg>
</messages>
Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/messages">
<upper>
<xsl:for-each select="msg">
<msg><xsl:value-of select="upper-case(.)"/></msg>
</xsl:for-each>
</upper>
</xsl:template>
</xsl:stylesheet>
Output:
<upper>
<msg>HELLO, WORLD!</msg>
<msg>XSLT IS POWERFUL</msg>
<msg>ÄRGER MIT Ü</msg>
</upper>
Case-insensitive comparison
Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/catalog">
<!-- Select items regardless of how 'active' is cased in the data -->
<active-items>
<xsl:for-each select="item[upper-case(@status) = 'ACTIVE']">
<item><xsl:value-of select="name"/></item>
</xsl:for-each>
</active-items>
</xsl:template>
</xsl:stylesheet>
Notes
upper-case()is not the same as theiflag onmatches(). The function changes the string; the flag changes how matching works.- For true locale-aware uppercasing (e.g., Turkish
i→İ), use an extension function or a collation-aware approach. - Numeric, punctuation, and whitespace characters are returned unchanged.
- Combining
upper-case()withnormalize-unicode()can help with Unicode normalization before comparison.