diff --git a/pom.xml b/pom.xml
index f120a0d..4d6c915 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.smooks.cartridges
smooks-templating-cartridge
- 2.1.0
+ 2.1.1-SNAPSHOT
Smooks Templating Cartridge
https://www.smooks.org
@@ -46,12 +46,12 @@
org.smooks
smooks-core
- 2.1.0
+ 2.2.0-SNAPSHOT
org.smooks.cartridges
smooks-javabean-cartridge
- 2.0.1
+ 2.0.2-SNAPSHOT
test
diff --git a/src/main/java/org/smooks/cartridges/templating/xslt/XslTemplateProcessor.java b/src/main/java/org/smooks/cartridges/templating/xslt/XslTemplateProcessor.java
index b2a4758..ae095b3 100644
--- a/src/main/java/org/smooks/cartridges/templating/xslt/XslTemplateProcessor.java
+++ b/src/main/java/org/smooks/cartridges/templating/xslt/XslTemplateProcessor.java
@@ -58,7 +58,7 @@
import org.smooks.cartridges.templating.AbstractTemplateProcessor;
import org.smooks.engine.delivery.AbstractParser;
import org.smooks.engine.delivery.dom.serialize.GhostElementSerializerVisitor;
-import org.smooks.engine.resource.config.ParameterAccessor;
+import org.smooks.engine.lookup.GlobalParamsLookup;
import org.smooks.io.sink.DOMSink;
import org.smooks.io.sink.StreamSink;
import org.smooks.io.sink.WriterSink;
@@ -203,9 +203,9 @@ protected void applyTemplate(Element element, ExecutionContext executionContext,
} catch (TransformerException e) {
throw new SmooksException("Error applying XSLT to node [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "]", e);
}
-
+ final boolean closeEmptyElements = Boolean.parseBoolean(executionContext.getApplicationContext().getRegistry().lookup(new GlobalParamsLookup()).getParameterValue(Filter.CLOSE_EMPTY_ELEMENTS));
try {
- writer.write(XmlUtils.serialize(ghostElement.getChildNodes(), Boolean.parseBoolean(ParameterAccessor.getParameterValue(Filter.CLOSE_EMPTY_ELEMENTS, String.class, "false", executionContext.getContentDeliveryRuntime().getContentDeliveryConfig()))));
+ writer.write(XmlUtils.serialize(ghostElement.getChildNodes(), closeEmptyElements));
} catch (IOException e) {
throw new SmooksException(e.getMessage(), e);
}
diff --git a/src/test/java/org/smooks/cartridges/templating/freemarker/FreeMarkerProgramaticConfigTestCase.java b/src/test/java/org/smooks/cartridges/templating/freemarker/FreeMarkerProgramaticConfigTestCase.java
index 5ed7080..4def76f 100644
--- a/src/test/java/org/smooks/cartridges/templating/freemarker/FreeMarkerProgramaticConfigTestCase.java
+++ b/src/test/java/org/smooks/cartridges/templating/freemarker/FreeMarkerProgramaticConfigTestCase.java
@@ -54,6 +54,7 @@
import org.smooks.cartridges.templating.MyBean;
import org.smooks.cartridges.templating.TemplatingConfiguration;
import org.smooks.engine.DefaultApplicationContextBuilder;
+import org.smooks.engine.DefaultFilterSettings;
import org.smooks.engine.resource.visitor.smooks.NestedSmooksVisitor;
import org.smooks.io.sink.StringSink;
import org.smooks.io.source.ReaderSource;
@@ -74,12 +75,12 @@ public class FreeMarkerProgramaticConfigTestCase {
@Test
public void testFreeMarkerTrans_01() throws SAXException, IOException {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.REPLACE));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
Bean bean = new Bean(MyBean.class, "myBeanData", "c", smooks.getApplicationContext().getRegistry());
@@ -93,13 +94,13 @@ public void testFreeMarkerTrans_01() throws SAXException, IOException {
@Test
public void test_nodeModel_1() {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("<#foreach c in a.b.c>'${c}'#foreach>")), "a");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("<#foreach c in a.b.c>'${c}'#foreach>")), "a");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setMaxNodeDepth(Integer.MAX_VALUE);
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.REPLACE));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
smooks.addVisitor(nestedSmooksVisitor, "a");
@@ -111,13 +112,13 @@ public void test_nodeModel_1() {
@Test
public void test_nodeModel_2() throws IOException, SAXException {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("'${c}'")), "c");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("'${c}'")), "c");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setMaxNodeDepth(Integer.MAX_VALUE);
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.REPLACE));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
smooks.addVisitor(nestedSmooksVisitor, "c");
@@ -127,43 +128,43 @@ public void test_nodeModel_2() throws IOException, SAXException {
@Test
public void testFreeMarkerTrans_bind() {
- StringReader input;
- ExecutionContext context;
+ StringReader stringReader;
+ ExecutionContext executionContext;
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("${myBeanData.x}")), "c");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("${myBeanData.x}")), "c");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setMaxNodeDepth(Integer.MAX_VALUE);
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.BIND_TO));
nestedSmooksVisitor.setBindIdOptional(Optional.of("mybeanTemplate"));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
Bean bean = new Bean(MyBean.class, "myBeanData", "c", smooks.getApplicationContext().getRegistry());
smooks.addVisitors(bean.bindTo("x", "c/@x"));
smooks.addVisitor(nestedSmooksVisitor, "c");
- context = smooks.createExecutionContext();
- input = new StringReader("");
- smooks.filterSource(context, new ReaderSource<>(input), null);
+ executionContext = smooks.createExecutionContext();
+ stringReader = new StringReader("");
+ smooks.filterSource(executionContext, new ReaderSource<>(stringReader), null);
- assertEquals("xvalueonc2", context.getBeanContext().getBean("mybeanTemplate"));
+ assertEquals("xvalueonc2", executionContext.getBeanContext().getBean("mybeanTemplate"));
- context = smooks.createExecutionContext();
- input = new StringReader("");
- smooks.filterSource(context, new ReaderSource<>(input), null);
- assertEquals("xvalueonc1", context.getBeanContext().getBean("mybeanTemplate"));
+ executionContext = smooks.createExecutionContext();
+ stringReader = new StringReader("");
+ smooks.filterSource(executionContext, new ReaderSource<>(stringReader), null);
+ assertEquals("xvalueonc1", executionContext.getBeanContext().getBean("mybeanTemplate"));
}
@Test
public void testInsertBefore() throws SAXException, IOException {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.PREPEND_BEFORE));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
Bean bean = new Bean(MyBean.class, "myBeanData", "b", smooks.getApplicationContext().getRegistry());
@@ -184,12 +185,12 @@ public void testInsertBefore() throws SAXException, IOException {
@Test
public void testInsertAfter() throws SAXException, IOException {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")), "c");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.APPEND_AFTER));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
Bean bean = new Bean(MyBean.class, "myBeanData", "b", smooks.getApplicationContext().getRegistry());
@@ -208,8 +209,8 @@ public void testInsertAfter() throws SAXException, IOException {
@Test
public void testAddTo() throws SAXException, IOException {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addVisitor(
new FreeMarkerTemplateProcessor(
new TemplatingConfiguration("/org/smooks/cartridges/templating/freemarker/test-template.ftl")
),
@@ -218,7 +219,7 @@ public void testAddTo() throws SAXException, IOException {
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.PREPEND_AFTER));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
Bean bean = new Bean(MyBean.class, "myBeanData", "b", smooks.getApplicationContext().getRegistry());
@@ -251,12 +252,12 @@ public void testAddTo() throws SAXException, IOException {
@Test
public void test_outputTo_Stream() {
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("data to outstream")), "#document");
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).withFilterSettings(new DefaultFilterSettings().setCloseSink(false)).build());
+ pipeline.addVisitor(new FreeMarkerTemplateProcessor(new TemplatingConfiguration("data to outstream")), "#document");
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(NestedSmooksVisitor.Action.OUTPUT_TO));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
nestedSmooksVisitor.setOutputStreamResourceOptional(Optional.of("outRes"));
Smooks smooks = new Smooks();
diff --git a/src/test/java/org/smooks/cartridges/templating/xslt/XslContentHandlerFactoryTest.java b/src/test/java/org/smooks/cartridges/templating/xslt/XslContentHandlerFactoryTest.java
index 307a814..cda5066 100644
--- a/src/test/java/org/smooks/cartridges/templating/xslt/XslContentHandlerFactoryTest.java
+++ b/src/test/java/org/smooks/cartridges/templating/xslt/XslContentHandlerFactoryTest.java
@@ -99,12 +99,12 @@ public void testXslUnitTrans_parambased(NestedSmooksVisitor.Action action, Strin
res.setResourceType("xsl");
res.setParameter(XslContentHandlerFactory.IS_XSLT_TEMPLATELET, "true");
- Smooks nestedSmooks = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
- nestedSmooks.addResourceConfig(res);
+ Smooks pipeline = new Smooks(new DefaultApplicationContextBuilder().withSystemResources(false).build());
+ pipeline.addResourceConfig(res);
NestedSmooksVisitor nestedSmooksVisitor = new NestedSmooksVisitor();
nestedSmooksVisitor.setAction(Optional.of(action));
- nestedSmooksVisitor.setNestedSmooks(nestedSmooks);
+ nestedSmooksVisitor.setPipeline(pipeline);
Smooks smooks = new Smooks();
smooks.addVisitor(nestedSmooksVisitor, "p");