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

Home
XML
1.CSS Style
2.SVG
3.XML Schema
4.XQuery
5.XSLT stylesheet
XML » XSLT stylesheet » normalize space 
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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.