javax.xml.transform.ErrorListener Java Examples

The following examples show how to use javax.xml.transform.ErrorListener. 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: XPathParser.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
  }
}
 
Example #2
Source File: XPathParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @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 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);
  }
}
 
Example #3
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 #4
Source File: XPath.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Warn the user of an problem.
 *
 * @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 warn(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

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

  if (null != ehandler)
  {

    // TO DO: Need to get stylesheet Locator from here.
    ehandler.warning(new TransformerException(fmsg, (SAXSourceLocator)xctxt.getSAXLocator()));
  }
}
 
Example #5
Source File: SmartTransformerFactoryImpl.java    From openjdk-jdk8u-backup 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 #6
Source File: XPathParser.java    From JDKSourceCode1.8 with MIT License 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: StylesheetHandler.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * Receive notification of a XSLT processing warning.
 *
 * @param e The warning 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#warning}
 * method chooses to flag this condition as an error.
 */
public void warning(org.xml.sax.SAXParseException e)
        throws org.xml.sax.SAXException
{

  String formattedMsg = e.getMessage();
  SAXSourceLocator locator = getLocator();
  ErrorListener handler = m_stylesheetProcessor.getErrorListener();

  try
  {
    handler.warning(new TransformerException(formattedMsg, locator));
  }
  catch (TransformerException te)
  {
    throw new org.xml.sax.SAXException(te);
  }
}
 
Example #8
Source File: XPathParser.java    From openjdk-jdk9 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 #9
Source File: XPathParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @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 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);
  }
}
 
Example #10
Source File: XPath.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Warn the user of an problem.
 *
 * @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 warn(
        XPathContext xctxt, int sourceNode, String msg, Object[] args)
          throws javax.xml.transform.TransformerException
{

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

  if (null != ehandler)
  {

    // TO DO: Need to get stylesheet Locator from here.
    ehandler.warning(new TransformerException(fmsg, (SAXSourceLocator)xctxt.getSAXLocator()));
  }
}
 
Example #11
Source File: XPathParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @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 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);
  }
}
 
Example #12
Source File: XPathParser.java    From TencentKona-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 #13
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 #14
Source File: XPath.java    From hottub 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 #15
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 #16
Source File: XPathParser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Warn the user of a problem.
 *
 * @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 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);
  }
}
 
Example #17
Source File: TransformerFactoryImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 * Set the error event listener for the TransformerFactory, which is used
 * for the processing of transformation instructions, and not for the
 * transformation itself.
 *
 * @param listener The error listener to use with the TransformerFactory
 * @throws IllegalArgumentException
 */
@Override
public void setErrorListener(ErrorListener listener)
    throws IllegalArgumentException
{
    if (listener == null) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
                                    "TransformerFactory");
        throw new IllegalArgumentException(err.toString());
    }
    _errorListener = listener;
}
 
Example #18
Source File: XPathContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the ErrorListener where errors and warnings are to be reported.
 *
 * @param listener A non-null ErrorListener reference.
 */
public void setErrorListener(ErrorListener listener) throws IllegalArgumentException
{
  if (listener == null)
    throw new IllegalArgumentException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null)); //"Null error handler");
  m_errorListener = listener;
}
 
Example #19
Source File: TransformationTest.java    From xmlunit with Apache License 2.0 5 votes vote down vote up
@Test
public void passesThroughErrorListener() {
    ErrorListener e = mock(ErrorListener.class);
    t.setFactory(fac);
    t.setErrorListener(e);
    t.transformToString();

    verify(transformer).setErrorListener(e);
}
 
Example #20
Source File: XPathContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the ErrorListener where errors and warnings are to be reported.
 *
 * @param listener A non-null ErrorListener reference.
 */
public void setErrorListener(ErrorListener listener) throws IllegalArgumentException
{
  if (listener == null)
    throw new IllegalArgumentException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null)); //"Null error handler");
  m_errorListener = listener;
}
 
Example #21
Source File: ToXMLStream.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example #22
Source File: TransformerImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Implements JAXP's Transformer.setErrorListener()
 * Set the error event listener in effect for the transformation.
 * Register a message handler in the translet in order to forward
 * xsl:messages to error listener.
 *
 * @param listener The error event listener to use
 * @throws IllegalArgumentException
 */
@Override
public void setErrorListener(ErrorListener listener)
    throws IllegalArgumentException {
    if (listener == null) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
                                    "Transformer");
        throw new IllegalArgumentException(err.toString());
    }
    _errorListener = listener;

    // Register a message handler to report xsl:messages
if (_translet != null)
    _translet.setMessageHandler(new MessageHandler(_errorListener));
}
 
Example #23
Source File: ToStream.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 * @param encoding the character encoding
 */
public void setEncoding(String encoding)
{
    String old = getEncoding();
    super.setEncoding(encoding);
    if (old == null || !old.equals(encoding)) {
       // If we have changed the setting of the
       m_encodingInfo = Encodings.getEncodingInfo(encoding);

       if (encoding != null && m_encodingInfo.name == null) {
           // We tried to get an EncodingInfo for Object for the given
           // encoding, but it came back with an internall null name
           // so the encoding is not supported by the JDK, issue a message.
           String msg = Utils.messages.createMessage(
                           MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
           try
           {
                   // Prepare to issue the warning message
                   Transformer tran = super.getTransformer();
                   if (tran != null) {
                           ErrorListener errHandler = tran.getErrorListener();
                           // Issue the warning message
                           if (null != errHandler && m_sourceLocator != null)
                                   errHandler.warning(new TransformerException(msg, m_sourceLocator));
                           else
                                   System.out.println(msg);
               }
                   else
                           System.out.println(msg);
           }
           catch (Exception e){}
       }
    }
    return;
}
 
Example #24
Source File: ToXMLStream.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method checks for the XML version of output document.
 * If XML version of output document is not specified, then output
 * document is of version XML 1.0.
 * If XML version of output doucment is specified, but it is not either
 * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
 * output document is set to XML 1.0 and processing continues.
 * @return string (XML version)
 */
private String getXMLVersion()
{
    String xmlVersion = getVersion();
    if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
    {
        xmlVersion = XMLVERSION10;
    }
    else if(xmlVersion.equals(XMLVERSION11))
    {
        xmlVersion = XMLVERSION11;
    }
    else
    {
        String msg = Utils.messages.createMessage(
                           MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
        try
        {
            // Prepare to issue the warning message
            Transformer tran = super.getTransformer();
            ErrorListener errHandler = tran.getErrorListener();
            // Issue the warning message
            if (null != errHandler && m_sourceLocator != null)
                errHandler.warning(new TransformerException(msg, m_sourceLocator));
            else
                System.out.println(msg);
        }
        catch (Exception e){}
        xmlVersion = XMLVERSION10;
    }
    return xmlVersion;
}
 
Example #25
Source File: XPathContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the ErrorListener where errors and warnings are to be reported.
 *
 * @param listener A non-null ErrorListener reference.
 */
public void setErrorListener(ErrorListener listener) throws IllegalArgumentException
{
  if (listener == null)
    throw new IllegalArgumentException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NULL_ERROR_HANDLER, null)); //"Null error handler");
  m_errorListener = listener;
}
 
Example #26
Source File: XPath.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type,
        ErrorListener errorListener)
          throws javax.xml.transform.TransformerException
{
  initFunctionTable();
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #27
Source File: TransformerFactoryImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 * Set the error event listener for the TransformerFactory, which is used
 * for the processing of transformation instructions, and not for the
 * transformation itself.
 *
 * @param listener The error listener to use with the TransformerFactory
 * @throws IllegalArgumentException
 */
@Override
public void setErrorListener(ErrorListener listener)
    throws IllegalArgumentException
{
    if (listener == null) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
                                    "TransformerFactory");
        throw new IllegalArgumentException(err.toString());
    }
    _errorListener = listener;
}
 
Example #28
Source File: XPath.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator,
        PrefixResolver prefixResolver, int type,
        ErrorListener errorListener, FunctionTable aTable)
          throws javax.xml.transform.TransformerException
{
  m_funcTable = aTable;
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
          XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
          new Object[]{Integer.toString(type)}));
          //"Can not deal with XPath type: " + type);

  // System.out.println("----------------");
  Expression expr = compiler.compile(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #29
Source File: XPath.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Construct an XPath object.
 *
 * (Needs review -sc) This method initializes an XPathParser/
 * Compiler and compiles the expression.
 * @param exprString The XPath expression.
 * @param locator The location of the expression, may be null.
 * @param prefixResolver A prefix resolver to use to resolve prefixes to
 *                       namespace URIs.
 * @param type one of {@link #SELECT} or {@link #MATCH}.
 * @param errorListener The error listener, or null if default should be used.
 *
 * @throws javax.xml.transform.TransformerException if syntax or other error.
 */
public XPath(
        String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type,
        ErrorListener errorListener)
          throws javax.xml.transform.TransformerException
{
  initFunctionTable();
  if(null == errorListener)
    errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler();

  m_patternString = exprString;

  XPathParser parser = new XPathParser(errorListener, locator);
  Compiler compiler = new Compiler(errorListener, locator, m_funcTable);

  if (SELECT == type)
    parser.initXPath(compiler, exprString, prefixResolver);
  else if (MATCH == type)
    parser.initMatchPattern(compiler, exprString, prefixResolver);
  else
    throw new RuntimeException(XSLMessages.createXPATHMessage(
            XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE,
            new Object[]{Integer.toString(type)}));

  // System.out.println("----------------");
  Expression expr = compiler.compileExpression(0);

  // System.out.println("expr: "+expr);
  this.setExpression(expr);

  if((null != locator) && locator instanceof ExpressionNode)
  {
      expr.exprSetParent((ExpressionNode)locator);
  }

}
 
Example #30
Source File: TransformerFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 * Set the error event listener for the TransformerFactory, which is used
 * for the processing of transformation instructions, and not for the
 * transformation itself.
 *
 * @param listener The error listener to use with the TransformerFactory
 * @throws IllegalArgumentException
 */
@Override
public void setErrorListener(ErrorListener listener)
    throws IllegalArgumentException
{
    if (listener == null) {
        ErrorMsg err = new ErrorMsg(ErrorMsg.ERROR_LISTENER_NULL_ERR,
                                    "TransformerFactory");
        throw new IllegalArgumentException(err.toString());
    }
    _errorListener = listener;
}