Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Normalize-space() function and if statement

File: Data.xml <poem>   <a>line 1</a>   <b>line 1</b>   <c>line 1</c>   <d>     line 1   </d> </poem> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />   <xsl:template match="a">     <xsl:if test="normalize-space(.) = normalize-space(../d)">       a = normalize-space(../d)     </xsl:if>        </xsl:template>   <xsl:template match="b|c|d" /> </xsl:stylesheet> Output:          a = normalize-space(../d)