commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r954075 - /commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
Date Sat, 12 Jun 2010 19:37:02 GMT
Author: jbeard
Date: Sat Jun 12 19:37:01 2010
New Revision: 954075

URL: http://svn.apache.org/viewvc?rev=954075&view=rev
Log:
Intermediate commit. Totally  broken, just want to make sure things are backed up (sketchy
laptop).

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

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=954075&r1=954074&r2=954075&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:37:01
2010
@@ -190,15 +190,6 @@ require.def("src/scxml/cgf/SCXMLCompiler
 				});
 
 				var factory = XPathFactory.newInstance();
-				xpath = factory.newXPath();
-				xpath.setNamespaceContext(personalNamespaceContext);
-
-				var expr = xpath.compile("//s:transition");
-				var result = expr.evaluate(doc, XPathConstants.NODESET);
-
-				print(result);
-				print(result.length);
-				debugger;
 
 				function nodesetToJsArray (args){
 					var toReturn = [];
@@ -210,28 +201,50 @@ require.def("src/scxml/cgf/SCXMLCompiler
 					return toReturn;
 				}
 
-				var arr = nodesetToJsArray(result);
-				arr.forEach(function(n){print(n.getAttributeNS(null,"event"))});
+				function $(query){
+					xpath = factory.newXPath();
+					xpath.setNamespaceContext(personalNamespaceContext);
+
+					var expr = xpath.compile(query);
+					var result = expr.evaluate(doc, XPathConstants.NODESET);
+
+					print(result);
+					print(result.length);
+
+					var arr = nodesetToJsArray(result);
+					return arr;
+				}
+
+
 
 				//do a bit of verification and normalization transformations
 
-				/*
 				//make all names we will use for variables legal
-				scxmlRoot..transition.(@event.length() && (@event = makeLegalLValue(@event)));
+				var transitions = $("//s:transition");
+				transitions.forEach(function(n){
+					n.setAttributeNS(null,"event",
+						makeLegalLValue(
+							n.getAttributeNS(null,"event")));
+				});
 
 				//make sure root has an id
-				scxmlRoot.@id = "Root"
+				doc.documentElement.setAttributeNS(null,"id","Root");
 
 				//normalize initial states
-				util.foreach(scxmlRoot..*.(@initial.length() > 0),function(s){
-					s.initial.transition.@target = s.@initial.toString();
-					delete s.@initial;
-				});
+				$("//s:*[@initial]").forEach(function(n){
+					var newInitial = doc.createElementNS(scxmlNs,"initial");
+					var newTransition = doc.createElementNS(scxmlNs,"transition");
+
+					n.appendChild(newInitial);
+					newInitial.appendChild(newTransition);
 
-				//make sure all transitions have id's
-				//var transitionid = 0;
-				//scxml..transition.(!@id.length() && (@id = "transition_" + transitionid++));
+					newInitial.setAttributeNS(null,"target",
+						n.getAttributeNS(null,"initial"));
 
+					//TODO: delete attribute somehow
+				});
+
+				/*
 				//we use both a dictionary and an array so that we can use both forEach and "in", which
makes the code pretty
 				var stateTagsArray = ["state", "parallel" , "final" , "initial" , "scxml" , "history"
];
 				var stateTagsHash = {}



Mime
View raw message