Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Value-of and math calculation

File: Data.xml <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" />   <xsl:template match="/">     <xsl:variable name="myVar">10</xsl:variable>     <test>       A.       <xsl:value-of select="3+2+$myVar" />       B.       <xsl:value-of select="substring('hello world',7)" />     </test>   </xsl:template> </xsl:stylesheet> 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" />   <xsl:template match="/">     <xsl:variable name="myVar">10</xsl:variable>     <test>       A.       <xsl:value-of select="3+2+$myVar" />       B.       <xsl:value-of select="substring('hello world',7)" />     </test>   </xsl:template> </xsl:stylesheet> Output: <test>       A.       15       B.       world</test>