normalize-space() function and if statement : normalize space « XSLT stylesheet « XML






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)
    
  
  
  

 








Related examples in the same category

1.normalize-space demo
2.normalize-space
3.Use normalize-space() function to normalize space for elements and attributes