This xslt analyzes a HTML5 source document. (my instinct tells me a program already exists that performs similar function, and better than this, but I can't find it)<?xml version=1.0 encoding=utf-8?><xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform    xmlns:xs=http://www.w3.org/2001/XMLSchema    exclude-result-prefixes=xs        version=2.0>    <!-- analyzes an HTML5 document -->    <xsl:output        method=xhtml        html-version=5.0        omit-xml-declaration=yes        encoding=UTF-8        indent=yes/>    <xsl:strip-space elements=*/>    <xsl:variable name=filename>        <!-- all after the last slash -->        <xsl:analyze-string select=base-uri() regex=([^/]+$)>                   <xsl:matching-substring>                <xsl:value-of select=./>            </xsl:matching-substring>        </xsl:analyze-string>    </xsl:variable>    <xsl:template match=/>        <html>            <head>                <meta content=text/html; charset=utf-8 http-equiv=content-type/>                <link href=../Styles/topic.css rel=stylesheet type=text/css/>                <title>                    <xsl:value-of select=concat('HTML Document Analysis of: ',$filename)/>                </title>            </head>            <body>                <h2><xsl:value-of select=concat('HTML Document Analysis of: ',$filename)/></h2>                <xsl:call-template name=stylesheet/>                <xsl:call-template name=block_count/>                <xsl:call-template name=inline_count/>                <xsl:call-template name=css_table/>                <xsl:call-template name=style_table/>            </body>        </html>    </xsl:template>    <xsl:template match=text()/>    <xsl:template name=stylesheet>        <xsl:variable name=stylesheet_name>            <xsl:analyze-string select=//link[1]/@href regex=([^/]+$)>                       <xsl:matching-substring>                    <xsl:value-of select=./>                </xsl:matching-substring>            </xsl:analyze-string>        </xsl:variable>        <xsl:if test=$stylesheet_name>            <p>First stylesheet name: <i><xsl:value-of select=$stylesheet_name/></i></p>        </xsl:if>                            </xsl:template>    <xsl:template name=block_count>        <h3>Block Level Elements Found</h3>        <table border=1 style=width:500px>            <tbody>                <tr>                    <th>Class</th>                    <th>Count</th>                </tr>                                                                    <xsl:for-each-group select=//*                     group-by=tokenize('address,article,aside,audio,blockquote,canvas,dd,div,dl,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,noscript,ol,output,p,pre,section,table,tfoot,ul,video',',')>                    <xsl:sort select=count(//*[name()=current-grouping-key()]) order=descending/>                    <xsl:variable name=count select=count(//*[name()=current-grouping-key()])/>                    <xsl:if test=$count &gt; 0>                        <tr>                            <td>                                <xsl:text>&lt;</xsl:text>                                <xsl:value-of select=current-grouping-key()/>                                <xsl:text>&gt;</xsl:text>                            </td>                            <td>                                <xsl:value-of select=$count/>                            </td>                        </tr>                    </xsl:if>                </xsl:for-each-group>            </tbody>        </table>                            </xsl:template>    <xsl:template name=inline_count>        <h3>Inline Elements Found</h3>        <table border=1 style=width:500px>            <tbody>                <tr>                    <th>Class</th>                    <th>Count</th>                </tr>                                                                    <xsl:for-each-group select=//*                     group-by=tokenize('b,big,i,small,tt,abbr,acronym,cite,code,dfn,em,kbd,strong,samp,var,a,bdo,br,img,map,object,q,script,span,sub,sup,button,input,label,select,textarea',',')>                    <xsl:sort select=count(//*[name()=current-grouping-key()]) order=descending/>                    <xsl:variable name=inline-count select=count(//*[name()=current-grouping-key()])/>                                        <xsl:if test=$inline-count &gt; 0>                        <tr>                            <td>                                <xsl:text>&lt;</xsl:text>                                <xsl:value-of select=current-grouping-key()/>                                <xsl:text>&gt;</xsl:text>                            </td>                            <td>                                <xsl:value-of select=$inline-count/>                            </td>                        </tr>                    </xsl:if>                </xsl:for-each-group>            </tbody>        </table>                            </xsl:template>    <xsl:template name=css_table>        <h3>Classes</h3>        <table border=1 style=width:500px>            <tbody>                <tr>                    <th>Class</th>                    <th>Count</th>                </tr>                                                    <xsl:for-each-group select=//*/@class group-by=.>                    <xsl:sort select=count(//*[@class=current-grouping-key()]) order=descending/>                    <tr>                        <td><xsl:value-of select=./></td>                        <td>                            <xsl:value-of select=count(//*[@class=current-grouping-key()])/>                        </td>                    </tr>                </xsl:for-each-group>            </tbody>        </table>            </xsl:template>    <xsl:template name=style_table>        <h3>Styles</h3>        <table border=1 style=width:500px>            <tbody>                <tr>                    <th>Styles</th>                    <th>Count</th>                </tr>                                                    <xsl:for-each-group select=//*/@style group-by=.>                    <xsl:sort select=count(//*[@style=current-grouping-key()]) order=descending/>                    <tr>                        <td><xsl:value-of select=./></td>                        <td>                            <xsl:value-of select=count(//*[@style=current-grouping-key()])/>                        </td>                    </tr>                </xsl:for-each-group>            </tbody>        </table>            </xsl:template></xsl:stylesheet>
XSLT 2.0 that analyzes an HTML5 document
html;xslt