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/25 03:39:21 UTC

svn commit: r957779 - in /commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137: ./ src/javascript/scxml/cgf/ src/javascript/scxml/cgf/backends/js/ src/javascript/scxml/cgf/util/

Author: jbeard
Date: Fri Jun 25 01:39:21 2010
New Revision: 957779

URL: http://svn.apache.org/viewvc?rev=957779&view=rev
Log:
Updated branch from trunk.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/   (props changed)
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/Transformer.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
    commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/util/xml.js

Propchange: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 25 01:39:21 2010
@@ -1 +1,2 @@
 /commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie:954350-956951
+/commons/sandbox/gsoc/2010/scxml-js/trunk:957703-957778

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/build.js Fri Jun 25 01:39:21 2010
@@ -21,12 +21,13 @@ require.def("build",
 		"src/javascript/scxml/cgf/util/file",	
 		"src/javascript/scxml/cgf/SCXMLCompiler",
 		"src/javascript/scxml/cgf/PerformanceAnalyzer",
+		"src/javascript/scxml/cgf/Transformer",
 		"src/javascript/scxml/cgf/util/xml",
 		"test/testHelpers.js",
 		"lib/js/json2.js",
 		"lib/test-js/env.js",
 		"lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js"],
-	function(util,utilFile,SCXMLCompiler,PerformanceAnalyzer,xmlUtil){
+	function(util,utilFile,SCXMLCompiler,PerformanceAnalyzer,Transformer,xmlUtil){
 
 		return function(args){
 
@@ -77,6 +78,22 @@ require.def("build",
 				KitchenSink_executableContent :"test/kitchen_sink/KitchenSink_executableContent.xml"
 			}
 
+			//FIXME: this violates Don't Repeat Yourself; these paths are written here and in the module
+			//we need a central configuration file to store it
+			var stylesheetsToPreprocess = [ {
+								from:"src/xslt/backends/js/StatePatternStatechartGenerator.xsl",
+								to:"build/StatePatternStatechartGenerator_combined.xsl"
+							} ,
+							{
+								from:"src/xslt/backends/js/StateTableStatechartGenerator.xsl",
+								to:"build/StateTableStatechartGenerator_combined.xsl"
+							},
+							{
+								from:"src/xslt/backends/js/SwitchyardStatechartGenerator.xsl",
+								to:"build/SwitchyardStatechartGenerator_combined.xsl"
+							} ];
+
+			var pathToPreprocessScript = "src/xslt/util/preprocess_import.xsl"
 
 			var performanceTestScripts = [ 
 				{ 
@@ -197,9 +214,24 @@ require.def("build",
 					d.mkdir();
 				},
 
-				genJavaScript : function(compilerCallback){
+				preprocessStylesheets : function(){
 					this.init(); 
 
+					print("Preprocesssing xsl stylesheets that use xsl:import...");
+
+					stylesheetsToPreprocess.forEach(function({from:inDoc,to:to}){
+						print("Preprocessing " + inDoc + " to " + to );
+						var transform = [xmlUtil.parseFromPath(pathToPreprocessScript)];
+						var outDoc = Transformer(inDoc,transform,null,"xml");
+						var xmlStr = xmlUtil.serializeToString(outDoc);
+						utilFile.writeFile(xmlStr,to); 
+					});
+					
+				},
+
+				genJavaScript : function(compilerCallback){
+					this.preprocessStylesheets();
+
 					print("Compiling SCXML files...");
 
 					var compileTargets = [{scxmlTest:scxmlTest,backend:backend} 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/Transformer.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/Transformer.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/Transformer.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/Transformer.js Fri Jun 25 01:39:21 2010
@@ -11,6 +11,7 @@ function(xmlUtil){
 					XMLReaderFactory = Packages.org.xml.sax.helpers.XMLReaderFactory,
 					ByteArrayOutputStream = java.io.ByteArrayOutputStream,
 					StreamResult = javax.xml.transform.stream.StreamResult,
+					StreamSource = javax.xml.transform.stream.StreamSource,
 					DOMSource = javax.xml.transform.dom.DOMSource,
 					SAXResult = javax.xml.transform.sax.SAXResult,
 					DOMResult = javax.xml.transform.dom.DOMResult;
@@ -31,7 +32,10 @@ function(xmlUtil){
 						}
 
 						// Use the DOM Document to define a DOMSource object.
-						var xmlDomSource = new DOMSource(xml);
+						// for Rhino only, we can also accept a path rather than a Document
+						var xmlDomSource = typeof xml == "string" ? 	
+									new StreamSource(xml) :
+									new DOMSource(xml);
 
 						var toReturn;
 						switch(output){

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js Fri Jun 25 01:39:21 2010
@@ -5,9 +5,7 @@ require.def(
 	[
 		"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
 		"xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
-		//stylesheet must be preprocessed with preprocess_import.xsl for IE and maybe chrome
-		"xml!src/xslt/backends/js/StatePatternStatechartGenerator_combined.xsl" 
-		//"xml!src/xslt/backends/js/StatePatternStatechartGenerator.xsl" 
+		"xml!build/StatePatternStatechartGenerator_combined.xsl" //preprocessed stylesheet
 	],
 
 	function(

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js Fri Jun 25 01:39:21 2010
@@ -3,8 +3,8 @@ require.def(
 	"src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator",
 
 	[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator", 
-		// "xml!src/xslt/backends/js/StateTableStatechartGenerator.xsl" 
-		"xml!src/xslt/backends/js/StateTableStatechartGenerator_combined.xsl" ],
+		"xml!build/StateTableStatechartGenerator_combined.xsl" //preprocessed stylesheet
+	],
 
 	function(AbstractEnumeratedStatechartGenerator,StateTableStatechartGenerator){
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js Fri Jun 25 01:39:21 2010
@@ -3,8 +3,8 @@ require.def(
 	"src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator",
 
 	[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator", 
-		// "xml!src/xslt/backends/js/SwitchyardStatechartGenerator.xsl" 
-		"xml!src/xslt/backends/js/SwitchyardStatechartGenerator_combined.xsl" ],
+		"xml!build/SwitchyardStatechartGenerator_combined.xsl" //preprocessed stylesheet
+	],
 
 	function(AbstractEnumeratedStatechartGenerator,SwitchyardStatechartGenerator){
 

Modified: commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/util/xml.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/util/xml.js?rev=957779&r1=957778&r2=957779&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/util/xml.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/core-module.SCXML-137/src/javascript/scxml/cgf/util/xml.js Fri Jun 25 01:39:21 2010
@@ -17,9 +17,8 @@ function(){
 						var baos = new ByteArrayOutputStream();
 						var serializer = new Packages.org.apache.xml.serialize.XMLSerializer(
 									baos,
-									new Packages.org.apache.xml.serialize.OutputFormat);
+									new Packages.org.apache.xml.serialize.OutputFormat());
 
-						serializer.setOutputStream(baos);
 						serializer.asDOMSerializer().serialize(d);
 
 						var toReturn = String(new java.lang.String(baos.toByteArray()));