RE: [xsl] normalize-space and sequence

Subject: RE: [xsl] normalize-space and sequence
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 26 Sep 2007 00:26:34 +0100
>   I am having a very simple issue here. I'd like to be able to apply
> normalize-space() even if I am dealing with a sequence of 
> string. If I do call normalize-space, the transformation 
> implicitly convert my sequence of string into string (saxon 8.9).

If the stylesheet specifies version="1.0", then normalize-space() will
process the first string in the sequence and ignore the others. If it
specifies version="2.0", then you will get a type error.

>   What's is this function that convert sequence of strings 
> into string ?

You can apply normalize-space to every string in a sequence (returning a
sequence of normalized strings) in the usual way: for $i in $seq return
normalize-space($i). If you want to combine a sequence of strings into a
single string, use string-join().
>   As a side note, there is no way to globally say 'all my xml 
> attribute/elements should have normalize space'.

Yes there is: you can declare their types in a schema to derive from
xs:token, and use schema-aware XSLT processing.

Michael Kay

Current Thread