[Home] [By Thread] [By Date] [Recent Entries]
On 17/03/12 08:18, Andrew Welch wrote:
Ken's "XSLStyle" might be something like you're after. Here's a post from Florent about it: http://fgeorges.blogspot.co.uk/2009/02/xslstyle-and-oxygen.html Looking at the first commentor, you might already be aware of that :)
First cut below. GPL If you can improve it, please share. I'm looking initially at fo output... ymmv DaveP
<d:doc xmlns:d="http://www.dpawson.co.uk/ns#"> <d:revhistory> <d:purpose> <d:para>This stylesheet works with a {} file to produce a {}</d:para> </d:purpose> <d:revision> <d:revnumber>1.0</d:revnumber> <d:date>2012-03-17T07:54:29Z.</d:date> <d:authorinitials>DaveP</d:authorinitials> <d:revdescription> <d:para>Analyse a stylseheet set</d:para> </d:revdescription> <d:revremark></d:revremark> </d:revision> </d:revhistory> </d:doc> <xsl:strip-space elements="*"/> <xsl:output method="html" indent="yes" encoding="utf-8"/> <xsl:template match="/"> <html> <head> <title>Stylesheet analysis. Stylesheet <xsl:value-of select="document-uri(/)"/></title> <link rel="STYLESHEET" href="analyze.css" type="text/css"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body bgcolor="#FFFFFF"> <h2>Stylesheet analysis. Revision <xsl:value-of select="document('')//d:doc/d:revhistory/d:revision[last()]/d:revnumber"/></h2> <h3>Stylesheet <xsl:value-of select="document-uri(.)"/></h3>
<xsl:call-template name='toc'/>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</li>
</xsl:for-each>
</ul>
</ul>
</xsl:if>
</xsl:template><!-- imports -->
<xsl:template match="xsl:import">
<xsl:variable name="path" select="tokenize(@href,'/')[last()]"/>
<div class="import" id="generate-id()">
<p><a href="{concat($path,'.html')}"><xsl:value-of select="@href"/></a></p>
</div>
<xsl:result-document
href="{concat($path,'.html')}">
<xsl:apply-templates select="document(@href)"/>
</xsl:result-document>
</xsl:template><!-- Match templates --> <xsl:template match="xsl:template[@match][not(@name)]"> <div class="match" id="{generate-id()}"> <p>Match Template <b><xsl:value-of select="@match"/></b> <xsl:if test="@mode"> <xsl:text> </xsl:text> <span class="mode"><xsl:value-of select="@mode"/></span> </xsl:if> </p> <xsl:if test=".//*[@xsl:use-attribute-sets]"> <xsl:apply-templates select=".//*[@xsl:use-attribute-sets]" mode='uas'/> </xsl:if> </div> <xsl:apply-templates/> </xsl:template> <!-- Named templates -->
<xsl:template match="xsl:template[@name][not(@match)]">
<div class='named' id="{generate-id()}">
<p>Named Template <b><xsl:value-of select="@name"/></b>
<xsl:if test="@mode">
<xsl:text> </xsl:text>
<span class="mode"><xsl:value-of select="@mode"/></span>
</xsl:if></p> <xsl:if test=".//*[@xsl:use-attribute-sets]"> <xsl:apply-templates select=".//*[@xsl:use-attribute-sets]" mode='uas'/> </xsl:if> </div> <xsl:apply-templates/> </xsl:template> <!-- Match named templates --> <xsl:template match="xsl:template[@match][@name]"> <div class="match" id="{generate-id()}"> <p>Match Template <b><xsl:value-of select="@match"/></b> <xsl:if test="@mode"> <xsl:text> </xsl:text> <span class="mode"><xsl:value-of select="@mode"/></span> </xsl:if> </p> <p>Named Template <b><xsl:value-of select="@name"/></b></p> <xsl:if test=".//*[@xsl:use-attribute-sets]"> <xsl:apply-templates select=".//*[@xsl:use-attribute-sets]" mode='uas'/> </xsl:if> </div> <xsl:apply-templates/> </xsl:template> <!-- Attribute sets. Moded, to use within templates --> <xsl:template match="fo:*[@xsl:use-attribute-sets]" mode='uas'> <xsl:variable name="parentmatch" select="ancestor::*[self::xsl:template][1]/@match,''" /> <xsl:variable name="parentname" select="ancestor::*[self::xsl:template][1]/@name,''" /> <div class="attribute-set-use" id="{generate-id()}"> <p class="attribute-set-use" id="{generate-id()}"> use-attribute-set <b><xsl:value-of select="@xsl:use-attribute-sets"/></b></p> </div> </xsl:template>
<!-- keys --> <xsl:template match="xsl:key"> <div class='keydef' id="generate-id()"> <p>Key, name=<xsl:value-of select="@name"/></p> </div> </xsl:template>
<!-- Ignore xsl:attribute?? --> <xsl:template match="xsl:attribute[not(@xsl:use-attribute-sets)]"/> <!-- Ignore xsl:param --> <xsl:template match="xsl:param|xsl:with-param"/> <!-- Ignore xsl:when,xsl:otherwise if contains text only? --> <xsl:template match="xsl:when[text()][not(*)]"/> <xsl:template match="xsl:otherwise[text()][not(*)]"/> <!-- Default --> <xsl:template match="*"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet>
--> /*CSS for the output of analyze.xsl*/ div.match p b{
background-color: aliceblue;
}div.variable{
text-indent: 2em;
}
div.variable p b{
background-color: ghostwhite;
}div.attribute-set-use{
text-indent: 2em;
}span.mode:before{
content:"Mode ";
background-color:ghostwhite;
}span.mode{
background-color:lemonchiffon;
}regards -- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
|

Cart



