You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by ri...@apache.org on 2005/04/10 00:41:05 UTC
svn commit: r160722 -
forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl
Author: rick
Date: Sat Apr 9 15:41:03 2005
New Revision: 160722
URL: http://svn.apache.org/viewcvs?view=rev&rev=160722
Log:
Correct scope problem in expanding the value of a for:skinconf-node.
Problem was as follows:
If skinconfig contained something like
<project-svg>
<text>Project Name</text>
<style>font: 20pt</style>
</project-svg>
<group-svg>
<text>some text</text>
<style>font: 16pt</style>
</group-svg>
and the referencing SVG document had:
<for:group-svg>
<for:text/>
</for:group-svg>
Then, the text above would include the text from <project-svg> since
it matched first.
This commit fixes that problem. Also included some comments in the
XSL to try and explain how it works.
Modified:
forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl
Modified: forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl
URL: http://svn.apache.org/viewcvs/forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl?view=diff&r1=160721&r2=160722
==============================================================================
--- forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl (original)
+++ forrest/trunk/main/webapp/resources/stylesheets/project2text.xsl Sat Apr 9 15:41:03 2005
@@ -25,25 +25,32 @@
<xsl:import href="copyover.xsl"/>
- <xsl:variable name="config" select="//skinconfig"/>
-
<xsl:template match="for:*">
- <xsl:param name="ancestorpath" select="''"/>
+ <xsl:param name="config" select="//skinconfig"/>
<xsl:choose>
+
+ <!-- If we have nested for:* elements in the XML we're
+ transforming, recursively call ourselves
+ with a narrowed scope for the skinconfig. -->
+
<xsl:when test="*">
+ <xsl:variable name="ln" select="local-name()"/>
<xsl:apply-templates>
- <xsl:with-param name="ancestorpath"
- select="concat($ancestorpath,'/',local-name())"/>
+ <xsl:with-param name="config" select="$config/*[local-name() = $ln]"/>
</xsl:apply-templates>
</xsl:when>
+
+ <!-- Ah ha! No more for:* children in the XML document being
+ transformed so we just select the value of this node from skinconfig
+ (ie. $config). Note that the node we select from skinconfig may
+ have nested elements and we'll get the values of all of them. -->
+
<xsl:otherwise>
- <xsl:variable name="tmp"
- select="concat($ancestorpath, '/', local-name())"/>
- <xsl:value-of
- select="$config//*[concat($ancestorpath, '/', local-name()) = $tmp]"/>
+ <xsl:variable name="ln" select="local-name()"/>
+ <xsl:value-of select="$config/*[local-name() = $ln]"/>
</xsl:otherwise>
- </xsl:choose>
+ </xsl:choose>
</xsl:template>
</xsl:stylesheet>