Search in sources :

Example 41 with ErrorListener

use of javax.xml.transform.ErrorListener in project robovm by robovm.

the class FuncFormatNumb method warn.

/**
   * 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()));
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) XString(org.apache.xpath.objects.XString) SAXSourceLocator(org.apache.xml.utils.SAXSourceLocator) TransformerException(javax.xml.transform.TransformerException)

Example 42 with ErrorListener

use of javax.xml.transform.ErrorListener in project robovm by robovm.

the class XPathParser method error.

/**
   * Notify the user of an error, and probably throw an
   * exception.
   *
   * @param msg An error msgkey that corresponds to one of the constants found 
   *            in {@link org.apache.xpath.res.XPATHErrorResources}, which is 
   *            a key for a format string.
   * @param args An array of arguments represented in the format string, which 
   *             may be null.
   *
   * @throws TransformerException if the current ErrorListoner determines to 
   *                              throw an exception.
   */
void error(String msg, Object[] args) throws TransformerException {
    String fmsg = XSLMessages.createXPATHMessage(msg, args);
    ErrorListener ehandler = this.getErrorListener();
    TransformerException te = new TransformerException(fmsg, m_sourceLocator);
    if (null != ehandler) {
        // TO DO: Need to get stylesheet Locator from here.
        ehandler.fatalError(te);
    } else {
        // System.err.println(fmsg);
        throw te;
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) XString(org.apache.xpath.objects.XString) TransformerException(javax.xml.transform.TransformerException)

Example 43 with ErrorListener

use of javax.xml.transform.ErrorListener in project robovm by robovm.

the class XPathParser method errorForDOM3.

/**
   * This method is added to support DOM 3 XPath API.
   * <p>
   * This method is exactly like error(String, Object[]); except that
   * the underlying TransformerException is 
   * XpathStylesheetDOM3Exception (which extends TransformerException).
   * <p>
   * So older XPath code in Xalan is not affected by this. To older XPath code
   * the behavior of whether error() or errorForDOM3() is called because it is
   * always catching TransformerException objects and is oblivious to
   * the new subclass of XPathStylesheetDOM3Exception. Older XPath code 
   * runs as before.
   * <p>
   * However, newer DOM3 XPath code upon catching a TransformerException can
   * can check if the exception is an instance of XPathStylesheetDOM3Exception
   * and take appropriate action.
   * 
   * @param msg An error msgkey that corresponds to one of the constants found 
   *            in {@link org.apache.xpath.res.XPATHErrorResources}, which is 
   *            a key for a format string.
   * @param args An array of arguments represented in the format string, which 
   *             may be null.
   *
   * @throws TransformerException if the current ErrorListoner determines to 
   *                              throw an exception.
   */
void errorForDOM3(String msg, Object[] args) throws TransformerException {
    String fmsg = XSLMessages.createXPATHMessage(msg, args);
    ErrorListener ehandler = this.getErrorListener();
    TransformerException te = new XPathStylesheetDOM3Exception(fmsg, m_sourceLocator);
    if (null != ehandler) {
        // TO DO: Need to get stylesheet Locator from here.
        ehandler.fatalError(te);
    } else {
        // System.err.println(fmsg);
        throw te;
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) XPathStylesheetDOM3Exception(org.apache.xpath.domapi.XPathStylesheetDOM3Exception) XString(org.apache.xpath.objects.XString) TransformerException(javax.xml.transform.TransformerException)

Example 44 with ErrorListener

use of javax.xml.transform.ErrorListener in project robovm by robovm.

the class XPathParser method warn.

/**
   * Warn the user of a problem.
   *
   * @param msg An error msgkey that corresponds to one of the constants found 
   *            in {@link org.apache.xpath.res.XPATHErrorResources}, which is 
   *            a key for a format string.
   * @param args An array of arguments represented in the format string, which 
   *             may be null.
   *
   * @throws TransformerException if the current ErrorListoner determines to 
   *                              throw an exception.
   */
void warn(String msg, Object[] args) throws TransformerException {
    String fmsg = XSLMessages.createXPATHWarning(msg, args);
    ErrorListener ehandler = this.getErrorListener();
    if (null != ehandler) {
        // TO DO: Need to get stylesheet Locator from here.
        ehandler.warning(new TransformerException(fmsg, m_sourceLocator));
    } else {
        // Should never happen.
        System.err.println(fmsg);
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) XString(org.apache.xpath.objects.XString) TransformerException(javax.xml.transform.TransformerException)

Example 45 with ErrorListener

use of javax.xml.transform.ErrorListener in project robovm by robovm.

the class StylesheetHandler method fatalError.

/**
   * Report a fatal XSLT processing error.
   *
   * @param e The error information encoded as an exception.
   *
   * @throws org.xml.sax.SAXException that wraps a
   * {@link javax.xml.transform.TransformerException} if the current
   * {@link javax.xml.transform.ErrorListener#fatalError}
   * method chooses to flag this condition as an error.
   */
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException {
    String formattedMsg = e.getMessage();
    SAXSourceLocator locator = getLocator();
    ErrorListener handler = m_stylesheetProcessor.getErrorListener();
    try {
        handler.fatalError(new TransformerException(formattedMsg, locator));
    } catch (TransformerException te) {
        throw new org.xml.sax.SAXException(te);
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) SAXSourceLocator(org.apache.xml.utils.SAXSourceLocator) TransformerException(javax.xml.transform.TransformerException)

Aggregations

ErrorListener (javax.xml.transform.ErrorListener)53 TransformerException (javax.xml.transform.TransformerException)49 SAXSourceLocator (org.apache.xml.utils.SAXSourceLocator)18 XString (org.apache.xpath.objects.XString)8 Transformer (javax.xml.transform.Transformer)6 SAXException (org.xml.sax.SAXException)6 IOException (java.io.IOException)4 ExpressionVisitor (org.apache.xalan.extensions.ExpressionVisitor)4 XMLString (org.apache.xml.utils.XMLString)4 XPath (org.apache.xpath.XPath)4 OutputStream (java.io.OutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Writer (java.io.Writer)2 EmptyStackException (java.util.EmptyStackException)2 SourceLocator (javax.xml.transform.SourceLocator)2 WrappedRuntimeException (org.apache.xml.serializer.utils.WrappedRuntimeException)2 XPathStylesheetDOM3Exception (org.apache.xpath.domapi.XPathStylesheetDOM3Exception)2 XObject (org.apache.xpath.objects.XObject)2