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:51 UTC

svn commit: r954090 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: runner.js src/scxml/cgf/SCXMLCompiler.js

Author: jbeard
Date: Sat Jun 12 19:38:50 2010
New Revision: 954090

URL: http://svn.apache.org/viewvc?rev=954090&view=rev
Log:
Rhino front-end now hooked up and generating code using SAX XML filters API. Need to do some testing, make sure it's correct.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/runner.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/runner.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/runner.js?rev=954090&r1=954089&r2=954090&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/runner.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/runner.js Sat Jun 12 19:38:50 2010
@@ -78,7 +78,7 @@ if(arguments.length){
 	load(pathToRequireJsDir + "require.js");
 	load(pathToRequireJsDir + "require/rhino.js");
 	load(pathToRequireJsDir + "require/text.js");
-
+	
 	//bootstrap require.js
 	require({
 		baseUrl : absoluteScriptDir 	//fixme: needs absolute path?  

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js?rev=954090&r1=954089&r2=954090&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js Sat Jun 12 19:38:50 2010
@@ -33,6 +33,7 @@ require.def("src/scxml/cgf/SCXMLCompiler
 	function(xsltIRFilters,fileUtil){
 
 		//import packages
+		importPackage(javax.xml.transform.dom);
 		importPackage(javax.xml.transform);
 		importPackage(javax.xml.transform.stream);
 		importPackage(javax.xml.transform.sax);
@@ -42,7 +43,7 @@ require.def("src/scxml/cgf/SCXMLCompiler
 
 		//importPackage(Packages.org.apache.commons.io);
 		importClass(java.io.ByteArrayOutputStream);
-
+		importClass(java.io.StringReader);
 
 		/*
 		    supported options:
@@ -57,14 +58,23 @@ require.def("src/scxml/cgf/SCXMLCompiler
 		*/
 		function compile(options){
 			if(!options.inFiles) return false;
-
+debugger;
 			//do transforms
 			var tFactory = TransformerFactory.newInstance();
 
 			var filterList = xsltIRFilters.map(function(xsltDoc){
-				return tFactory.newXMLFilter(new DOMSource(xsltDoc));
+				return tFactory.newXMLFilter(new StreamSource(new StringReader(xsltDoc)));
 			});
 
+			//we do this one separately from the others, because he has external dependencies, 
+			//and thus needs to be given the path to the file, rather than just the file's string representation
+			//FIXME: I think require.nameToUrl is not supposed to be a public API, even though it should be...
+			var statePatternStatechartGeneratorXslPath = require.nameToUrl("test/xslt/StatePatternStatechartGenerator",".xsl","_");
+
+			var generatorFilter = tFactory.newXMLFilter(new StreamSource(statePatternStatechartGeneratorXslPath));
+
+			filterList = filterList.concat(generatorFilter);
+		
 			var reader = XMLReaderFactory.createXMLReader();
 
 			var prevFilter = null;
@@ -73,8 +83,6 @@ require.def("src/scxml/cgf/SCXMLCompiler
 				prevFilter = filter;
 			})
 
-			var lastFilter = prevFilter;
-
 			var xmlProps = OutputPropertiesFactory.getDefaultMethodProperties("xml");
 			xmlProps.setProperty("indent", "yes");
 			xmlProps.setProperty("standalone", "no"); 
@@ -89,9 +97,9 @@ require.def("src/scxml/cgf/SCXMLCompiler
 				var baos = new ByteArrayOutputStream();
 
 				serializer.setOutputStream(baos);
-				lastFilter.setContentHandler(serializer.asContentHandler());
+				generatorFilter.setContentHandler(serializer.asContentHandler());
 
-				lastFilter.parse(new InputSource(xmlFile));
+				generatorFilter.parse(new InputSource(xmlFile));
 
 				var transformedJs = String(new java.lang.String(baos.toByteArray()));