xsl-list
[Top] [All Lists]

[xsl] Stripping white space

2007-03-30 07:31:28
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>

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>