AddUriToCatalogTF

Add an external entity and its URI to a XmlCatalogResolver.

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

Description:

Add an external entity and its URI to an XmlCatalogResolver. URI resolving is used by XSL transformers, such as the ones used by XsltTF.

An XmlCatalogResolver containing URI:s can be a great help when parsing XML documents containing relative path references to external entities or to included documents.

The base location property can be used to prefix all added URI:s with a preset string.

Required properties

Properties

baseLocationtop

If this is set, all added URI:s will be relative to this location. This can be used to resolve entities relative to files in this catalog.

Setter method:
setBaseLocation(AbsoluteLocation l)
parameters:
l – The base location. Entities will be added relative to this location.
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
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.
source (required)top

The entity to add to the catalog. If the task is run standalone, the entity is added to the catalog with its name as the URI. If the task's SourceConfigurable.setRelativeToBase(org.entityfs.el.RelativeLocation) property is set (if the task is run by an RecursiveActionTF), the entity is saved in the catalog with a URI relative to the base location.

It is up to the XmlCatalogResolver to interpret the entity object. It is usually done with InterpretAsReadableFileStrategy (depends on the resolver's configuration).

Setter method:
setSource(Object o)
parameters:
o – An entity.
See also:
baseLocation
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?
xmlCatalog (required)top

The catalog to add the external entities to.

Setter method:
setXmlCatalog(XmlCatalog c)
parameters:
c – The XML catalog.

Examples

Example 1

Add URI-based entities to an XML catalog

// Create an XML catalog object. // The XmlCatalogResolver is an XmlCatalog, // an EntityResolver and a UriResolver rolled into one. cg = new XmlCatalogResolver(); // Add all files under the directory d to the catalog. Create locations relative // to /d1 new RecursiveActionTF(). setSource( new DirectoryAndFilter(d, EFileFilter.FILTER)). setTaskFactory( new AddUriToCatalogTF(). setBaseLocation(new AbsoluteLocation("/d1")). setXmlCatalog(cg)).run(); // Given the following directory structure: // d // + d1 // | + f1 // | + d10 // | + f10 // + d2 // + f2 // // the catalog will now contain the following URI:s: // f1 // d10/f10 // ../d2/f2 // // ...and can be used to resolve relative entities from d1


* 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.