12.3 Processing the Source Tree

<?xml version="1.0" encoding="utf-8" ?>  
<xsl:stylesheet version="1.0"  
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
>  
  <xsl:template match="helloWorld" >  
     <html>  
       <head><title>example</title></head>  
       <body>  
          <xsl:apply-templates/>  
       </body>  
     </html>  
  </xsl:template>  
  <xsl:template match="greeting" >  
     <h1>  
       <xsl:apply-templates />  
     </h1>  
  </xsl:template>  
</xsl:stylesheet>  
<?xml version="1.0"  
      encoding="utf-8" ?>  
<helloWorld>  
  <greeting>Hello World!</greeting>  
</helloWorld>  
<html>  
<head>  
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>example</title>  
</head>  
<body>  
 
<h1>Hello World!</h1>  
 
</body>  
</html>
<?xml version="1.0" encoding="UTF-8" ?>  
    <xsl:stylesheet version="1.0"  
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
>  
 
  <xsl:template match="list" >  
     <num>  
        <xsl:apply-templates select="child::*[ last() ]" />  
     </num>  
  </xsl:template>  
 
  <xsl:template match="num" >  
     <digit> <xsl:apply-templates select="child::*" /> </digit>  
        <xsl:apply-templates select="preceding-sibling::*[1]" />  
  </xsl:template>  
 
</xsl:stylesheet>  
<?xml version="1.0" encoding="utf-8" ?>  
<list>  
   <num>1</num>  
   <num>2</num>  
   <num>3</num>  
</list>  
<?xml version="1.0" encoding="UTF-8"?>  
<num><digit/><digit/><digit/></num>