Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.apache.commons.digester.substitution

Provides for manipulation of xml attributes and element body text before the data is processed by any Rule objects.

See:
Description

Interface Summary
VariableExpander | An Interface describing a class capable of expanding strings which may contain variable references.

Class Summary
MultiVariableExpander | Expands variable references from multiple sources.
VariableAttributes | Wrapper for an org.xml.sax.Attributes object which expands any "variables" referenced in the attribute value via ${foo} or similar.
VariableSubstitutor | Substitutor implementation that support variable replacement for both attributes and body text.

## Package org.apache.commons.digester.substitution Description

Provides for manipulation of xml attributes and element body text before the data is processed by any Rule objects.

The class org.apache.commons.digester.Substitutor defines an abstract interface for mechanisms which manipulate xml attributes and body text. The Digester method setSubstitutor can be used to define a concrete substitutor that will be applied to the data before it is passed to the matching rules.

This package provides some useful concrete implementations of the abstract Substitutor class. In particular, it provides an implementation that allows the application to define "variables" which the input data can reference using a syntax such as "${user.name}".

Here's an example of setting up the VariableSubstitutor:

      // set up the variables the input xml can reference
      Map vars = new HashMap();
      vars.put("user.name", "me");
      vars.put("os", "Linux");

      // map ${varname} to the entries in the var map
      MultiVariableExpander expander = new MultiVariableExpander();
      expander.addSource("$", vars);

      // allow expansion in both xml attributes and element text
      Substitutor substitutor = new VariableSubstitutor(expander);

      Digester digester = new Digester();
      digester.setSubstitutor(substitutor);

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.