use of org.mycore.common.MCRTextResolver in project mycore by MyCoRe-Org.
the class MCRDynamicURIResolver method resolveVariablesFromElement.
/**
* This method runs through the whole content of the startElement and
* tries to resolve all variables in texts and attributes.
*
* @param startElement where to start to resolve the variables
* @param variablesMap a map of all variables
*/
protected void resolveVariablesFromElement(Element startElement, Hashtable<String, String> variablesMap) {
Iterator<Element> it = startElement.getDescendants(Filters.element());
MCRTextResolver varResolver = new MCRTextResolver(variablesMap);
while (it.hasNext()) {
Element element = it.next();
// text
String text = element.getText();
if (text != null && !text.equals("") && text.contains("{")) {
element.setText(varResolver.resolve(text));
}
// attributes
for (Attribute attrib : element.getAttributes()) {
String attribValue = attrib.getValue();
if (attribValue.contains("{")) {
attrib.setValue(varResolver.resolve(attribValue));
}
}
}
}
Aggregations