org.inria.ns.reflex.xml.filter
Class XIncludeFilter

java.lang.Object
  extended by org.inria.ns.reflex.xml.filter.XIncludeFilter
All Implemented Interfaces:
Localizable, Filter, RuleBasedFilter, NamespaceAware

public class XIncludeFilter
extends Object
implements RuleBasedFilter, Localizable, NamespaceAware

A built-in filter that replaces some content tagged with XInclude.

The location of this filter might be the active sheet that ask for XInclude resolution. When a document specifies relative URIs, they are resolved upon its base URI if the document location is absolute. If it is relative, the base URI of the host active sheet will be used in very last resort.

To get an XInclude filter, simply use :

  <xcl:parse-filter name="xinclude" source="res:org.inria.ns.reflex.xml.filter.XIncludeFilter"/>

Author:
Philippe Poulard
See Also:
XIncludeRules

Constructor Summary
XIncludeFilter()
          Create a new XIncludeFilter.
XIncludeFilter(NamespaceContextFactory namespaceContextFactory)
          Create a new XIncludeFilter without location.
XIncludeFilter(NamespaceContextFactory namespaceContextFactory, Localizable localizable)
          Create a new XIncludeFilter.
XIncludeFilter(NamespaceContextFactory namespaceContextFactory, XFile location)
          Create a new XIncludeFilter.
 
Method Summary
 FilterContextFactory getFilterContextFactory()
          Get the filter context factory for XInclude.
 XFile getLocation()
          Get the location of this filter.
 List getRules()
          Return the XInclude rules.
 boolean isLocalizable()
          Indicates wether this filter is localizable or not.
 boolean normalize()
          An XInclude filter doesn't normalize adjacent text nodes.
 void setLocation(XFile location)
          Set the location of this filter.
 void setNamespaceContextFactory(NamespaceContextFactory namespaceContextFactory)
          Set the component that can supply a namespace context for resolving prefixes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XIncludeFilter

public XIncludeFilter()
Create a new XIncludeFilter.

See Also:
setNamespaceContextFactory(NamespaceContextFactory), getFilterContextFactory(), FilterBuilder

XIncludeFilter

public XIncludeFilter(NamespaceContextFactory namespaceContextFactory,
                      Localizable localizable)
Create a new XIncludeFilter.

Parameters:
namespaceContextFactory - The non-null component that can create the namespace context. It is expected to create the filter context factory.
localizable - The non-null component that could retrieve the location of this filter.
See Also:
getFilterContextFactory()

XIncludeFilter

public XIncludeFilter(NamespaceContextFactory namespaceContextFactory,
                      XFile location)
Create a new XIncludeFilter.

Parameters:
namespaceContextFactory - The non-null component that can create the namespace context. It is expected to create the filter context factory.
location - The non-null location of this filter.
See Also:
getFilterContextFactory()

XIncludeFilter

public XIncludeFilter(NamespaceContextFactory namespaceContextFactory)
Create a new XIncludeFilter without location.

Parameters:
namespaceContextFactory - The non-null component that can create the namespace context. It is expected to create the filter context factory.
See Also:
getFilterContextFactory()
Method Detail

getRules

public List getRules()
Return the XInclude rules.

Specified by:
getRules in interface RuleBasedFilter
Returns:
The rules that match the XIncludes elements.
See Also:
org.inria.ns.reflex.processor.xcl.AbstractFilterAction#getRules(), XIncludeRules.XINCLUDE_RULES

getFilterContextFactory

public FilterContextFactory getFilterContextFactory()
Get the filter context factory for XInclude.

Specified by:
getFilterContextFactory in interface RuleBasedFilter
Returns:
A specific implementation that can create a custom filter context.

getLocation

public XFile getLocation()
                  throws UnlocalizableException
Get the location of this filter.

Specified by:
getLocation in interface Localizable
Returns:
The location of this filter.
Throws:
UnlocalizableException - If this instance is unable to localize this component.
See Also:
Localizable.getLocation()

setLocation

public void setLocation(XFile location)
                 throws UnlocalizableException
Set the location of this filter.

Specified by:
setLocation in interface Localizable
Parameters:
location - The location of this filter.
Throws:
UnlocalizableException - If a base URI is irrelevant for this instance.
See Also:
Localizable.setLocation(org.inria.ns.reflex.modules.io.XFile)

isLocalizable

public boolean isLocalizable()
Indicates wether this filter is localizable or not.

Specified by:
isLocalizable in interface Localizable
Returns:
true if this filter is localizable, false otherwise.
See Also:
Localizable.isLocalizable()

normalize

public boolean normalize()
An XInclude filter doesn't normalize adjacent text nodes.

Specified by:
normalize in interface RuleBasedFilter
Returns:
false
See Also:
RuleBasedFilter.normalize()

setNamespaceContextFactory

public void setNamespaceContextFactory(NamespaceContextFactory namespaceContextFactory)
Set the component that can supply a namespace context for resolving prefixes.

An XInclude filter should be invoked after having setting one to it.

Specified by:
setNamespaceContextFactory in interface NamespaceAware
Parameters:
namespaceContextFactory - The namespace context factory, which is the more often ParseFilterAction.
See Also:
NamespaceAware.setNamespaceContextFactory(NamespaceContextFactory)