Java Code Examples for org.apache.xpath.XPathContext#getErrorListener()

The following examples show how to use org.apache.xpath.XPathContext#getErrorListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FuncDocument.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime state.
 * @param msg The error message key
 * @param args Arguments to be used in the error message
 * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
 * the error condition is severe enough to halt processing.
 *
 * @throws javax.xml.transform.TransformerException
 */
public void error(XPathContext xctxt, String msg, Object args[])
        throws javax.xml.transform.TransformerException
{

  String formattedMsg = XSLMessages.createMessage(msg, args);
  ErrorListener errHandler = xctxt.getErrorListener();
  TransformerException spe = new TransformerException(formattedMsg,
                            (SourceLocator)xctxt.getSAXLocator());

  if (null != errHandler)
    errHandler.error(spe);
  else
    System.out.println(formattedMsg);
}
 
Example 2
Source File: FuncDocument.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @param xctxt The XPath runtime state.
 * @param msg Warning message key
 * @param args Arguments to be used in the warning message
 * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
 * the error condition is severe enough to halt processing.
 *
 * @throws javax.xml.transform.TransformerException
 */
public void warn(XPathContext xctxt, String msg, Object args[])
        throws javax.xml.transform.TransformerException
{

  String formattedMsg = XSLMessages.createWarning(msg, args);
  ErrorListener errHandler = xctxt.getErrorListener();
  TransformerException spe = new TransformerException(formattedMsg,
                            (SourceLocator)xctxt.getSAXLocator());

  if (null != errHandler)
    errHandler.warning(spe);
  else
    System.out.println(formattedMsg);
}
 
Example 3
Source File: FuncFormatNumb.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @param xctxt The XPath runtime state.
 * @param msg Warning message key
 * @param args Arguments to be used in warning message
 * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
 * the error condition is severe enough to halt processing.
 *
 * @throws javax.xml.transform.TransformerException
 */
public void warn(XPathContext xctxt, String msg, Object args[])
        throws javax.xml.transform.TransformerException
{

  String formattedMsg = XSLMessages.createWarning(msg, args);
  ErrorListener errHandler = xctxt.getErrorListener();

  errHandler.warning(new TransformerException(formattedMsg,
                                           (SAXSourceLocator)xctxt.getSAXLocator()));
}
 
Example 4
Source File: AVTPartXPath.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Construct a simple AVT part.
 * 
 * @param val A pure string section of an AVT.
 * @param nsNode An object which can be used to determine the
 * Namespace Name (URI) for any Namespace prefix used in the XPath. 
 * Usually this is based on the context where the XPath was specified,
 * such as a node within a Stylesheet.
 * @param xpathProcessor XPath parser
 * @param factory XPath factory
 * @param liaison An XPathContext object, providing infomation specific
 * to this invocation and this thread. Maintains SAX output state, 
 * variables, error handler and so on, so the transformation/XPath 
 * object itself can be simultaneously invoked from multiple threads.
 *
 * @throws javax.xml.transform.TransformerException
 * TODO: Fix or remove this unused c'tor.
 */
public AVTPartXPath(
        String val, org.apache.xml.utils.PrefixResolver nsNode, 
        XPathParser xpathProcessor, XPathFactory factory, 
        XPathContext liaison)
          throws javax.xml.transform.TransformerException
{
  m_xpath = new XPath(val, null, nsNode, XPath.SELECT, liaison.getErrorListener());
}