类javax.xml.transform.ErrorListener源码实例Demo

下面列出了怎么用javax.xml.transform.ErrorListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: j2objc   文件: XPathParser.java
/**
 * 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);
  }
}
 
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;
    }
}
 
源代码3 项目: j2objc   文件: StylesheetHandler.java
/**
 * 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);
  }
}
 
源代码4 项目: JDKSourceCode1.8   文件: XPathParser.java
/**
 * 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;
  }
}
 
源代码5 项目: jdk1.8-source-analysis   文件: XPathParser.java
/**
 * 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);
  }
}
 
源代码6 项目: jdk1.8-source-analysis   文件: XPathParser.java
/**
 * 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;
  }
}
 
源代码7 项目: openjdk-8-source   文件: XPath.java
/**
 * 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()));
  }
}
 
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;
    }
}
 
源代码9 项目: openjdk-jdk9   文件: XPathParser.java
/**
 * 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;
  }
}
 
源代码10 项目: openjdk-8   文件: XPathParser.java
/**
 * 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);
  }
}
 
源代码11 项目: hottub   文件: XPath.java
/**
 * 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()));
  }
}
 
源代码12 项目: TencentKona-8   文件: XPathParser.java
/**
 * 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);
  }
}
 
源代码13 项目: TencentKona-8   文件: XPathParser.java
/**
 * 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;
  }
}
 
源代码14 项目: hottub   文件: XPath.java
/**
 * 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());
  }
}
 
源代码15 项目: hottub   文件: XPathParser.java
/**
 * 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;
  }
}
 
源代码16 项目: Bytecoder   文件: XPathParser.java
/**
 * 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);
  }
}
 
/**
 * 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;
}
 
源代码18 项目: openjdk-8   文件: ToXMLStream.java
/**
 * 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;
}
 
源代码19 项目: jdk1.8-source-analysis   文件: ToStream.java
/**
 * 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;
}
 
源代码20 项目: openjdk-jdk8u   文件: ToStream.java
/**
 * 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;
}
 
源代码21 项目: jdk1.8-source-analysis   文件: XPath.java
/**
 * 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);
  }

}
 
源代码22 项目: j2objc   文件: FuncDocument.java
/**
 * 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);
}
 
源代码23 项目: JDKSourceCode1.8   文件: XPath.java
/**
 * 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);
  }

}
 
源代码24 项目: JDKSourceCode1.8   文件: ToXMLStream.java
/**
 * 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;
}
 
源代码25 项目: TencentKona-8   文件: ToStream.java
/**
 * 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;
}
 
源代码26 项目: TencentKona-8   文件: ToXMLStream.java
/**
 * 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;
}
 
源代码27 项目: openjdk-8-source   文件: XPathContext.java
/**
 * 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;
}
 
源代码28 项目: hottub   文件: XPath.java
/**
 * 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);
  }

}
 
源代码29 项目: openjdk-8   文件: TransformerFactoryImpl.java
/**
 * 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;
}
 
源代码30 项目: Bytecoder   文件: XPath.java
/**
 * 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);
  }

}