commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954083 - /commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl
Date Sat, 12 Jun 2010 19:37:58 GMT
Author: jbeard
Date: Sat Jun 12 19:37:58 2010
New Revision: 954083

URL: http://svn.apache.org/viewvc?rev=954083&view=rev
Log:
transformIf.xsl works well with the simple executableContent example

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl?rev=954083&r1=954082&r2=954083&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/transformIf.xsl Sat Jun 12 19:37:58
2010
@@ -13,35 +13,45 @@
 	   </xsl:copy>
 	</xsl:template>
 
-	<xsl:template match="s:if">
-		<xsl:variable name="elseOrElseIfNodes" select="s:elseif | s:else"/>
-		<xsl:variable name="firstElseOrElseIfNodes" select="(s:elseif | s:else)[1]"/>
-		<xsl:variable name="nodePosition">
-			<xsl:choose>
-				<xsl:when test="$elseOrElseIfNodes">
-					<xsl:value-of select="position($firstElseOrElseIfNodes)"/>
-				</xsl:when>
-				<xsl:otherwise>
-					<xsl:value-of select="count(*)"/>
-				</xsl:otherwise>
-			</xsl:choose>
-		</xsl:variable>
+	<!--consume-->
+	<!--gets siblings until you hit else or elseif or null-->
+	<xsl:template name="consume">
+		<xsl:param name="currentNode"/>
 
-		<xsl:variable name="test" select="subsequence(1,$nodePosition)"/>
 		<xsl:message>
-			<xsl:value-of select="'----------'"/>
-			<xsl:copy-of select="$test"/>
-			<xsl:value-of select="'----------'"/>
+			<xsl:text>---start---</xsl:text>
+			<xsl:copy-of select="local-name($currentNode)"/>
+			<xsl:text>---end---</xsl:text>
 		</xsl:message>
+		
+		<xsl:if test="$currentNode and
+				not($currentNode/self::else or $currentNode/self::elseif)">
+
+			<xsl:apply-templates select="$currentNode"/>
+
+			<xsl:call-template name="consume">
+				<xsl:with-param name="currentNode" 
+					select="$currentNode/following-sibling::*"/>
+			</xsl:call-template>
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="s:if">
 
 		<xsl:copy>
 			<xsl:apply-templates select="@*"/>
-			<!--
+
 			<c:executableContent>
-				<xsl:apply-templates select="subsequence(1,$nodePosition)"/>
+				<xsl:call-template name="consume">
+					<xsl:with-param name="currentNode" select="*[1]"/>
+				</xsl:call-template>
 			</c:executableContent>
-			<xsl:apply-templates select="subsequence($nodePosition + 1,count(*))"/>
-			-->
+
+			<xsl:for-each select="s:elseif | s:else">
+				<c:executableContent>
+					<xsl:apply-templates select="./following-sibling::*"/>
+				</c:executableContent>
+			</xsl:for-each>
 		</xsl:copy>
 	</xsl:template>
 



Mime
View raw message