XQuery/Special Characters

Motivation
You want to control where you put special characters such as newlines and quote characters in your XML files.

Method
We will create XQuery variables (referents) to the decimal encoded character values using the  notation where NN is the decimal number for this character in the character set. We can then add these variables anywhere in the output stream.

Example Program
In this example we will create a variable $nl had have it refer to the newline character. We will then put this in the middle of a string.

Returns:

Hello World

The following shows how both quote and newline special characters can be created.

Returns: "Hello  World"

Note that the string length of these variables string-length($nl) and string-length($quote) is only one character.

Using Zero Width Space Characters for Line Breaks
If you have URLs that appear in the text to ensure they break gracefully when hyphenation is enabled:

Contributed by Joe Wicentowski in March of 2014