Last active
February 15, 2021 11:47
-
-
Save cjmamo/db790ce86c7ac65581f62c7b4cd4b2a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import org.milyn.SmooksException; | |
import org.milyn.container.ExecutionContext; | |
import org.milyn.delivery.dom.DOMElementVisitor; | |
import org.milyn.delivery.sax.SAXElement; | |
import org.milyn.delivery.sax.SAXElementVisitor; | |
import org.milyn.delivery.sax.SAXText; | |
import org.w3c.dom.Element; | |
public class MyDomAndSaxVisitor implements SAXElementVisitor, DOMElementVisitor { | |
@Override | |
public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation at the beginning of a DOM element..."); | |
... | |
} | |
@Override | |
public void visitAfter(Element element, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation at the end of a DOM element..."); | |
... | |
} | |
@Override | |
public void visitBefore(SAXElement element, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation at the beginning of a SAX element event..."); | |
... | |
} | |
@Override | |
public void onChildText(SAXElement element, SAXText childText, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation on a SAX child text event..."); | |
... | |
} | |
@Override | |
public void onChildElement(SAXElement element, SAXElement childElement, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation on a SAX child element event..."); | |
... | |
} | |
@Override | |
public void visitAfter(SAXElement element, ExecutionContext executionContext) throws SmooksException { | |
System.out.println("Applying operation at the end of a SAX element event..."); | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import org.smooks.container.ExecutionContext; | |
import org.smooks.delivery.sax.ng.ElementVisitor; | |
import org.w3c.dom.Element; | |
public class MySaxNgVisitor implements ElementVisitor { | |
@Override | |
public void visitBefore(Element element, ExecutionContext executionContext) { | |
System.out.println("Applying operation at the beginning of a fragment..."); | |
... | |
} | |
@Override | |
public void visitChildText(Element element, ExecutionContext executionContext) { | |
System.out.println("Applying operation on a child text fragment..."); | |
... | |
} | |
@Override | |
public void visitChildElement(Element childElement, ExecutionContext executionContext) { | |
System.out.println("Applying operation on a child fragment..."); | |
... | |
} | |
@Override | |
public void visitAfter(Element element, ExecutionContext executionContext) { | |
System.out.println("Applying operation at the end of a fragment..."); | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import org.milyn.cdr.SmooksResourceConfiguration; | |
import org.milyn.cdr.annotation.AppContext; | |
import org.milyn.cdr.annotation.Config; | |
import org.milyn.cdr.annotation.ConfigParam; | |
import org.milyn.container.ApplicationContext; | |
public class MySmooks1Resource { | |
@ConfigParam(name = "MyProperty", defaultVal = "hello world") | |
private String propertyOne; | |
@ConfigParam | |
private String propertyTwo; | |
@ConfigParam(use = ConfigParam.Use.OPTIONAL) | |
private String propertyThree; | |
@AppContext | |
private ApplicationContext appContext; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import org.smooks.container.ApplicationContext; | |
import javax.inject.Inject; | |
import javax.inject.Named; | |
import java.util.Optional; | |
public class MySmooks2Resource { | |
@Inject | |
@Named("MyProperty") | |
private String propertyOne = "hello world"; | |
@Inject | |
private String propertyTwo; | |
@Inject | |
private Optional<String> propertyThree; | |
@Inject | |
private ApplicationContext appContext; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import org.smooks.container.ExecutionContext; | |
import org.smooks.delivery.memento.NodeVisitable; | |
import org.smooks.delivery.memento.TextAccumulatorMemento; | |
import org.smooks.delivery.sax.ng.ElementVisitor; | |
import org.w3c.dom.Element; | |
import java.util.function.Consumer; | |
public class MyTextAccumulatorVisitor implements ElementVisitor { | |
@Override | |
public void visitBefore(Element element, ExecutionContext executionContext) { | |
} | |
@Override | |
public void visitChildText(Element element, ExecutionContext executionContext) { | |
executionContext.getMementoCaretaker().stash(new TextAccumulatorMemento(new NodeVisitable(element), this), | |
textAccumulatorMemento -> textAccumulatorMemento.accumulateText(element.getTextContent())); | |
} | |
@Override | |
public void visitChildElement(Element childElement, ExecutionContext executionContext) { | |
} | |
@Override | |
public void visitAfter(Element element, ExecutionContext executionContext) { | |
TextAccumulatorMemento textAccumulatorMemento = new TextAccumulatorMemento(new NodeVisitable(element), this); | |
executionContext.getMementoCaretaker().restore(textAccumulatorMemento); | |
System.out.println("Accumulated character data: " + textAccumulatorMemento.getText()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<dependency> | |
<groupId>org.smooks.cartridges.edi</groupId> | |
<artifactId>d03b-edifact-binding</artifactId> | |
<version>2.0.0-M2</version> | |
</dependency> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-1.2.xsd" | |
xmlns:core="https://www.smooks.org/xsd/smooks/smooks-core-1.5.xsd"> | |
<core:namespaces> | |
<core:namespace prefix="a" uri="http://a"/> | |
<core:namespace prefix="b" uri="http://b"/> | |
<core:namespace prefix="c" uri="http://c"/> | |
<core:namespace prefix="d" uri="http://d"/> | |
</core:namespaces> | |
<resource-config selector="/a:ord[@num = 3122 and @state = 'finished']/a:items/c:item[@c:code = '8655']/d:units[text() = 1]"> | |
<resource>org.acme.MyVisitor</resource> | |
</resource-config> | |
</smooks-resource-list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.0.xsd" | |
xmlns:a="http://a" xmlns:b="http://b" xmlns:c="http://c" xmlns:d="http://d"> | |
<resource-config selector="/a:ord[@num = 3122 and @state = 'finished']/a:items/c:item[@c:code = '8655']/d:units[text() = 1]"> | |
<resource>org.acme.MyVisitor</resource> | |
</resource-config> | |
</smooks-resource-list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.0.xsd"> | |
<params> | |
<!-- 0 denotes infinite depth --> | |
<param name="max.node.depth">0</param> | |
</params> | |
... | |
</smooks-resource-list> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment