ovidiu 2002/09/06 18:18:00
Modified: src/java/org/apache/cocoon/components/language/markup/xsp/java
jpath.xsl
Log:
Fix the code generation in the case of jpath:for-each to generate
variables with unique names. Patch from Per-Olof Noren <[EMAIL PROTECTED]>.
Revision Changes Path
1.3 +10 -21
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/jpath.xsl
Index: jpath.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/jpath.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- jpath.xsl 6 Sep 2002 00:23:49 -0000 1.2
+++ jpath.xsl 7 Sep 2002 01:17:59 -0000 1.3
@@ -21,7 +21,6 @@
<xsp:page>
<xsl:apply-templates select="@*"/>
<xsp:structure>
- <xsp:include>java.util.List</xsp:include>
<xsp:include>java.util.Iterator</xsp:include>
<xsp:include>org.apache.cocoon.environment.Environment</xsp:include>
<xsp:include>org.apache.cocoon.components.flow.WebContinuation</xsp:include>
@@ -61,7 +60,6 @@
</xsl:variable>
CompiledExpression <xsl:value-of select="$var-name"/>
= jxpathContext.compile("<xsl:value-of select="@test"/>");
- <xsl:apply-templates select="jpath:*" mode="compile"/>
</xsl:template>
<xsl:template match="jpath:for-each | jpath:value-of" mode="compile">
@@ -72,15 +70,8 @@
</xsl:variable>
CompiledExpression <xsl:value-of select="$var-name"/>
= jxpathContext.compile("<xsl:value-of select="@select"/>");
- <xsl:apply-templates select="jpath:*" mode="compile"/>
</xsl:template>
- <!--
- <xsl:template match="*|@*|text()|processing-instruction()" mode="compile">
- <xsl:apply-templates mode="compile"/>
- </xsl:template>
--->
-
<xsl:template name="get-var-name">
<xsl:param name="expr"/>
jxpath_<xsl:value-of select="translate($expr,
" 	

~`!@%^*()-+=[]{}\|,./?><'", '')"/>
@@ -154,24 +145,22 @@
<xsl:when test="@select">
<xsp:logic>
{
- List selection = <xsl:call-template name="get-var-name">
- <xsl:with-param name="expr" select="@test"/>
- </xsl:call-template>
- .eval(jxpathContext);
- if (selection != null) {
- Iterator iter = selection.iterator();
- JPathContext <xsl:value-of select="$old-context"/> = jxpathContext;
- while (iter.hasNext()) {
- Object current = iter.next();
- jxpathContext = JPathContext.newContext(current);
+ Iterator iter_<xsl:value-of select="generate-id(.)"/>
+ = <xsl:call-template name="get-var-name">
+ <xsl:with-param name="expr" select="@test"/>
+ </xsl:call-template>
+ .iterate(jxpathContext);
+ JXPathContext <xsl:value-of select="$old-context"/> = jxpathContext;
+ while (iter_<xsl:value-of select="generate-id(.)"/>.hasNext()) {
+ Object current_<xsl:value-of select="generate-id(.)"/> =
iter_<xsl:value-of select="generate-id(.)"/>.next();
+ jxpathContext = JXPathContext.newContext(current_<xsl:value-of
select="generate-id(.)"/>);
</xsp:logic>
<xsl:apply-templates/>
<xsp:logic>
- }
- jxpathContext = <xsl:value-of select="$old-context"/>;
}
+ jxpathContext = <xsl:value-of select="$old-context"/>;
}
</xsp:logic>
</xsl:when>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]