func.function.2.xsl 725 B

12345678910111213141516171819202122
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  3. xmlns:func = "http://exslt.org/functions" extension-element-prefixes="func">
  4. <!-- Test an EXSLT function with local variables -->
  5. <func:function name="func:count-elements-and-attributes">
  6. <xsl:variable name="elements" select="//*"/>
  7. <xsl:variable name="attributes" select="//@*"/>
  8. <func:result select="count($elements | $attributes)"/>
  9. </func:function>
  10. <xsl:template match="/">
  11. <out>
  12. <el><xsl:value-of select="count(//*)"/></el>;
  13. <at><xsl:value-of select="count(//@*)"/></at>;
  14. <xsl:value-of select="func:count-elements-and-attributes()"/>
  15. </out>
  16. </xsl:template>
  17. </xsl:stylesheet>