[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Stripping white space

Subject: Stripping white space
From: "Grant Slade" <grant.slade@xxxxxxxxx>
Date: Fri, 30 Mar 2007 08:31:02 -0600
 Stripping white space
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.