use of org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition in project webtools.sourceediting by eclipse.
the class LaunchHelper method save.
public void save(File file) throws CoreException {
BufferedWriter writer = null;
try {
// ensure it exists
file.createNewFile();
writer = new BufferedWriter(new FileWriter(file));
PipelineDefinition pdef = new PipelineDefinition();
for (Iterator<?> iter = attributes.getAttributes().iterator(); iter.hasNext(); ) {
LaunchAttribute att = (LaunchAttribute) iter.next();
pdef.addAttribute(new TypedValue(att.uri, TypedValue.TYPE_STRING, att.value));
}
for (Iterator<?> iter = pipeline.getTransformDefs().iterator(); iter.hasNext(); ) {
LaunchTransform lt = (LaunchTransform) iter.next();
TransformDefinition tdef = new TransformDefinition();
URL url = pathToURL(lt.getLocation());
tdef.setStylesheetURL(url.toExternalForm());
tdef.setResolverClass(lt.getResolver());
for (Iterator<?> iterator = lt.getParameters().iterator(); iterator.hasNext(); ) {
LaunchAttribute att = (LaunchAttribute) iterator.next();
tdef.addParameter(new TypedValue(att.uri, TypedValue.TYPE_STRING, att.getResolvedValue()));
}
// set the output props for the LAST transform only
if (!iter.hasNext()) {
for (Map.Entry<String, String> entry : outputProperties.getProperties().entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
if (name != null && value != null)
tdef.setOutputProperty(name, value);
}
}
pdef.addTransformDef(tdef);
}
Document doc = pdef.toXML();
String s = PreferenceUtil.serializeDocument(doc);
writer.write(s);
} catch (FileNotFoundException e) {
throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, Messages.LaunchHelper_0, e));
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, Messages.LaunchHelper_1, e));
} catch (ParserConfigurationException e) {
throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, "ParserConfigurationException", // $NON-NLS-1$
e));
} catch (TransformerException e) {
throw new CoreException(new Status(IStatus.ERROR, JAXPLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, "TransformerException", // $NON-NLS-1$
e));
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
JAXPLaunchingPlugin.log(e);
}
}
}
}
use of org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition in project webtools.sourceediting by eclipse.
the class PipelineDefintionTest method setupTransformDefinition.
private TransformDefinition setupTransformDefinition() {
TransformDefinition tdef = new TransformDefinition();
pldef.addTransformDef(tdef);
return tdef;
}
use of org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition in project webtools.sourceediting by eclipse.
the class PipelineDefintionTest method testRemoveTransformDefintion.
@Test
public void testRemoveTransformDefintion() throws Exception {
TransformDefinition tdef = setupTransformDefinition();
assertEquals(1, pldef.getTransformDefs().size());
pldef.removeTransformDef(tdef);
assertEquals(0, pldef.getTransformDefs().size());
}
use of org.eclipse.wst.xsl.jaxp.debug.invoker.TransformDefinition in project webtools.sourceediting by eclipse.
the class TestJAXPProcessorInvoker method testSimpleTransform.
@Test
public void testSimpleTransform() throws Exception {
URL surl = TestJAXPProcessorInvoker.class.getResource("1-input.xml");
URL xslt = TestJAXPProcessorInvoker.class.getResource("1-transform.xsl");
PipelineDefinition pipe = new PipelineDefinition();
TransformDefinition tdef = new TransformDefinition();
tdef.setStylesheetURL(xslt.toExternalForm());
pipe.addTransformDef(tdef);
pipe.configure(invoker);
InputSource source = new InputSource(surl.openStream());
DOMResult result = new DOMResult();
invoker.transform(source, result);
Document node = (Document) result.getNode();
assertNotNull("Did not get a result document.", node);
assertEquals("Missing root-out node name.", "root-out", node.getDocumentElement().getLocalName());
}
Aggregations