Re: [docbook-apps] xsl: extract the first word

From
Jirka Kosek <>
Date
2005-10-31T21:44:52+00:00
ID
Thread
Re: [docbook-apps] xsl: extract the first word
Sam Steingold wrote:
> I am trying to get something like
>   (substring X 0 (position #\Space X))
> i.e., the first word of the string.
> if there are no spaces, I want the whole of X (in that case POSITION
> returns NIL and I get what I want).
> 
> I tried:
> 
> {substring-before(normalize-space(.),' ')}
> unfortunately, this returns "" (empty string) when there is no spaces in
> the string.

Try this:

substring-before(concat(normalize-space(.), ' '),' ')

by adding space at the end of string, you can be sure that there always 
will be at least one space.

				Jirka

-- 
------------------------------------------------------------------
   Jirka Kosek     e-mail:      http://www.kosek.cz
------------------------------------------------------------------
   Profesionální školení a poradenství v oblasti technologií XML.
      Podívejte se na náš nově spuštěný web http://DocBook.cz
        Podrobný přehled školení http://xmlguru.cz/skoleni/
------------------------------------------------------------------
Nejbližší termíny školení: XML schémata (včetně RELAX NG) 7.-9.11.
          *** DocBook 5.-7.12. *** XSL-FO 19.-20.12. ***
------------------------------------------------------------------