[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] normalize-space and sequence


Subject: Re: [xsl] normalize-space and sequence
From: "Mathieu Malaterre" <mathieu.malaterre@xxxxxxxxx>
Date: Wed, 26 Sep 2007 22:09:47 +0200

Hi David,

On 9/26/07, David Carlisle <davidc@xxxxxxxxx> wrote:
> It's helpful if you post actual code, rather than a description of it,
> as I'm not sure whic case you are in It _sounds_ like you are doing

Sorry. I'll keep that in mind.

> normalize-space(("aaa","bbb","ccc"))
>
> applying the function to a sequence.
> In XPath 2 (native mode) that is an error as normalize-space expects a
> single string
> If you are in backward compatibility mode (ie have version="1.0" in
> scope) then the effect is to discard all but the first item of the
> sequnce and normalize that, so you'd get "aaa".

ok

> the function for converting a sequence to a strng is string-join
>
> string-join(("aaa","bbb","ccc"),"=")
>
> produces the string
>
> "aaa=bbb=ccc"

Hum. I am still not clear why this is called implicitly with {} but I
need to call explicitly string-joing before normalize-space.

> not on input, but on output, you can have templates such as
>
> <xsl:template match="@*">
> <xsl:attribute name="name()" select="normalize-space(.)"/>
> </xsl:template>

I replaced it with:

<xsl:template match="@*">
<xsl:attribute name="{name()}" select="normalize-space(.)"/>
</xsl:template>

See:
http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/oo2.xsl?r1=1144&r2=1145

> which will make the default templates on attributes and text normalize
> space.

Running the xsl code still leave whitespace at end/beginning of my
output strings:

http://gdcm.svn.sourceforge.net/viewvc/gdcm/trunk/Source/InformationObjectDefinition/ModuleAttributes.xml

Am I missing something ? I'd like to avoid duplicating the string-join
+ normalize-space all over my xsl code.

Thanks a bunch,
-- 
Mathieu


Current Thread
Keywords