public class DomVariableExpander extends IdentityForwardingSaxHandler
Usage:
Map<String, String> variables = ... Element elementWithVariables = ... Document elementExpanded = DomVariableExpander.expand( elementWithVariables, variables);
Variables may be written in attribute values and in text contents, and may be written in the XML as $xyz or ${xyz}. Variables in the Map passed to the expand method should not have the dollar prefix. Variable names may contain a-z, A-Z, 0-9, hypen and underscore and are case sensitive.
This class is namespace aware.
Modifier and Type | Class and Description |
---|---|
static class |
DomVariableExpander.VariableNotFoundException |
Constructor and Description |
---|
DomVariableExpander(TransformerHandler outputHandler,
Map<String,String> variables) |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length) |
static Document |
expand(Node prototypeElement,
Map<String,String> variables) |
void |
startElement(String uri,
String localName,
String el,
Attributes templateAttributes) |
endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
public DomVariableExpander(TransformerHandler outputHandler, Map<String,String> variables)
public void startElement(String uri, String localName, String el, Attributes templateAttributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class IdentityForwardingSaxHandler
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class IdentityForwardingSaxHandler
SAXException