commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954097 - /commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/numberStatesAndTransitions.xsl
Date Sat, 12 Jun 2010 19:39:42 GMT
Author: jbeard
Date: Sat Jun 12 19:39:41 2010
New Revision: 954097

URL: http://svn.apache.org/viewvc?rev=954097&view=rev
Log:
Added transitions back in.

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

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/numberStatesAndTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/numberStatesAndTransitions.xsl?rev=954097&r1=954096&r2=954097&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/numberStatesAndTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/numberStatesAndTransitions.xsl Sat
Jun 12 19:39:41 2010
@@ -10,6 +10,8 @@
 	<xsl:variable name="states" 
 		select="//*[self::s:state or self::s:parallel or self::s:final or self::s:initial or self::s:history]"
/>
 
+	<xsl:variable name="transitions" select="//s:transition"/>
+
 	<!--
 	<xsl:template match="/">
 		<xsl:for-each select="$states">
@@ -52,10 +54,12 @@
 			<xsl:for-each select="$states">
 				<xsl:if test="@id = $stateId">
 
+					<!--
 					<xsl:message>
 						stateid : <xsl:value-of select="$stateId"/>
-						stateNum : <xsl:value-of select="position()"/>
+						stateNum : <xsl:number select="position()"/>
 					</xsl:message>
+					-->
 
 					<xsl:attribute name="stateNum" namespace="http://msdl.cs.mcgill.ca/">
 						<xsl:value-of select="position()"/>
@@ -67,6 +71,40 @@
 		</xsl:copy>
 	</xsl:template>
 
+	<xsl:template match="s:transition">
+
+		<xsl:variable name="tName">
+			<xsl:value-of select="@c:tName"/>
+		</xsl:variable>
+
+		<!-- what we want to ask is, what is his position in the nodeset that we've constructed?

+			but we can't use position normally... can only be used wrt to the context node
+			i think the easiest thing to think about is just iterating through these state nodes in
a for-each
+			fashion. but... yah, can't do that in the top-down recursive manner that we're doing.
+
+		-->
+		
+		<xsl:copy>
+			<xsl:apply-templates select="@*"/>
+
+			<!-- FIXME: subtract 1 for 0-based indexing in generated code? 
+				No, we probably want to adjust this in the code generator-->
+			<!--FIXME: there has GOT to be a more efficient way to do this
+				the way I'm doing it now takes an O(n) operation and makes it into an O(n^2) op. really
bad)
+				but it's not clear how else to get the position of a given node out of a node list...
+			-->
+			<xsl:for-each select="$transitions">
+				<xsl:if test="@c:tName = $tName">
+
+					<xsl:attribute name="tNum" namespace="http://msdl.cs.mcgill.ca/">
+						<xsl:value-of select="position()"/>
+					</xsl:attribute>
+				</xsl:if>
+			</xsl:for-each>
+
+			<xsl:apply-templates select="node()"/>
+		</xsl:copy>
+	</xsl:template>
 
 </xsl:stylesheet>
 



Mime
View raw message