DomParseXmlTF

Parse an XML file and create a DOM document.

Task package:org.schmant.task.base
Java package:org.schmant.task.xml.dom
Category:XML tasks
Since:0.5
EntityFS-aware?Yes*
Implements:ActionTaskFactory
Produces:Document
See also:AddSystemIdToCatalogTF
AddUriToCatalogTF
XsltTF

Description:

Parse an XML file and create a DOM document. After running the task, the document can be retrieved by calling get() or getDocument() on the task.

Required properties

Properties

attributestop

A list of DOM parser attributes. The attributes are set on the DOM parser factory in the order that they are added to this property.

Setter method:
addAttribute(String name, Object value)
Add one attribute.
parameters:
name – The attribute's name.
value – The attribute's value.
Setter method:
addAttributes(Object o)
Add one or several attributes.
parameters:
o – One attribute or an array or collection of attributes (TwoObjects<String, ?> objects).
Setter method:
clearAttributes()
Clear the list of attributes.
documentBuilderFactoryClassNametop

Set the fully qualified class name of the DocumentBuilderFactory implementation to use. The task's class loader, or any of its parents, must be able to load the class.

Setter method:
setDocumentBuilderFactoryClassName(String n)
parameters:
n – The fully qualified class name of a DocumentBuilderFactory implementation.
Default value:
The current default DocumentBuilderFactory implementation. This can be affected by service provider information from Jar files in Schmant's class path and in the currently enabled task packages. A good rule of thumb is that this is never set to what you assume it is...
entityResolvertop

An EntityResolver that is used when parsing the XML document. This can for instance be a XmlCatalogResolver.

Setter method:
setEntityResolver(EntityResolver er)
parameters:
er – The entity resolver.
See also:
entityResolverDecorator
entityResolverDecoratortop

An optional EntityResolverDecorator that is used to give the DOM parser an EntityResolver.

Setter method:
setEntityResolverDecorator(EntityResolverDecorator d)
parameters:
d –  An entity resolver decorator.
See also:
entityResolver
errorHandlertop

The parser's ErrorHandler.

Setter method:
setErrorHandler(ErrorHandler h)
parameters:
h – The error handler.
Default value:
The XML parser's default error handler (parser-dependent).
featurestop

A map of features for the XML parser.

Setter method:
clearFeatures()
Clear the feature map.
Setter method:
putFeature(String name, boolean b)
Add one feature.
parameters:
name – The name of the feature, for instance XMLConstants.FEATURE_SECURE_PROCESSING.
b – Is the feature on or off?
Setter method:
putFeatures(Map<String, Boolean> m)
Add all features from a map.
parameters:
m – A map of features.
logFootertop

The message that is logged to info level after the task has been successfully run.

Setter method:
setLogFooter(String s)
parameters:
s – The footer message.
Default value:
Empty (no footer message is logged.)
See also:
logHeader
logHeadertop

The message that is logged to info level before the task is run.

Setter method:
setLogHeader(String s)
parameters:
s – The header message.
Default value:
A task class specific message.
See also:
logFooter
namespaceAwaretop

Should the parser be name space aware?

Setter method:
setNamespaceAware(boolean b)
parameters:
b – Should the parser be name space aware?
Default value:
false (the parser is not name space aware).
reportLeveltop

This property is used to change the Report level for all task created by this task factory. The report level is changed for the thread running the task when the it is run, and is restored to its previous level when the it is done.

Setter method:
setReportLevel(Level l)
Set the report level
parameters:
l – The new report level.
schematop

The DOM parser's Schema, if any.

Setter method:
setSchema(java.lang.Object o)
parameters:
o – A schema.
Interpreted by DomParseXmlTask.intepretSchema(java.lang.Object).
source (required)top

The XML document to parse.

Setter method:
setSource(Object o)
parameters:
o – The XML document.
Interpreted by InterpretAsReadableFileStrategy.
See also:
useFileInsteadOfInputStream
traceLoggingtop

If trace logging is enabled for a task, it reports its configuration before it is run.

Trace logging may also be enabled globally for all tasks by calling TraceMode.setTraceMode(boolean).

Setter method:
setTraceLogging(boolean b)
Enable or disable trace logging.
parameters:
b – Enable trace logging?
useFileInsteadOfInputStreamtop

The default is to open a InputStream on the source file and parse data read from the stream. If this property is set to true, data is parsed from a File instead. Sometimes this gives the parser more help in resolving external entities with relative paths, sometimes not.

A more robust way of resolving external entities is provided by the XmlCatalogResolver. Entities can be added to the XML catalog using the AddSystemIdToCatalogTF and AddUriToCatalogTF tasks.

If this is set to true, the source property will be interpreted by InterpretAsFileStrategy.

Setter method:
setUseFileInsteadOfInputStream(boolean b)
parameters:
b –  Should the XML be parsed from a File rather than from a InputStream?
Default value:
false (parse data from a InputStream).
See also:
source
validatingtop

Should the parser be validating?

Setter method:
setValidating(boolean b)
parameters:
b – Should the parser be validating?
Default value:
false (the parser is not validating).
XIncludeAwaretop

Should the parser be XInclude-aware?

Setter method:
setXIncludeAware(boolean b)
parameters:
b – Should the parser be XInclude-aware?
Default value:
false (the parser is not XInclude-aware).

Examples

See XsltTF for examples.


* An EntityFS-aware task is implemented using EntityFS. This means that it uses the filter settings of DirectoryView:s and also that it often can work with other file system implementations than File-based, such as the RAM file system.