@Bindable(prefix="XmlDocumentSource",
inherit=CommonAttributes.class)
public class XmlDocumentSource
extends ProcessingComponentBase
implements IDocumentSource
xml| Modifier and Type | Field and Description |
|---|---|
List<Cluster> |
clusters
If
readClusters is true and clusters are present in the input
XML, they will be deserialized and exposed to components further down the processing
chain. |
List<Document> |
documents
Documents read from the XML data.
|
String |
query
After processing this field may hold the query read from the XML data, if any.
|
boolean |
readAll
If
true, all documents are read from the input XML stream, regardless
of the limit set by results. |
boolean |
readClusters
If clusters are present in the input XML they will be read and exposed to components
further down the processing chain.
|
int |
results
The maximum number of documents to read from the XML data if
readAll is
false. |
String |
title
The title (file name or query attribute, if present) for the search result fetched
from the resource.
|
IResource |
xml
The resource to load XML data from.
|
Map<String,String> |
xmlParameters
Values for custom placeholders in the XML URL.
|
IResource |
xslt
The resource to load XSLT stylesheet from.
|
Map<String,String> |
xsltParameters
Parameters to be passed to the XSLT transformer.
|
| Constructor and Description |
|---|
XmlDocumentSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
init(IControllerContext context)
Invoked after component's attributes marked with
Init and Input
annotations have been bound, but before calls to any other methods of this
component. |
void |
process()
Performs the processing required to fulfill the request.
|
afterProcessing, beforeProcessing, dispose, getContext, getSharedExecutorclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterProcessing, beforeProcessing, dispose@Input @Processing @Attribute @Required @Internal(configuration=true) @Label(value="XML resource") @Level(value=BASIC) @Group(value="XML data") public IResource xml
IResource implementations directly or use
ResourceLookup to look up
IResource instances from a variety of locations.
One special IResource implementation you can use is
URLResourceWithParams. It allows you to specify attribute placeholders in
the URL that will be replaced with actual values at runtime. The placeholder format
is ${attribute}. The following common attributes will be substituted:
query will be replaced with the current query being processed. If
the query has not been provided, this attribute will fall back to an empty string.results will be replaced with the number of results requested. If
the number of results has not been provided, this attribute will be substituted
with an empty string.
Additionally, custom placeholders can be used. Values for the custom placeholders
should be provided in the xmlParameters attribute.
@Input @Processing @Attribute @Internal(configuration=true) @Label(value="XSLT stylesheet") @Level(value=MEDIUM) @Group(value="XML transformation") public IResource xslt
Documents.
The XSLT IResource can be provided both on initialization and processing
time. The stylesheet provided on initialization will be cached for the life time of
the component, while processing-time style sheets will be compiled every time
processing is requested and will override the initialization-time stylesheet.
To pass additional parameters to the XSLT transformer, use the
xsltParameters attribute.
@Input @Processing @Attribute @Internal(configuration=true) @Label(value="XML parameters") @Level(value=ADVANCED) @Group(value="XML data") public Map<String,String> xmlParameters
xml attribute is URLResourceWithParams, this map provides
values for custom placeholders found in the XML URL. Keys of the map correspond to
placeholder names, values of the map will be used to replace the placeholders.
Please see xml for the placeholder syntax.@Input @Processing @Attribute @Internal(configuration=true) @Label(value="XSLT parameters") @Level(value=ADVANCED) @Group(value="XML transformation") public Map<String,String> xsltParameters
@Input @Output @Processing @Attribute(key="query", inherit=true) public String query
xml.@Input @Processing @Attribute(key="results", inherit=true) @IntRange(min=1) public int results
readAll is
false.@Input @Processing @Attribute @Label(value="Read clusters from input") @Level(value=BASIC) @Group(value="XML transformation") public boolean readClusters
@Input @Processing @Attribute @Label(value="Read all documents") @Level(value=BASIC) @Group(value="Search query") public boolean readAll
true, all documents are read from the input XML stream, regardless
of the limit set by results.@Output @Processing @Attribute(key="processing-result.title", inherit=true) public String title
@Processing @Output @Attribute(key="documents", inherit=true) public List<Document> documents
@Processing @Input @Output @Internal @Attribute(key="clusters", inherit=true) public List<Cluster> clusters
readClusters is true and clusters are present in the input
XML, they will be deserialized and exposed to components further down the processing
chain.public void init(IControllerContext context)
IProcessingComponentInit and Input
annotations have been bound, but before calls to any other methods of this
component. After a call to this method completes without an exception, attributes
marked with Init Output will be collected. In this method,
components should perform initializations based on the initialization-time
attributes. This method is called once in the life time of a processing
component instance.init in interface IProcessingComponentinit in class ProcessingComponentBasecontext - An instance of IControllerContext of the controller to which this
component instance will be bound.public void process()
throws ProcessingException
IProcessingComponentprocess in interface IProcessingComponentprocess in class ProcessingComponentBaseProcessingException - when processing failed. If thrown, the
IProcessingComponent.afterProcessing() method will be called and the component will
be ready to accept further requests or to be disposed of. Finally, the
exception will be rethrown from the controller method that caused the
component to perform processing.