saxon:separator - defining the separator for list values

Normally, in an element or attribute whose type is derived from xs:list, the separator between items in the list must be whitespace. The saxon:separator attribute can be specified on an xs:list element to define an alternative way of separating items. The value is a regular expression. For example, saxon:separator="," defines comma as the separator, saxon:separator="\|" uses a vertical bar, and saxon:separator=",\s*" uses a comma followed by zero or more spaces.

Tokenization of the supplied value is performed according to the rules of the XPath fn:tokenize() function. Note this means that the regular expression must not be one that matches a zero-length string.

If the item type of the list is one that collapses whitespace (for example xs:integer or xs:date) then whitespace is automatically allowed before and after a separator; it does not need to be explicitly permitted by the regular expression.

If the input value starts or ends with a separator, then the result of tokenization will include a zero-length token. With many item types (for example xs:integer or xs:date) a zero-length string is not a valid value, so this will result in an error.

An empty input string represents an empty list of values. An input string containing one or more whitespace characters represents a list of length one whose only token comprises whitespace; for many item types, this is not a valid token.

Note that the attribute has no impact on the way values are serialized. When constructing elements and attributes in the result of a query or stylesheet, it will be necessary to insert the separators explicitly, typically by invoking the fn:string-join() function.

For example:

<xs:simpleType name="list-of-doubles" xmlns:saxon="http://saxon.sf.net/"> <xs:list item-type="xs:double" saxon:separator=","> </xs:simpleType>