| <!-- $Id: package.html,v 1.2.2.1 2004/08/18 19:59:29 rdonkin Exp $ |
| |
| Copyright 2001-2004 The Apache Software Foundation. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <html> |
| <head> |
| <title>Package Documentation for org.apache.commons.digester.substitution Package</title> |
| </head> |
| <body bgcolor="white"> |
| Provides for manipulation of xml attributes and element body text before |
| the data is processed by any Rule objects. |
| <br><br> |
| <p> |
| 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. |
| </p> |
| <p> |
| 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}". |
| </p> |
| <p>Here's an example of setting up the VariableSubstitutor:</p> |
| <pre> |
| // 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); |
| </pre> |
| </body> |
| </html> |