Search in sources :

Example 11 with ErrorListener

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

the class Expression method error.

/**
   * Tell the user of an error, and probably throw an
   * exception.
   *
   * @param xctxt The XPath runtime context.
   * @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.
   *
   * @throws javax.xml.transform.TransformerException
   */
public void error(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
    java.lang.String fmsg = XSLMessages.createXPATHMessage(msg, args);
    if (null != xctxt) {
        ErrorListener eh = xctxt.getErrorListener();
        TransformerException te = new TransformerException(fmsg, this);
        eh.fatalError(te);
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) TransformerException(javax.xml.transform.TransformerException)

Example 12 with ErrorListener

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

the class Expression method warn.

/**
   * Warn the user of an problem.
   *
   * @param xctxt The XPath runtime context.
   * @param msg An error msgkey that corresponds to one of the conststants 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.
   *
   * @throws javax.xml.transform.TransformerException
   */
public void warn(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
    java.lang.String fmsg = XSLMessages.createXPATHWarning(msg, args);
    if (null != xctxt) {
        ErrorListener eh = xctxt.getErrorListener();
        // TO DO: Need to get stylesheet Locator from here.
        eh.warning(new TransformerException(fmsg, xctxt.getSAXLocator()));
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) TransformerException(javax.xml.transform.TransformerException)

Example 13 with ErrorListener

use of javax.xml.transform.ErrorListener in project j2objc by google.

the class Expression method error.

/**
   * Tell the user of an error, and probably throw an
   * exception.
   *
   * @param xctxt The XPath runtime context.
   * @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.
   *
   * @throws javax.xml.transform.TransformerException
   */
public void error(XPathContext xctxt, String msg, Object[] args) throws javax.xml.transform.TransformerException {
    java.lang.String fmsg = XSLMessages.createXPATHMessage(msg, args);
    if (null != xctxt) {
        ErrorListener eh = xctxt.getErrorListener();
        TransformerException te = new TransformerException(fmsg, this);
        eh.fatalError(te);
    }
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) TransformerException(javax.xml.transform.TransformerException)

Example 14 with ErrorListener

use of javax.xml.transform.ErrorListener in project j2objc by google.

the class XPath method bool.

/**
   * Given an expression and a context, evaluate the XPath
   * and return the result.
   * 
   * @param xctxt The execution context.
   * @param contextNode The node that "." expresses.
   * @param namespaceContext The context in which namespaces in the
   * XPath are supposed to be expanded.
   * 
   * @throws TransformerException thrown if the active ProblemListener decides
   * the error condition is severe enough to halt processing.
   *
   * @throws javax.xml.transform.TransformerException
   * @xsl.usage experimental
   */
public boolean bool(XPathContext xctxt, int contextNode, PrefixResolver namespaceContext) throws javax.xml.transform.TransformerException {
    xctxt.pushNamespaceContext(namespaceContext);
    xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
    try {
        return m_mainExp.bool(xctxt);
    } catch (TransformerException te) {
        te.setLocator(this.getLocator());
        ErrorListener el = xctxt.getErrorListener();
        if (// defensive, should never happen.
        null != el) {
            el.error(te);
        } else
            throw te;
    } catch (Exception e) {
        while (e instanceof org.apache.xml.utils.WrappedRuntimeException) {
            e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
        }
        // e.printStackTrace();
        String msg = e.getMessage();
        if (msg == null || msg.length() == 0) {
            msg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XPATH_ERROR, null);
        }
        TransformerException te = new TransformerException(msg, getLocator(), e);
        ErrorListener el = xctxt.getErrorListener();
        // te.printStackTrace();
        if (// defensive, should never happen.
        null != el) {
            el.fatalError(te);
        } else
            throw te;
    } finally {
        xctxt.popNamespaceContext();
        xctxt.popCurrentNodeAndExpression();
    }
    return false;
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) TransformerException(javax.xml.transform.TransformerException) TransformerException(javax.xml.transform.TransformerException)

Example 15 with ErrorListener

use of javax.xml.transform.ErrorListener in project j2objc by google.

the class XPath method execute.

/**
   * Given an expression and a context, evaluate the XPath
   * and return the result.
   * 
   * @param xctxt The execution context.
   * @param contextNode The node that "." expresses.
   * @param namespaceContext The context in which namespaces in the
   * XPath are supposed to be expanded.
   * 
   * @throws TransformerException thrown if the active ProblemListener decides
   * the error condition is severe enough to halt processing.
   *
   * @throws javax.xml.transform.TransformerException
   * @xsl.usage experimental
   */
public XObject execute(XPathContext xctxt, int contextNode, PrefixResolver namespaceContext) throws javax.xml.transform.TransformerException {
    xctxt.pushNamespaceContext(namespaceContext);
    xctxt.pushCurrentNodeAndExpression(contextNode, contextNode);
    XObject xobj = null;
    try {
        xobj = m_mainExp.execute(xctxt);
    } catch (TransformerException te) {
        te.setLocator(this.getLocator());
        ErrorListener el = xctxt.getErrorListener();
        if (// defensive, should never happen.
        null != el) {
            el.error(te);
        } else
            throw te;
    } catch (Exception e) {
        while (e instanceof org.apache.xml.utils.WrappedRuntimeException) {
            e = ((org.apache.xml.utils.WrappedRuntimeException) e).getException();
        }
        // e.printStackTrace();
        String msg = e.getMessage();
        if (msg == null || msg.length() == 0) {
            msg = XSLMessages.createXPATHMessage(XPATHErrorResources.ER_XPATH_ERROR, null);
        }
        TransformerException te = new TransformerException(msg, getLocator(), e);
        ErrorListener el = xctxt.getErrorListener();
        // te.printStackTrace();
        if (// defensive, should never happen.
        null != el) {
            el.fatalError(te);
        } else
            throw te;
    } finally {
        xctxt.popNamespaceContext();
        xctxt.popCurrentNodeAndExpression();
    }
    return xobj;
}
Also used : ErrorListener(javax.xml.transform.ErrorListener) XObject(org.apache.xpath.objects.XObject) TransformerException(javax.xml.transform.TransformerException) 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