alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Digester example source code file (substitution.xml)

This example Commons Digester source code file (substitution.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Digester tags/keywords

apache, asf, asf, digester, digester, documentation, license, license, multivariableexpander, package, see, the, the, you

The Commons Digester substitution.xml source code

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<document xmlns="http://maven.apache.org/XDOC/2.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
  <properties>
    <title>Download Commons Digester
    <author email="dev@commons.apache.org">Commons Documentation Team
  </properties>
  <body>
    <section name="Package Documentation for org.apache.commons.digester.substitution Package">
      <p>Provides for manipulation of xml attributes and element body text before
the data is processed by any Rule objects.</p>

<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:

<source> // 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); </source> </section> </body> </document>

Other Commons Digester examples (source code examples)

Here is a short list of links related to this Commons Digester substitution.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.