Q:

ALign xml text using XSLT in ouput html

i have my XML like this
   <catalog>
       <cd>
          <p style="TEXT-ALIGN: center; MARGIN: 0pt; font-size:5">Washington</p>
       </cd>
    </catalog>

and use the XSLT to get the and set the "washington" text align property 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="html" indent="yes"/>

   <xsl:template match="p">
      <p style="text-align:{substring-before(substring-after(@style,'TEXT-ALIGN:'),';')}">
         <xsl:value-of select="." />
      </p>
   </xsl:template>

</xsl:stylesheet>

it works fine and give me required output <p style="text-align: center">Washington</p>
which align the text to center
but if i change the line to 
 <p align="{substring-before(substring-after(@style,'TEXT-ALIGN:'),';')}">

to get this <p align="center">Washington</p> 
then its not working to set the text to the center
where m going wrong

A:

It may because of the space before the word "center" in your align attribute.
<p align=" center">Washington<p>

You need to use the normalize-space command to remove this extra space:
<p align="{normalize-space(substring-before(substring-after(@style,'TEXT-ALIGN:'),';'))}">

This would output the following
<p align="center">Washington<p>

