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/11/21 16:40:20 UTC
svn commit: r1037480 - in /commons/sandbox/gsoc/2010/scxml-js/trunk/src:
javascript/scxml/cgf/backends/js/ python/scxml/cgf/ xslt/backends/js/
xslt/ir-compiler/ xslt/util/
Author: jbeard
Date: Sun Nov 21 15:40:20 2010
New Revision: 1037480
URL: http://svn.apache.org/viewvc?rev=1037480&view=rev
Log:
Added src/python/scxml/cgf/target symlink, which was needed to provide access to built xsl resources from python modules.
Added topo-sort.xsl and custom dependency annotations to stylesheets. This should solve the problem of having to maintain a separate list of transformations for each compilation strategy, and each language. Now there is one canonical list for each compilation strategy, which gets constructed at compile-time.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target (with props)
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl (with props)
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendBasicStateInformation.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendStateInformation.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js Sun Nov 21 15:40:20 2010
@@ -27,11 +27,11 @@ require.def(
return {
"transformations" : AbstractStatechartGenerator.transformations.concat([
appendTransitionInformation,
- addTransitionTargetIds,
copyEnumeratedEventTransitions,
enumerateEvents,
addEventRegularExpressions,
- expandStarEvent]),
+ expandStarEvent,
+ addTransitionTargetIds]),
"code" : StatePatternStatechartGenerator
};
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/SCXMLCompiler.py Sun Nov 21 15:40:20 2010
@@ -46,17 +46,37 @@ def compile(pathsToSCXML=[],backend="sta
return results
+
def transformDocument(sourceDocument=None,transformList=[],params={},output="xml"):
+ def tryTransform(docToTransform,transformTuple):
+ transform = transformTuple[0]
+ try:
+ toReturn = transform(docToTransform)
+ if not toReturn:
+ raise Exception("Failed to transform document.")
+ else:
+ return toReturn
+ except:
+ #FIXME: how to print to stderr in python?
+ stderr = sys.stderr;
+ stderr.write("Failed to transform document.\n")
+ stderr.write("Given input document:\n")
+ stderr.write(str(docToTransform))
+ stderr.write("And xsl:\n")
+ stderr.write(str(transformTuple[1]))
+ stderr.close()
+ sys.exit(0)
+
templateStreams = map(lambda t : pkg_resources.resource_stream(__name__,t), transformList)
#print templateStreams
templateDocs = map(lambda t : etree.parse(t), templateStreams)
#print templateDocs
- compiledTemplates = map(lambda t : etree.XSLT(t), templateDocs)
+ compiledTemplates = map(lambda t : (etree.XSLT(t),t), templateDocs)
#print compiledTemplates
#TODO: apply args to the transform
- outputDocument = reduce(lambda docToTransform,transform: transform(docToTransform), compiledTemplates, sourceDocument)
+ outputDocument = reduce(tryTransform, compiledTemplates, sourceDocument)
if output == "xml":
return outputDocument
Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target?rev=1037480&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target Sun Nov 21 15:40:20 2010
@@ -0,0 +1 @@
+link ../../../../target/
\ No newline at end of file
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/python/scxml/cgf/target
------------------------------------------------------------------------------
svn:special = *
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl Sun Nov 21 15:40:20 2010
@@ -20,6 +20,24 @@
xmlns:c="http://commons.apache.org/scxml-js"
version="1.0">
+ <c:dependencies>
+ <c:dependency path="addBasicDescendantsToTransitions.xsl"/>
+ <c:dependency path="addEventRegularExpressions.xsl"/>
+ <c:dependency path="appendBasicStateInformation.xsl"/>
+ <c:dependency path="appendStateInformation.xsl"/>
+ <c:dependency path="appendTransitionInformation.xsl"/>
+ <c:dependency path="changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl"/>
+ <c:dependency path="computeLCA.xsl"/>
+ <c:dependency path="copyEnumeratedEventTransitions.xsl"/>
+ <c:dependency path="enumerateEvents.xsl"/>
+ <c:dependency path="expandStarEvent.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="transformIf.xsl"/>
+ </c:dependencies>
+
<import href="AbstractStatechartGenerator.xsl"/>
<!-- TODO: refactor name of enumeratedEventDispatchInvocation variable. it is no longer an invocation -->
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl Sun Nov 21 15:40:20 2010
@@ -20,6 +20,28 @@
xmlns:c="http://commons.apache.org/scxml-js"
version="1.0">
+ <c:dependencies>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="addBasicDescendantsToTransitions.xsl"/>
+ <c:dependency path="addEventRegularExpressions.xsl"/>
+ <c:dependency path="appendBasicStateInformation.xsl"/>
+ <c:dependency path="appendStateInformation.xsl"/>
+ <c:dependency path="appendTransitionInformation.xsl"/>
+ <c:dependency path="changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl"/>
+ <c:dependency path="computeLCA.xsl"/>
+ <c:dependency path="copyEnumeratedEventTransitions.xsl"/>
+ <c:dependency path="enumerateEvents.xsl"/>
+ <c:dependency path="expandStarEvent.xsl"/>
+ <c:dependency path="flattenTransitions.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ <c:dependency path="nameTransitions.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ <c:dependency path="numberStatesAndTransitions.xsl"/>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="transformIf.xsl"/>
+ </c:dependencies>
+
<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
<variable name="enumeratedEventDispatchInvocation" select="'STATE_TRANSITION_TABLE[state][e]();'"/>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl Sun Nov 21 15:40:20 2010
@@ -20,6 +20,28 @@
xmlns:c="http://commons.apache.org/scxml-js"
version="1.0">
+ <c:dependencies>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="addBasicDescendantsToTransitions.xsl"/>
+ <c:dependency path="addEventRegularExpressions.xsl"/>
+ <c:dependency path="appendBasicStateInformation.xsl"/>
+ <c:dependency path="appendStateInformation.xsl"/>
+ <c:dependency path="appendTransitionInformation.xsl"/>
+ <c:dependency path="changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl"/>
+ <c:dependency path="computeLCA.xsl"/>
+ <c:dependency path="copyEnumeratedEventTransitions.xsl"/>
+ <c:dependency path="enumerateEvents.xsl"/>
+ <c:dependency path="expandStarEvent.xsl"/>
+ <c:dependency path="flattenTransitions.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ <c:dependency path="nameTransitions.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ <c:dependency path="numberStatesAndTransitions.xsl"/>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="transformIf.xsl"/>
+ </c:dependencies>
+
<import href="AbstractEnumeratedStatechartGenerator.xsl"/>
<variable name="enumeratedEventDispatchInvocation" select="'dispatch(state,e)'"/>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl Sun Nov 21 15:40:20 2010
@@ -22,6 +22,11 @@
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="appendBasicStateInformation.xsl"/>
+ <c:dependency path="computeLCA.xsl"/>
+ </c:dependencies>
+
<xsl:variable name="states" select="//*[self::s:state or self::s:parallel or self::s:scxml]"/>
<!-- identity transform -->
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addEventRegularExpressions.xsl Sun Nov 21 15:40:20 2010
@@ -22,6 +22,10 @@
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="enumerateEvents.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendBasicStateInformation.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendBasicStateInformation.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendBasicStateInformation.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendBasicStateInformation.xsl Sun Nov 21 15:40:20 2010
@@ -26,6 +26,10 @@ isHistory="true" to history states.
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendStateInformation.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendStateInformation.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendStateInformation.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendStateInformation.xsl Sun Nov 21 15:40:20 2010
@@ -26,6 +26,10 @@ descendants of children of <parallel> st
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl Sun Nov 21 15:40:20 2010
@@ -30,6 +30,14 @@ region (a child of <parallel>), and the
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ <c:dependency path="changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl Sun Nov 21 15:40:20 2010
@@ -29,6 +29,12 @@ elements, so this should still generate
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/computeLCA.xsl Sun Nov 21 15:40:20 2010
@@ -30,6 +30,14 @@ to the input document as children in the
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="splitTransitionTargets.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ <c:dependency path="changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl"/>
+ <c:dependency path="generateUniqueInitialStateIds.xsl"/>
+ <c:dependency path="generateUniqueStateIds.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/enumerateEvents.xsl Sun Nov 21 15:40:20 2010
@@ -26,6 +26,10 @@ source document under the namespaced <ev
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="copyEnumeratedEventTransitions.xsl"/>
+ </c:dependencies>
+
<xsl:key name="enumeratedEvents" match="c:enumeratedTransition | c:enumeratedSend" use="@event"/> <!-- used for generating unique list -->
<xsl:key name="allEvents" match="s:transition | s:send" use="@event"/> <!-- used for generating unique list -->
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/expandStarEvent.xsl Sun Nov 21 15:40:20 2010
@@ -22,6 +22,10 @@
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="enumerateEvents.xsl"/>
+ </c:dependencies>
+
<xsl:variable name="enumeratedEventsEnum" select="/s:scxml/c:enumeratedEventsEnum/c:event"/>
<!-- identity transform -->
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/flattenTransitions.xsl Sun Nov 21 15:40:20 2010
@@ -28,6 +28,10 @@ collision.
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ </c:dependencies>
+
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl?rev=1037480&r1=1037479&r2=1037480&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/numberStatesAndTransitions.xsl Sun Nov 21 15:40:20 2010
@@ -6,6 +6,11 @@
version="1.0">
<xsl:output method="xml"/>
+ <c:dependencies>
+ <c:dependency path="appendBasicStateInformation.xsl"/>
+ <c:dependency path="normalizeInitialStates.xsl"/>
+ </c:dependencies>
+
<!-- we copy them, so that we can use their positions as identifiers -->
<!-- identity transform -->
Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl?rev=1037480&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl Sun Nov 21 15:40:20 2010
@@ -0,0 +1,197 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<!--
+This stylesheet takes as input an XSL stylesheet with its depdencies
+defined in the scxml-js namespace. It then topolgically sorts all
+dependencies, and returns an XML file with the paths to the stylesheets
+in topologically-sorted order.
+-->
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:c="http://commons.apache.org/scxml-js"
+ xmlns:exsl="http://exslt.org/common"
+ version="1.0">
+ <xsl:output method="xml"/>
+
+ <!-- this should be overridden by the user -->
+ <xsl:param name="root-path" value="'root'"/>
+
+
+ <xsl:template match="/">
+ <xsl:variable name="dependency-graph-fragment">
+ <xsl:call-template name="load-dependency-graph">
+ <xsl:with-param name="paths-already-visited" select="/.."/>
+ <xsl:with-param name="this-path" select="$root-path"/>
+ <xsl:with-param name="current-node" select="."/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="dependency-graph-node-set" select="exsl:node-set($dependency-graph-fragment)"/>
+
+ <!--
+ <xsl:copy-of select="$dependency-graph-node-set"/>
+ -->
+
+ <xsl:variable name="unique-dependency-graph-node-set"
+ select="$dependency-graph-node-set/c:stylesheet[not(@path = preceding-sibling::c:stylesheet/@path)]"/>
+
+ <!--
+ <xsl:value-of select="count($unique-dependency-graph-node-set)"/>
+ -->
+
+ <xsl:variable name="starting-nodes-without-dependencies" select="$unique-dependency-graph-node-set[not(c:dependency)]"/>
+
+ <!--
+ <xsl:copy-of select="$starting-nodes-without-dependencies"/>
+ -->
+ <c:topologicallySortedDependencyList>
+ <xsl:call-template name="topo-sort">
+ <xsl:with-param name="nodes-without-dependencies" select="$starting-nodes-without-dependencies"/>
+ <xsl:with-param name="processed-nodes" select="/.."/>
+ <xsl:with-param name="dependency-graph-node-set" select="$unique-dependency-graph-node-set"/>
+ </xsl:call-template>
+ </c:topologicallySortedDependencyList>
+ </xsl:template>
+
+ <xsl:template name="topo-sort">
+ <xsl:param name="nodes-without-dependencies"/>
+ <xsl:param name="processed-nodes"/>
+ <xsl:param name="dependency-graph-node-set"/>
+
+ <xsl:variable name="next-processed-nodes" select="$processed-nodes | $nodes-without-dependencies"/>
+
+ <!-- shallow copy -->
+ <xsl:for-each select="$nodes-without-dependencies">
+ <xsl:copy>
+ <xsl:attribute name="path"><xsl:value-of select="@path"/></xsl:attribute>
+ </xsl:copy>
+ </xsl:for-each>
+
+ <!--
+ <xsl:text>nodes-without-dependencies : </xsl:text>
+ <xsl:text>count : </xsl:text><xsl:value-of select="count($nodes-without-dependencies)"/><xsl:text> </xsl:text>
+ <xsl:for-each select="$nodes-without-dependencies">
+ <xsl:text>path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+ </xsl:for-each>
+ <xsl:text>+++++++++++++++++++++++++++++++++++++++++ </xsl:text>
+
+
+ <xsl:text>next-processed-nodes : </xsl:text>
+ <xsl:text>count : </xsl:text><xsl:value-of select="count($next-processed-nodes)"/><xsl:text> </xsl:text>
+ <xsl:for-each select="$next-processed-nodes">
+ <xsl:text>path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+ </xsl:for-each>
+ <xsl:text>///////////////////////////////////////// </xsl:text>
+
+
+ <xsl:variable name="unprocessed-nodes" select="$dependency-graph-node-set[not($next-processed-nodes/@path = @path)]"/>
+
+ <xsl:text>unprocessed-nodes : </xsl:text>
+ <xsl:text>count : </xsl:text><xsl:value-of select="count($unprocessed-nodes)"/><xsl:text> </xsl:text>
+ <xsl:for-each select="$unprocessed-nodes">
+ <xsl:text>path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+ </xsl:for-each>
+ <xsl:text>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ </xsl:text>
+
+ <xsl:variable name="nodes-whose-deps-have-all-been-processed"
+ select="$dependency-graph-node-set[count(c:dependency) != count(c:dependency[$next-processed-nodes/@path = @path])]"/>
+
+ <xsl:text>nodes-whose-deps-have-all-been-processed : </xsl:text>
+ <xsl:text>count : </xsl:text><xsl:value-of select="count($nodes-whose-deps-have-all-been-processed)"/><xsl:text> </xsl:text>
+ <xsl:for-each select="$nodes-whose-deps-have-all-been-processed">
+ <xsl:text>path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+
+ <xsl:text> count-dep : </xsl:text><xsl:value-of select="count(c:dependency)"/><xsl:text> </xsl:text>
+ <xsl:for-each select="c:dependency">
+ <xsl:text> dep-path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+ </xsl:for-each>
+
+ <xsl:text> .......unprocessed dependencies: </xsl:text>
+ <xsl:for-each select="c:dependency[not($next-processed-nodes/@path = @path)]">
+ <xsl:text> unprocessed-dep-path : </xsl:text><xsl:value-of select="@path"/><xsl:text> </xsl:text>
+ </xsl:for-each>
+ </xsl:for-each>
+ <xsl:text>========================================= </xsl:text>
+ -->
+
+ <!-- base case: no nodes left in the graph -->
+ <xsl:if test="count($next-processed-nodes) < count($dependency-graph-node-set)">
+
+ <!-- select the next nodes such that those nodes have not been processed, and they have no dependencies that have not been processed -->
+ <xsl:variable name="next-nodes-without-dependencies"
+ select="$dependency-graph-node-set[
+ not($next-processed-nodes/@path = @path)
+ and count(c:dependency) = count(c:dependency[$next-processed-nodes/@path = @path])]"/>
+
+ <xsl:if test="$next-nodes-without-dependencies">
+ <xsl:call-template name="topo-sort">
+ <xsl:with-param name="nodes-without-dependencies" select="$next-nodes-without-dependencies"/>
+ <xsl:with-param name="processed-nodes" select="$next-processed-nodes"/>
+ <xsl:with-param name="dependency-graph-node-set" select="$dependency-graph-node-set"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+
+ </xsl:template>
+
+ <xsl:template name="load-dependency-graph">
+ <xsl:param name="paths-already-visited"/>
+ <xsl:param name="this-path"/>
+ <xsl:param name="current-node"/>
+
+ <xsl:variable name="dep-paths" select="$current-node/xsl:stylesheet/c:dependencies/c:dependency"/>
+
+ <!--
+ <xsl:message>
+ this-path: <xsl:value-of select="$this-path"/>
+ dep-paths: <xsl:value-of select="count($dep-paths)"/>
+ </xsl:message>
+ -->
+
+ <!-- write out his dependencies -->
+ <c:stylesheet path="{$this-path}">
+ <xsl:copy-of select="$dep-paths"/>
+ </c:stylesheet>
+
+ <!-- visit all other depdencies -->
+ <xsl:for-each select="$dep-paths">
+ <xsl:variable name="dep-path" select="@path"/>
+ <!--
+ <xsl:message>
+ dep-path : <xsl:value-of select="$dep-path"/>
+ </xsl:message>
+ -->
+
+ <xsl:if test="not($paths-already-visited[.=$dep-path])">
+
+ <!-- read the doc -->
+ <xsl:variable name="dep-doc" select="document(concat('../ir-compiler/',$dep-path))"/>
+
+ <xsl:call-template name="load-dependency-graph">
+ <xsl:with-param name="this-path" select="$dep-path"/>
+ <xsl:with-param name="current-node" select="$dep-doc"/>
+ <xsl:with-param name="paths-already-visited" select="$paths-already-visited | $dep-path"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+
+
+</xsl:stylesheet>
+
+
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/util/topo-sort.xsl
------------------------------------------------------------------------------
svn:eol-style = native