| Refresh | Home EGTry.com

appy-templates can re-apply templates on the desent nodes of the matched node


xml

<?xml version="1.0" encoding="UTF-8"?>
<root>

  <AA id="a">inside A  
     <BB id="b"> Inside B </BB>
  </AA>

</root>


xslt 1: with no apply-templates

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="AA">
    <a>
      <xsl:value-of select="name()"/>
      <xsl:value-of select="@id"/>
      (<!--xsl:apply-templates/ -->)
    </a>
	</xsl:template>
	
  <xsl:template match="BB">
    <b>
      name=<xsl:value-of select="name()"/>
      id=<xsl:value-of select="@id"/>
    </b>
	</xsl:template>


</xsl:stylesheet>


output 1

<?xml version="1.0" encoding="UTF-8"?>

  <a>AAa
      ()
    </a>


xslt 2: apply-templates

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="AA">
    <a>
      <xsl:value-of select="name()"/>
      <xsl:value-of select="@id"/>
      (<xsl:apply-templates/> )
    </a>
	</xsl:template>
	
  <xsl:template match="BB">
    <b>
      name=<xsl:value-of select="name()"/>
      id=<xsl:value-of select="@id"/>
    </b>
	</xsl:template>


</xsl:stylesheet>


output 2

<?xml version="1.0" encoding="UTF-8"?>

  <a>AAa
      (inside A  
     <b>
      name=BB
      id=b</b>
   )
    </a>