xsl-list
[Top] [All Lists]

Re: [xsl] normalize-space and sequence

2007-09-26 13:10:11
Hi David,

On 9/26/07, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--