@EventDriven @SideEffectFree @SupportsBatching @Tags(value={"XML","evaluate","XPath"}) @InputRequirement(value=INPUT_REQUIRED) @CapabilityDescription(value="Evaluates one or more XPaths against the content of a FlowFile. The results of those XPaths are assigned to FlowFile Attributes or are written to the content of the FlowFile itself, depending on configuration of the Processor. XPaths are entered by adding user-defined properties; the name of the property maps to the Attribute Name into which the result will be placed (if the Destination is flowfile-attribute; otherwise, the property name is ignored). The value of the property must be a valid XPath expression. If the XPath evaluates to more than one node and the Return Type is set to \'nodeset\' (either directly, or via \'auto-detect\' with a Destination of \'flowfile-content\'), the FlowFile will be unmodified and will be routed to failure. If the XPath does not evaluate to a Node, the FlowFile will be routed to \'unmatched\' without having its contents modified. If Destination is flowfile-attribute and the expression matches nothing, attributes will be created with empty strings as the value, and the FlowFile will always be routed to \'matched\'") @WritesAttribute(attribute="user-defined", description="This processor adds user-defined attributes if the <Destination> property is set to flowfile-attribute.") @DynamicProperty(name="A FlowFile attribute(if <Destination> is set to \'flowfile-attribute\'", value="An XPath expression", description="If <Destination>=\'flowfile-attribute\' then the FlowFile attribute is set to the result of the XPath Expression. If <Destination>=\'flowfile-content\' then the FlowFile content is set to the result of the XPath Expression.") public class EvaluateXPath extends AbstractProcessor
Modifier and Type | Class and Description |
---|---|
private static class |
EvaluateXPath.XPathValidator |
Modifier and Type | Field and Description |
---|---|
static PropertyDescriptor |
DESTINATION |
static String |
DESTINATION_ATTRIBUTE |
static String |
DESTINATION_CONTENT |
private AtomicReference<XPathFactory> |
factoryRef |
private List<PropertyDescriptor> |
properties |
static Relationship |
REL_FAILURE |
static Relationship |
REL_MATCH |
static Relationship |
REL_NO_MATCH |
private Set<Relationship> |
relationships |
static PropertyDescriptor |
RETURN_TYPE |
static String |
RETURN_TYPE_AUTO |
static String |
RETURN_TYPE_NODESET |
static String |
RETURN_TYPE_STRING |
static PropertyDescriptor |
VALIDATE_DTD |
Constructor and Description |
---|
EvaluateXPath() |
Modifier and Type | Method and Description |
---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext context) |
private void |
doTransform(Source sourceNode,
OutputStream out) |
Set<Relationship> |
getRelationships() |
protected PropertyDescriptor |
getSupportedDynamicPropertyDescriptor(String propertyDescriptorName) |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
initializeXPathFactory() |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
onTrigger
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue
equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, onPropertyModified, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
public static final String DESTINATION_ATTRIBUTE
public static final String DESTINATION_CONTENT
public static final String RETURN_TYPE_AUTO
public static final String RETURN_TYPE_NODESET
public static final String RETURN_TYPE_STRING
public static final PropertyDescriptor DESTINATION
public static final PropertyDescriptor RETURN_TYPE
public static final PropertyDescriptor VALIDATE_DTD
public static final Relationship REL_MATCH
public static final Relationship REL_NO_MATCH
public static final Relationship REL_FAILURE
private Set<Relationship> relationships
private List<PropertyDescriptor> properties
private final AtomicReference<XPathFactory> factoryRef
protected void init(ProcessorInitializationContext context)
init
in class AbstractSessionFactoryProcessor
protected Collection<ValidationResult> customValidate(ValidationContext context)
customValidate
in class AbstractConfigurableComponent
public Set<Relationship> getRelationships()
getRelationships
in interface Processor
getRelationships
in class AbstractSessionFactoryProcessor
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class AbstractConfigurableComponent
@OnScheduled public void initializeXPathFactory() throws XPathFactoryConfigurationException
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
getSupportedDynamicPropertyDescriptor
in class AbstractConfigurableComponent
public void onTrigger(ProcessContext context, ProcessSession session)
onTrigger
in class AbstractProcessor
private void doTransform(Source sourceNode, OutputStream out) throws TransformerFactoryConfigurationError, TransformerException
Copyright © 2020 Apache NiFi Project. All rights reserved.