Subject: Re: [xsl] Stylesheet analysis/documentation From: davep <davep@xxxxxxxxxxxxx> Date: Sat, 17 Mar 2012 10:18:47 +0000 |
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 :)
IIRC Kens is about documenting what you have written? I'm more interested in understanding what others have written?
First cut below. GPL If you can improve it, please share. I'm looking initially at fo output... ymmv
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://www.dpawson.co.uk/ns#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo xs d" version="2.0">
<xsl:strip-space elements="*"/> <xsl:output method="html" indent="yes" encoding="utf-8"/>
<h3>Stylesheet <xsl:value-of select="document-uri(.)"/></h3> <xsl:call-template name='toc'/> <xsl:apply-templates/> </body> </html> </xsl:template>
<!-- toc --> <xsl:template name="toc"> <xsl:if test="//xsl:template"> <h3>Templates</h3> <ul> <ul> <xsl:for-each select="//xsl:template"> <li><a href="#{generate-id()}"> <xsl:choose> <xsl:when test="@match"> <xsl:value-of select="@match"/> </xsl:when> <xsl:otherwise> <xsl:text>name </xsl:text> <xsl:value-of select="@name"/> </xsl:otherwise> </xsl:choose> </a>
</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>
<!-- 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>
</div> <xsl:apply-templates/> </xsl:template>
<xsl:variable name="parentmatch" select="ancestor::*[self::xsl:template][1]/@match,''" /> <xsl:variable name="parentname" select="ancestor::*[self::xsl:template][1]/@name,''" />
<!-- variables --> <xsl:template match="xsl:variable"> <div class="variable" id="{generate-id()}"> <p>Variable <b><xsl:value-of select="@name"/></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:text --> <xsl:template match="xsl:text"/>
<!-- 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>
<!-- * Copyright (C) 2012 Dave Pawson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA.
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; }
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Stylesheet analysis/docum, Andrew Welch | Thread | Re: [xsl] Stylesheet analysis/docum, G. Ken Holman |
Re: [xsl] Stylesheet analysis/docum, Tony Graham | Date | Re: [xsl] Stylesheet analysis/docum, G. Ken Holman |
Month |