public class TrueCheck implements LayoutEngineCheck {
private String xpath;
+ private String failureMessage;
/**
* Creates a new instance
*/
public TrueCheck(Node node) {
this.xpath = node.getAttributes().getNamedItem("xpath").getNodeValue();
+ Node nd = node.getAttributes().getNamedItem("fail-msg");
+ if (nd != null) {
+ this.failureMessage = nd.getNodeValue();
+ }
}
/** @see org.apache.fop.layoutengine.LayoutEngineCheck */
throw new RuntimeException("XPath evaluation failed: " + e.getMessage());
}
if (!XBoolean.S_TRUE.equals(res)) {
- throw new RuntimeException(
- "Expected XPath expression to evaluate to 'true', but got '"
- + res + "' (" + this + ")");
+ if (failureMessage != null) {
+ throw new RuntimeException(failureMessage);
+ } else {
+ throw new RuntimeException(
+ "Expected XPath expression to evaluate to 'true', but got '"
+ + res + "' (" + this + ")");
+ }
}
}