* From the SLD 1.0 spec: "ParameterValueType" uses WFS-Filter expressions
* to give values for SLD graphic parameters. A "mixed" element-content
* model is used with textual substitution for values.
*/
Expression parseParameterValueExpression(Node root, boolean mixedText) {
ExpressionDOMParser parser = new ExpressionDOMParser(
(FilterFactory2) ff);
Expression expr = parser.expression(root); // try the provided node
// first
if (expr != null)
return expr;
NodeList children = root.getChildNodes();
// if there is only one CharacterData node - we can make a literal out
// of it
if (children.getLength() == 1
&& root.getFirstChild() instanceof CharacterData) {
Node textNode = root.getFirstChild();
String text = textNode.getNodeValue();
return ff.literal(text.trim());
}
List<Expression> expressionList = new ArrayList<Expression>();
for (int index = 0; index < children.getLength(); index++) {
Node child = children.item(index);
if (child instanceof CharacterData) {
if (mixedText) {
String text = child.getNodeValue();
Expression childExpr = ff.literal(text);
expressionList.add(childExpr);
}
} else {
Expression childExpr = parser.expression(child);
if (childExpr != null) {
expressionList.add(childExpr);
}
}
}