<?xml version="1.0" encoding="GBK"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"><xsl:template match="//*" >
         <xsl:apply-templates />
         <xsl:call-template name="attributes"/>
  </xsl:template>  <xsl:template match="@*" name="attributes" >
  匹配上了属性节点
  </xsl:template>
<xsl:template match="text()"  name="nodetext">
  匹配上了文本节点
  </xsl:template>
</xsl:stylesheet>

解决方案 »

  1.   

    默认的模板应用,并不会执行属性的应用。正确如下:
    <?xml version="1.0" encoding="GBK"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">  <xsl:template match="/ | *">
         <xsl:apply-templates select="@*"/>
         <xsl:apply-templates/>
      </xsl:template>  <xsl:template match="text()" >
      匹配上了文本节点
      </xsl:template>  <xsl:template match="@*" >
      匹配上了属性节点
      </xsl:template></xsl:stylesheet>