[yelp-xsl] [xsldoc] Checking used parameters, and updating cache namespace
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp-xsl] [xsldoc] Checking used parameters, and updating cache namespace
- Date: Wed, 27 Jan 2010 15:48:17 +0000 (UTC)
commit 4dc1b296a3cc72bc6e46af88bd04fddf1ecb70c8
Author: Shaun McCance <shaunm gnome org>
Date: Tue Jan 26 21:12:16 2010 -0600
[xsldoc] Checking used parameters, and updating cache namespace
doc/yelp-xsl/xsldoc-check.xsl | 3 +-
doc/yelp-xsl/xsldoc-scan.xsl | 82 +++++++++++++++++++++++++++++++++++++----
2 files changed, 76 insertions(+), 9 deletions(-)
---
diff --git a/doc/yelp-xsl/xsldoc-check.xsl b/doc/yelp-xsl/xsldoc-check.xsl
index 52b76d1..bee0532 100644
--- a/doc/yelp-xsl/xsldoc-check.xsl
+++ b/doc/yelp-xsl/xsldoc-check.xsl
@@ -39,12 +39,13 @@ free software.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mal="http://projectmallard.org/1.0/"
+ xmlns:cache="http://projectmallard.org/cache/1.0/"
version="1.0">
<xsl:output method="text"/>
<xsl:param name="xsldoc.cache.file"/>
-<xsl:param name="xsldoc.cache" select="document($xsldoc.cache.file)/mal:cache"/>
+<xsl:param name="xsldoc.cache" select="document($xsldoc.cache.file)/cache:cache"/>
<xsl:key name="xsldoc.cache.key" match="mal:page | mal:section" use="@id"/>
<xsl:template match="/mal:page">
diff --git a/doc/yelp-xsl/xsldoc-scan.xsl b/doc/yelp-xsl/xsldoc-scan.xsl
index 5e7e59f..c42ed38 100644
--- a/doc/yelp-xsl/xsldoc-scan.xsl
+++ b/doc/yelp-xsl/xsldoc-scan.xsl
@@ -41,6 +41,7 @@ free software.
xmlns:mal="http://projectmallard.org/1.0/"
xmlns:exsl="http://exslt.org/common"
xmlns:set="http://exslt.org/sets"
+ xmlns:str="http://exslt.org/strings"
xmlns="http://projectmallard.org/1.0/"
extension-element-prefixes="exsl"
exclude-result-prefixes="mal set"
@@ -99,16 +100,34 @@ free software.
</xsl:if>
</xsl:for-each>
<!-- xslt-uses-param -->
- <!-- Disable for now, until we can do it better. We should look deeper into
- select attributes, and checking descendent-or-self/preceding-sibling for
- params and variables.
- <xsl:for-each select="set:distinct($xslt_file//xsl:value-of
- [starts-with(@select, '$') and contains(@select, '.')]/@select)">
- <xsl:variable name="id"
- select="concat('P__', translate(substring-after(., '$'), '.', '_'))"/>
+ <xsl:variable name="uses-params">
+ <!-- FIXME
+ -->
+ <xsl:for-each select="$xslt_file//xsl:value-of/@select |
+ $xslt_file//xsl:if/@test |
+ $xslt_file//xsl:when/@test ">
+ <xsl:variable name="xpath_node" select="."/>
+ <xsl:variable name="params">
+ <xsl:call-template name="extract-params">
+ <xsl:with-param name="string" select="string(.)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:for-each select="str:split($params)">
+ <xsl:variable name="paramname" select="string(.)"/>
+ <xsl:if test="
+ not($xpath_node/../ancestor-or-self::*/preceding-sibling::xsl:param[ name = $paramname]
+ or $xpath_node/../ancestor-or-self::*/preceding-sibling::xsl:variable[ name = $paramname])">
+ <param>
+ <xsl:value-of select="$paramname"/>
+ </param>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:for-each select="set:distinct(exsl:node-set($uses-params)/mal:param)">
+ <xsl:variable name="id" select="concat('P__', translate(string(.), '.', '_'))"/>
<link type="xslt-uses-param" xref="{$id}"/>
</xsl:for-each>
- -->
</info>
<xsl:copy-of select="mal:title"/>
<xsl:if test="string(mal:info/mal:desc) != ''">
@@ -198,4 +217,51 @@ free software.
<xsl:copy-of select="."/>
</xsl:template>
+<xsl:template name="extract-params">
+ <xsl:param name="string" select="''"/>
+ <xsl:param name="position" select="1"/>
+ <xsl:param name="in_param" select="false()"/>
+ <xsl:if test="$position <= string-length($string)">
+ <xsl:variable name="char" select="substring($string, $position, 1)"/>
+ <xsl:choose>
+ <xsl:when test="$in_param">
+ <xsl:choose>
+ <xsl:when test="contains(
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_',
+ $char)">
+ <xsl:value-of select="$char"/>
+ <xsl:call-template name="extract-params">
+ <xsl:with-param name="string" select="$string"/>
+ <xsl:with-param name="position" select="$position + 1"/>
+ <xsl:with-param name="in_param" select="true()"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> </xsl:text>
+ <xsl:call-template name="extract-params">
+ <xsl:with-param name="string" select="$string"/>
+ <xsl:with-param name="position" select="$position + 1"/>
+ <xsl:with-param name="in_param" select="false()"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="$char = '$'">
+ <xsl:call-template name="extract-params">
+ <xsl:with-param name="string" select="$string"/>
+ <xsl:with-param name="position" select="$position + 1"/>
+ <xsl:with-param name="in_param" select="true()"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="extract-params">
+ <xsl:with-param name="string" select="$string"/>
+ <xsl:with-param name="position" select="$position + 1"/>
+ <xsl:with-param name="in_param" select="false()"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]