The normalize-unicode() function

Smartsite 7.4 - ...

The normalize-unicode() XPath 2.0 function returns the value of arg after applying Unicode normalization.

XML CopyCode image Copy Code
string fn:normalize-unicode(arg)
string fn:normalize-unicode(arg, string normalizationForm)

Parameters:

  • arg: a node reference or literal.
  • string normalizationForm (optional): NFC (default), NFD, NFKC or NFKD.

Normalization Form

  • NFC: Indicates that a Unicode string is normalized using full canonical decomposition, followed by the replacement of sequences with their primary composites, if possible.
  • NFD: Indicates that a Unicode string is normalized using full canonical decomposition.
  • NFKC: Indicates that a Unicode string is normalized using full compatibility decomposition, followed by the replacement of sequences with their primary composites, if possible.
  • NFKD: Indicates that a Unicode string is normalized using full compatibility decomposition.

Example

XML CopyCode image Copy Code
<html xmlns="http://www.w3.org/1999/xhtml" 
 xmlns:xf="http://www.w3.org/2002/xforms" 
 xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0"
 xmlns:fn="http://www.w3.org/2005/xpath-functions">
 <head>
  <title>Example</title>
  <xf:model>
   <xf:instance>
    <data xmlns="">
     <tekst>£15 ㎗ leçon</tekst>
    </data>
   </xf:instance>
  </xf:model>
 </head>
 <body>
  <xf:group>
   <xf:output value="fn:normalize-unicode('£', 'NFC')" />
   <xf:output value="fn:normalize-unicode('£', 'NFKC')" />
   <xf:output value="fn:normalize-unicode('15 ㎗', 'NFKC')" />
   <xf:output value="fn:normalize-unicode('15 ㎗', 'NFD')" />
   <xf:output value="fn:normalize-unicode('leçon', 'NFKD')" />
   <xf:output value="fn:normalize-unicode(tekst, 'NFKD')" />
  </xf:group>
 </body>
</html>

The result will be:


£
15 dl
15
leçon
£15 dl leçon

Namespace

This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).