public abstract class AbstractXmlContentImporter extends AbstractContentImporter implements XmlContentImporter
XmlContentImporter
class which provides base XML importer configuration and logic.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractXmlContentImporter.DefaultPrefixResolver
Configurable XML prefix resolver.
|
AbstractContentImporter.ContentReference
Modifier and Type | Field and Description |
---|---|
protected DOMParser |
_domParser
A DOM parser.
|
protected PrefixResolver |
_prefixResolver
The prefix resolver.
|
protected SAXParser |
_saxParser
A SAX parser.
|
protected SourceResolver |
_srcResolver
The source resolver.
|
protected XPathProcessor |
_xPathProcessor
The XPath processor.
|
protected String |
_xsl
The configured XML transformation stylesheet.
|
protected XSLTProcessor |
_xsltProcessor
The runtime XSLT processor.
|
protected TransformerHandler |
_xslTransformerHandler
The XSL transformer handler.
|
_CONTENT_ID_MAP_KEY, _CONTENT_LINK_MAP_KEY, _CONTENT_REPEATER_SIZE_MAP, _contentTypes, _contentWorkflowHelper, _editActionId, _extensions, _initialActionId, _language, _mixins, _priority, _resolver, _workflowName, DEFAULT_PRIORITY
Constructor and Description |
---|
AbstractXmlContentImporter() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Configuration configuration) |
protected void |
configureContentCreation(Configuration configuration)
Configure the content creation parameters.
|
protected void |
configureNamespaces(Configuration configuration)
Configure the namespace to use.
|
protected void |
configureXml(Configuration configuration)
Configure XML-specific properties.
|
protected String |
getAttributeValue(Node node,
String name,
String defaultValue)
Get a node's attribute value (trimmed).
|
protected String |
getAttributeValue(Node node,
String name,
String defaultValue,
boolean trim)
Get a node's attribute value, optionally trimmed.
|
protected PrefixResolver |
getPrefixResolver()
Get the prefix resolver.
|
protected String |
getTextContent(Node node,
String defaultValue)
Get a node's text content, without trimming it.
|
protected String |
getTextContent(Node node,
String defaultValue,
boolean trim)
Get a node's text content, optionally trimmed.
|
protected abstract Set<String> |
importContents(Document document,
Map<String,Object> params)
Import the contents from the XML DOM
Document . |
Set<String> |
importContents(InputStream is,
Map<String,Object> params)
Import the contents from the file.
|
protected void |
initializeXslTransformerHandler()
Initialize the transformer from the configured XSL.
|
void |
service(ServiceManager serviceManager) |
boolean |
supports(InputStream is,
String name)
Tests if the
ContentImporter is able to import the corresponding stream.Implementing classes should first test the file extension, if possible, and if the name is provided. |
addContentReference, addContentReference, addContentReferences, configureExtensions, configureWorkflow, createContent, createContent, createContent, createContent, createContent, getContentFromProperties, getContentIdMap, getContentRefMap, getContentRepeaterSizeMap, getContentTypes, getDefaultExtensions, getEditActionId, getInitialActionId, getLanguage, getMixins, getPriority, getReferencedContentId, getWorkflowName, isExtensionValid, parseDate, parseDate, restoreContentReferences, setBinaryMetadata, setBooleanMetadata, setDateMetadata, setDoubleMetadata, setGeocodeMetadata, setGeocodeMetadata, setLongMetadata, setReferenceMetadatas, setRepeaterSize, setRichText, setStringMetadata
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
supports
getPriority
protected SourceResolver _srcResolver
protected DOMParser _domParser
protected SAXParser _saxParser
protected XPathProcessor _xPathProcessor
protected XSLTProcessor _xsltProcessor
protected PrefixResolver _prefixResolver
protected TransformerHandler _xslTransformerHandler
public AbstractXmlContentImporter()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
service
in class AbstractContentImporter
ServiceException
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configure
in class AbstractContentImporter
ConfigurationException
protected void configureXml(Configuration configuration) throws ConfigurationException
configuration
- the XML configuration.ConfigurationException
- if an error occurs.protected void configureContentCreation(Configuration configuration) throws ConfigurationException
AbstractContentImporter
configureContentCreation
in class AbstractContentImporter
configuration
- the content creation configuration.ConfigurationException
- if an error occurs.protected void configureNamespaces(Configuration configuration) throws ConfigurationException
configuration
- the namespaces configuration, can be null.ConfigurationException
- if an error occurs.protected PrefixResolver getPrefixResolver()
public boolean supports(InputStream is, String name) throws IOException
ContentImporter
ContentImporter
is able to import the corresponding stream.supports
in interface ContentImporter
is
- an input stream on the file, cannot be null. The stream is closed by the caller.name
- the file name, can be null.ContentImporter
can import the corresponding stream, false otherwise.IOException
- if an error occurs.public Set<String> importContents(InputStream is, Map<String,Object> params) throws IOException
ContentImporter
importContents
in interface ContentImporter
is
- an input stream on the file, cannot be null. The stream is closed by the caller.params
- input or output parameters.IOException
- if an error occurs importing the contents.protected abstract Set<String> importContents(Document document, Map<String,Object> params) throws IOException
Document
.document
- the XML Document.params
- the import parameters.IOException
- if an error occurs importing the contents.protected void initializeXslTransformerHandler() throws IOException, XSLTProcessorException
IOException
- if an errors occurs reading the XSL.XSLTProcessorException
- of an error occurs during the XSL transformer manipulationprotected String getTextContent(Node node, String defaultValue)
node
- the node, can be null.defaultValue
- the default value.protected String getTextContent(Node node, String defaultValue, boolean trim)
node
- the node, can be null.defaultValue
- the default value.trim
- true to trim the text content, false otherwise.protected String getAttributeValue(Node node, String name, String defaultValue)
node
- the node, can be null.name
- the attribute name.defaultValue
- the default value.protected String getAttributeValue(Node node, String name, String defaultValue, boolean trim)
node
- the node, can be null.name
- the attribute name.defaultValue
- the default value.trim
- true