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:39:10 UTC
svn commit: r954093 -
/commons/sandbox/gsoc/2010/scxml-js/trunk/src/scxml/cgf/SCXMLCompiler.js
Author: jbeard
Date: Sat Jun 12 19:39:10 2010
New Revision: 954093
URL: http://svn.apache.org/viewvc?rev=954093&view=rev
Log:
Still not working.
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=954093&r1=954092&r2=954093&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:39:10 2010
@@ -62,30 +62,34 @@ require.def("src/scxml/cgf/SCXMLCompiler
var tFactory = TransformerFactory.newInstance();
var filterList = xsltIRFilters.map(function(xsltDoc){
- return tFactory.newXMLFilter(new StreamSource(new StringReader(xsltDoc)));
+ return tFactory.newTransformerHandler(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));
+ var generatorFilter = tFactory.newTransformerHandler(new StreamSource(statePatternStatechartGeneratorXslPath));
filterList = filterList.concat(generatorFilter);
var reader = XMLReaderFactory.createXMLReader();
- var prevFilter = null;
- filterList.forEach(function(filter){
- filter.setParent(prevFilter || reader);
- prevFilter = filter;
- })
+ for(var i = 1; i < filterList.length; i++){
+ var result = new SAXResult(filterList[i]);
+ filterList[i-1].setResult(result);
+ }
+
+ var firstFilter = filterList[1];
+ /*
var xmlProps = OutputPropertiesFactory.getDefaultMethodProperties("text");
xmlProps.setProperty("indent", "yes");
xmlProps.setProperty("standalone", "no");
var serializer = SerializerFactory.getSerializer(xmlProps);
+ */
var toReturn = options.inFiles.map(function(xmlFile){
@@ -95,22 +99,27 @@ require.def("src/scxml/cgf/SCXMLCompiler
var baos = new ByteArrayOutputStream();
- serializer.setOutputStream(baos);
- //generatorFilter.setContentHandler(serializer.asContentHandler());
-
- //can't pass in parameters in this way
- //generatorFilter.parse(new InputSource(xmlFile));
-
- // Set up the transformer to process the SAX events generated by the last filter in the chain
- var transformer = tFactory.newTransformer();
- transformer.setOutputProperties(xmlProps);
+ generatorFilter.setResult(new StreamResult(baos));
+ var firstFilterTransformer = firstFilter.getTransformer();
+ /*
for(optName in options){
- transformer.setParameter(optName,options[optName]);
+ firstFilterTransformer.setParameter(optName,options[optName]);
}
+ */
- var transformSource = new SAXSource( generatorFilter, new InputSource(xmlFile));
- transformer.transform(transformSource, new StreamResult(baos));
+ // Set up the transformer to process the SAX events generated by the last filter in the chain
+ var factory= javax.xml.parsers.SAXParserFactory.newInstance();
+ factory.setNamespaceAware( true );
+ var jaxpParser= factory.newSAXParser();
+ var reader=jaxpParser.getXMLReader()// || XMLReaderFactory.createXMLReader();
+
+ reader.setContentHandler(firstFilter);
+
+ // Parse the source XML, and send the parse events to the
+ // TransformerHandler.
+debugger
+ reader.parse(xmlFile);
var transformedJs = String(new java.lang.String(baos.toByteArray()));