[xsl] Stripping white space

Subject: [xsl] Stripping white space
From: "Grant Slade" <grant.slade@xxxxxxxxx>
Date: Fri, 30 Mar 2007 08:31:02 -0600
I have the following XSLT which handles Authors, i.e.

<AU>Smith, J.P.<AU>
<AU>Jahan, Aras^Jones, Jimmy C.</AU>   <--- delimited by '^'

My problem is that I am breaking apart the individual authors using
substring breaking apart by comman, so in the output I am getting:

<surname>Smith</surname>
<given-names> J.P.</given-names>      <--- has a space before the J

I tried using the normalize-space function which I understood would
strip leading and trailing white space, but it isn't working.

Probably a better way to do this is using patterns, and I will
probably change it but I wanted to know if there's a way to strip the
whitespace.  My xslt is as follows:

   <xsl:template match="AU">
       <contrib contrib-type="author">
           <xsl:choose>
               <!-- Tests for Multiple Authors -->
               <xsl:when test="contains(., '^')">
                   <xsl:for-each select="tokenize(.,'\^')">
                       <xsl:choose>
                           <xsl:when test="contains(.,',')">
                               <name>
                                   <surname>
                                       <xsl:value-of
select="substring-before(normalize-space(.),',')"/>
                                   </surname>
                                   <given-names>
                                       <xsl:value-of
select="substring-after(normalize-space(.),',')"/>
                                   </given-names>
                               </name>
                           </xsl:when>
                       </xsl:choose>
                   </xsl:for-each>
                   <!-- <xsl:message terminate="yes"/> -->
               </xsl:when>
               <!-- Tests for singular author -->
               <xsl:when test="matches (.,',{1}')">
                   <name>
                       <surname>
                           <xsl:value-of
select="substring-before(normalize-space(.),',')"/>
                       </surname>
                       <given-names>
                           <xsl:value-of
select="substring-after(normalize-space(.),',')"/>
                       </given-names>
                   </name>
                   <!-- <xsl:message terminate="yes"></xsl:message> -->
               </xsl:when>
               <!-- Tests for empty AU field -->
               <xsl:when test="not(normalize-space(.))">
                   <xsl:message terminate="yes"></xsl:message>
               </xsl:when>
               <xsl:otherwise>
                       <xsl:message terminate="yes">
                           <xsl:text>ABANDON SHIP!  Arrrrrr ...</xsl:text>
                       </xsl:message> -->
               </xsl:otherwise>
           </xsl:choose>
       </contrib>
   </xsl:template>

Current Thread