You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/06/12 21:38:15 UTC

svn commit: r954085 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: test/xslt/appendTransitionInformation.xsl xalan.sh

Author: jbeard
Date: Sat Jun 12 19:38:15 2010
New Revision: 954085

URL: http://svn.apache.org/viewvc?rev=954085&view=rev
Log:
Intermediate commit.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl   (with props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh   (with props)

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl?rev=954085&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl Sat Jun 12 19:38:15 2010
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+	xmlns:s="http://www.w3.org/2005/07/scxml"
+	xmlns="http://www.w3.org/2005/07/scxml"
+	xmlns:c="http://msdl.cs.mcgill.ca/"
+	version="1.0">
+	<xsl:output method="xml"/>
+
+	<!-- identity transform -->
+	<xsl:template match="@*|node()">
+	   <xsl:copy>
+	      <xsl:apply-templates select="@*|node()"/>
+	   </xsl:copy>
+	</xsl:template>
+
+	<!--
+
+		util.foreach(scxmlRoot..transition,function(transition){
+
+			var sourceState = transition.parent();
+
+			var targetId = transition.msdl::targets.msdl::target.msdl::targetState[0].toString();
+			var transitionTarget = conf.allStates.(@id == targetId);
+
+			//we use these funky-looking variables to avoid namespace collisions in the below query
+			var $s = sourceState, $t = transitionTarget;
+			if(!conf.parallelRegions.( 
+				descendants($s.localName()).contains($s) &&
+					descendants($t.localName()).contains($t)).length()){ 
+
+				transition.@msdl::exitsParallelRegion = true;
+			}
+			
+
+			//set whether he is preempted
+			if(conf.parallelsAndDescendantStates.contains(sourceState) && 
+				!conf.parallelsAndDescendantStates.contains(transitionTarget)){
+
+				transition.@msdl::isPreempted = true;
+			}
+
+		});
+	-->
+
+	<xsl:variable name="parallels" select="//s:parallel"/>
+
+	<xsl:variable name="parallelRegions">
+		<xsl:value-of select="//s:parallel/s:state"/>
+	</xsl:variable>
+
+	<xsl:template match="s:transition">
+		<xsl:variable name="sourceState" select="parent::*"/>
+		<xsl:variable name="targetId" select="c:targets/c:target/c:targetState[1]"/>
+
+		<xsl:variable name="targetState" select="//*[(self::s:state or self::s:parallel or self::s:final or self::s:initial or self::s:scxml or self::s:history) and @id = $targetId]"/>
+
+		<xsl:copy>
+			<xsl:apply-templates select="@*"/>
+	
+			<xsl:message>
+				<xsl:text>START&#10;</xsl:text>
+				<xsl:text>Parallels:</xsl:text> <xsl:value-of select="$parallels/@id"/> <xsl:text>&#10;</xsl:text>
+				<xsl:text>Parallel Regions:</xsl:text> <xsl:value-of select="count($parallelRegions)"/> <xsl:text>&#10;</xsl:text>
+				<xsl:text>Source state:</xsl:text> <xsl:value-of select="$sourceState/@id"/> <xsl:text>&#10;</xsl:text>
+				<xsl:text>Target state:</xsl:text> <xsl:value-of select="$targetState/@id"/> <xsl:text>&#10;</xsl:text>
+				<xsl:text>END&#10;</xsl:text>
+			</xsl:message>
+
+			<!-- get his parallel region -->
+			<xsl:variable name="sourceParallelRegion" select="$parallelRegions/self::*[.//*[. = $sourceState]]"/>
+			<xsl:variable name="targetParallelRegion" select="$parallelRegions/self::*[.//*[. = $targetState]]"/>
+
+			<!-- if source parallel region and end parallel region are not the same, 
+				then we say he exits exitsParallelRegion -->
+			<xsl:if test="not($sourceParallelRegion = $targetParallelRegion)">
+				<xsl:attribute name="exitsParallelRegion" namespace="http://msdl.cs.mcgill.ca/">
+					<xsl:value-of select="'true'"/>
+				</xsl:attribute> 
+			</xsl:if>
+
+			<!-- if the source is a parallel state or one of his descendants, 
+				and the target is outside of the parallel state that most closely wraps the source state, 
+				then we we say he is preempted -->
+			<xsl:variable name="sourceParallel" select="$parallels[self::* = $sourceState or .//*[. = $sourceState]]"/>
+			<xsl:variable name="targetParallel" select="$parallels[self::* = $targetState or .//*[. = $targetState]]"/>
+
+			<xsl:if test="not($sourceParallel = $targetParallel)">
+				<xsl:attribute name="isPreempted" namespace="http://msdl.cs.mcgill.ca/">
+					<xsl:value-of select="'true'"/>
+				</xsl:attribute> 
+			</xsl:if>
+
+			
+			<!--FIXME: we actually need to test if it's the SAME parallel substate -->
+			<!--FIXME: change isParallelSubstate to isDescendantOfParallelRegion -->
+			<!-- FIXME: isParallelStateOrDescendantOfParallelState ... but, again we need to know... -->
+			<!--
+			<xsl:if test="$sourceState/@c:isParallelSubstate and 
+						not($targetState/@c:isParallelSubstate)">
+			</xsl:if>
+			-->
+
+			<xsl:apply-templates select="node()"/>
+		</xsl:copy>
+	</xsl:template>
+
+</xsl:stylesheet>
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/test/xslt/appendTransitionInformation.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh?rev=954085&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh Sat Jun 12 19:38:15 2010
@@ -0,0 +1 @@
+java -cp ./lib/java/serializer.jar:./lib/java/xalan.jar:./lib/java/xercesImpl.jar:./lib/java/xml-apis.jar org.apache.xalan.xslt.Process -XSL $1 -IN $2 

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/xalan.sh
------------------------------------------------------------------------------
    svn:executable = *