public boolean evaluate(Node contextNode,Node xpathnode,String str,Node namespaceNode) throws TransformerException {
  if (!str.equals(xpathStr) || xpathExpression == null) {
    if (xpf == null) {
      xpf=XPathFactory.newInstance();
      try {
        xpf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,Boolean.TRUE);
      }
 catch (      XPathFactoryConfigurationException ex) {
        throw new TransformerException("empty",ex);
      }
    }
    XPath xpath=xpf.newXPath();
    xpath.setNamespaceContext(new DOMNamespaceContext(namespaceNode));
    xpathStr=str;
    try {
      xpathExpression=xpath.compile(xpathStr);
    }
 catch (    XPathExpressionException ex) {
      throw new TransformerException("empty",ex);
    }
  }
  try {
    Boolean result=(Boolean)xpathExpression.evaluate(contextNode,XPathConstants.BOOLEAN);
    return result.booleanValue();
  }
 catch (  XPathExpressionException ex) {
    throw new TransformerException("empty",ex);
  }
}

public boolean evaluate ( Node contextNode , Node xpathnode , String str , Node namespaceNode ) throws TransformerException { if ( ! str . equals ( xpathStr ) || xpathExpression == null ) { if ( xpf == null ) { xpf = XPathFactory . newInstance ( ) ; try { xpf . setFeature ( XMLConstants . FEATURE_SECURE_PROCESSING , Boolean . TRUE ) ; } catch ( XPathFactoryConfigurationException ex ) { throw new TransformerException ( "empty" , ex ) ; } } XPath xpath = xpf . newXPath ( ) ; xpath . setNamespaceContext ( new DOMNamespaceContext ( namespaceNode ) ) ; xpathStr = str ; try { xpathExpression = xpath . compile ( xpathStr ) ; } catch ( XPathExpressionException ex ) { throw new TransformerException ( "empty" , ex ) ; } } try { Boolean result = ( Boolean ) xpathExpression . evaluate ( contextNode , XPathConstants . BOOLEAN ) ; return result . booleanValue ( ) ; } catch ( XPathExpressionException ex ) { throw new TransformerException ( "empty" , ex ) ; } }
evaluate an xpath string and return true if the output is to be included or not .
