Java Code Examples for javax.xml.transform.ErrorListener#fatalError()

The following examples show how to use javax.xml.transform.ErrorListener#fatalError() . 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: SmartTransformerFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public XMLFilter newXMLFilter(Templates templates)
    throws TransformerConfigurationException {
    try {
        return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
    }
    catch(TransformerConfigurationException e1) {
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory();
        }
        ErrorListener errorListener = _xsltcFactory.getErrorListener();
        if(errorListener != null) {
            try {
                errorListener.fatalError(e1);
                return null;
            }
            catch( TransformerException e2) {
                new TransformerConfigurationException(e2);
            }
        }
        throw e1;
    }
}
 
Example 2
Source File: XPath.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.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.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
 
Example 3
Source File: MsgMgr.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param msg Message text to issue
 * @param args Arguments to use in message
 * @param e Exception to throw
 * @throws XSLProcessorException thrown if the active ProblemListener and XPathContext decide
 * the error condition is severe enough to halt processing.
 *
 * @throws TransformerException
 * @xsl.usage internal
 */
public void error(SourceLocator srcLctr, String msg, Object args[], Exception e) throws TransformerException
{

  //msg  = (null == msg) ? XSLTErrorResources.ER_PROCESSOR_ERROR : msg;
  String formattedMsg = XSLMessages.createMessage(msg, args);

  // Locator locator = m_stylesheetLocatorStack.isEmpty()
  //                   ? null :
  //                    ((Locator)m_stylesheetLocatorStack.peek());
  // Locator locator = null;
  ErrorListener errHandler = m_transformer.getErrorListener();

  if (null != errHandler)
    errHandler.fatalError(new TransformerException(formattedMsg, srcLctr));
  else
    throw new TransformerException(formattedMsg, srcLctr);
}
 
Example 4
Source File: XPathParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 5
Source File: XPathParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 6
Source File: XPathParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 7
Source File: XPath.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.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.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
 
Example 8
Source File: SmartTransformerFactoryImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public XMLFilter newXMLFilter(Templates templates)
    throws TransformerConfigurationException {
    try {
        return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
    }
    catch(TransformerConfigurationException e1) {
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory();
        }
        ErrorListener errorListener = _xsltcFactory.getErrorListener();
        if(errorListener != null) {
            try {
                errorListener.fatalError(e1);
                return null;
            }
            catch( TransformerException e2) {
                new TransformerConfigurationException(e2);
            }
        }
        throw e1;
    }
}
 
Example 9
Source File: XPathParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 10
Source File: XPathParser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 11
Source File: XPath.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @param msg An error msgkey that corresponds to one of the constants found
 *            in {@link com.sun.org.apache.xpath.internal.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.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
 
Example 12
Source File: SmartTransformerFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public XMLFilter newXMLFilter(Templates templates)
    throws TransformerConfigurationException {
    try {
        return new com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter(templates);
    }
    catch(TransformerConfigurationException e1) {
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory();
        }
        ErrorListener errorListener = _xsltcFactory.getErrorListener();
        if(errorListener != null) {
            try {
                errorListener.fatalError(e1);
                return null;
            }
            catch( TransformerException e2) {
                new TransformerConfigurationException(e2);
            }
        }
        throw e1;
    }
}
 
Example 13
Source File: XPathParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
  }
}
 
Example 14
Source File: XPath.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Tell the user of an error, and probably throw an
 * exception.
 *
 * @param xctxt The XPath runtime context.
 * @param sourceNode Not used.
 * @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.
 */
public void error(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

  String fmsg = XSLMessages.createXPATHMessage(msg, args);
  ErrorListener ehandler = xctxt.getErrorListener();

  if (null != ehandler)
  {
    ehandler.fatalError(new TransformerException(fmsg,
                            (SAXSourceLocator)xctxt.getSAXLocator()));
  }
  else
  {
    SourceLocator slocator = xctxt.getSAXLocator();
    System.out.println(fmsg + "; file " + slocator.getSystemId()
                       + "; line " + slocator.getLineNumber() + "; column "
                       + slocator.getColumnNumber());
  }
}
 
Example 15
Source File: XPathParser.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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;
      }
}
 
Example 16
Source File: Expression.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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);
  }
}
 
Example 17
Source File: Expression.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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);
  }
}
 
Example 18
Source File: Expression.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * 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);
  }
}
 
Example 19
Source File: Expression.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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);
  }
}
 
Example 20
Source File: Expression.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * 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 com.sun.org.apache.xpath.internal.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);
  }
}