gpt4 book ai didi

org.apache.xerces.impl.XMLErrorReporter类的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 17:47:05 28 4
gpt4 key购买 nike

本文整理了Java中org.apache.xerces.impl.XMLErrorReporter类的一些代码示例,展示了XMLErrorReporter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLErrorReporter类的具体详情如下:
包路径:org.apache.xerces.impl.XMLErrorReporter
类名称:XMLErrorReporter

XMLErrorReporter介绍

[英]This class is a common element of all parser configurations and is used to report errors that occur. This component can be queried by parser components from the component manager using the following property ID:

http://apache.org/xml/properties/internal/error-reporter

Errors are separated into domains that categorize a class of errors. In a parser configuration, the parser would register a MessageFormatter for each domain that is capable of localizing error messages and formatting them based on information about the error. Any parser component can invent new error domains and register additional message formatters to localize messages in those domains.

This component requires the following features and properties from the component manager that uses it:

  • http://apache.org/xml/properties/internal/error-handler

This component can use the following features and properties but they are not required:

  • http://apache.org/xml/features/continue-after-fatal-error
    [中]此类是所有解析器配置的公共元素,用于报告发生的错误。解析器组件可以使用以下属性ID从组件管理器中查询此组件:
http://apache.org/xml/properties/internal/error-reporter

错误被划分为对一类错误进行分类的域。在解析器配置中,解析器将为每个能够本地化错误消息并基于错误信息对其进行格式化的域注册MessageFormatter。任何解析器组件都可以创建新的错误域,并注册额外的消息格式化程序来本地化这些域中的消息。
此组件需要使用它的组件管理器提供以下功能和属性:

  • http://apache.org/xml/properties/internal/error-handler
    此组件可以使用以下功能和属性,但不是必需的:
  • http://apache.org/xml/features/continue-after-fatal-error

代码示例

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/**
 * Reports XPointer Warnings
 * 
 */
private void reportWarning(String key, Object[] arguments)
    throws XNIException {
  fXPointerErrorReporter.reportError(
      XPointerMessageFormatter.XPOINTER_DOMAIN, key, arguments,
      XMLErrorReporter.SEVERITY_WARNING);
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void setErrorReporter(XMLErrorReporter reporter) {
  fErrorReporter = reporter;
  if (fErrorReporter != null) {
    fErrorReporter.putMessageFormatter(
      XIncludeMessageFormatter.XINCLUDE_DOMAIN, fXIncludeMessageFormatter);
    // this ensures the proper location is displayed in error messages
    if (fDocLocation != null) {
      fErrorReporter.setDocumentLocator(fDocLocation);
    }
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/**
 * Set the locale to use for messages.
 *
 * @param locale The locale object to use for localization of messages.
 *
 * @exception XNIException Thrown if the parser does not support the
 *                         specified locale.
 */
public void setLocale(Locale locale) {
  fLocale = locale;
  fErrorReporter.setLocale(locale);
} // setLocale(Locale)

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Create a new ASCII reader from the InputStream. **/
private Reader createASCIIReader(InputStream stream) {
  return new ASCIIReader(stream,
      fTempString.ch.length,
      fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN), 
      fErrorReporter.getLocale());
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/**
 * Initializes error handling objects
 */
protected void initErrorReporter() {
  if (fErrorReporter == null) {
    fErrorReporter = new XMLErrorReporter();
  }
  if (fErrorHandler == null) {
    fErrorHandler = new XPointerErrorHandler();
  }
  fErrorReporter.putMessageFormatter(
      XPointerMessageFormatter.XPOINTER_DOMAIN,
      new XPointerMessageFormatter());
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

addComponent(fEntityManager);
fErrorReporter = new XMLErrorReporter();
fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
fProperties.put(ERROR_REPORTER, fErrorReporter);
addComponent(fErrorReporter);
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  XMLMessageFormatter xmft = new XMLMessageFormatter();
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
  XSMessageFormatter xmft = new XSMessageFormatter();
  fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

XMLDTDLoader(SymbolTable symbolTable,
      XMLGrammarPool grammarPool, XMLErrorReporter errorReporter, 
      XMLEntityResolver entityResolver) {
  fSymbolTable = symbolTable;
  fGrammarPool = grammarPool;
  if(errorReporter == null) {
    errorReporter = new XMLErrorReporter();
    errorReporter.setProperty(ERROR_HANDLER, new DefaultErrorHandler());
  }
  fErrorReporter = errorReporter;
  // Add XML message formatter if there isn't one.
  if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
    XMLMessageFormatter xmft = new XMLMessageFormatter();
    fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
    fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
  }
  fEntityResolver = entityResolver;
  if(fEntityResolver instanceof XMLEntityManager) {
    fEntityManager = (XMLEntityManager)fEntityResolver;
  } else {
    fEntityManager = new XMLEntityManager();
  }
  fEntityManager.setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY, errorReporter);
  fDTDScanner = createDTDScanner(fSymbolTable, fErrorReporter, fEntityManager);
  fDTDScanner.setDTDHandler(this);
  fDTDScanner.setDTDContentModelHandler(this);
  reset();
} // init(SymbolTable, XMLGrammarPool, XMLErrorReporter, XMLEntityResolver)

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
  fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
fProperties.put(ERROR_REPORTER, fErrorReporter);
addComponent(fErrorReporter);
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  XMLMessageFormatter xmft = new XMLMessageFormatter();
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Setup for validation. **/
final void setup(Location location, StAXResult result, boolean stringsInternalized) {
  fDepth = 0;
  fComponentManager.reset();
  setupStAXResultHandler(result);
  fValidationManager.setEntityState(this);
  if (fEntities != null && !fEntities.isEmpty()) {
    // should only clear this if the last document contained unparsed entities
    fEntities.clear();
  }
  fStAXLocationWrapper.setLocation(location);
  fErrorReporter.setDocumentLocator(fStAXLocationWrapper);
  fStringsInternalized = stringsInternalized;
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

Locale locale = (fErrorReporter != null) ? fErrorReporter.getLocale() : null;
String reason = fXIncludeMessageFormatter.formatMessage(locale, "XPointerStreamability", null);
reportResourceError("XMLResourceError", new Object[] { href, reason });
  fErrorReporter.setDocumentLocator(fDocLocation);
    Locale locale = (fErrorReporter != null) ? fErrorReporter.getLocale() : null;
    String reason = fXIncludeMessageFormatter.formatMessage(locale, "XPointerResolutionUnsuccessful", null);
    reportResourceError("XMLResourceError", new Object[] {href, reason});
  fErrorReporter.setDocumentLocator(fDocLocation);
  fErrorReporter.setDocumentLocator(fDocLocation);
fErrorReporter.reportError(ex.getDomain(), ex.getKey(), 
  ex.getArguments(), XMLErrorReporter.SEVERITY_FATAL_ERROR, ex);
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
  "CharConversionFailure", null, XMLErrorReporter.SEVERITY_FATAL_ERROR, e);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
        "schema_reference.4",
        new Object[] { loc }, XMLErrorReporter.SEVERITY_ERROR);
    fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
        "schema_reference.4", new Object[] { file.toString() },
        XMLErrorReporter.SEVERITY_ERROR);
MessageFormatter mf = fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN);
throw new XMLConfigurationException(
    XMLConfigurationException.NOT_SUPPORTED, 
    mf.formatMessage(fErrorReporter.getLocale(), "jaxp12-schema-source-type.1",
    new Object [] {val != null ? val.getClass().getName() : "null"}));

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

fErrorReporter = new XMLErrorReporter();
setProperty(ERROR_REPORTER, fErrorReporter);
addComponent(fErrorReporter);
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  XMLMessageFormatter xmft = new XMLMessageFormatter();
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
if (fErrorReporter.getMessageFormatter("http://www.w3.org/TR/xml-schema-1") == null) {
  MessageFormatter xmft = null;
  try {
     fErrorReporter.putMessageFormatter("http://www.w3.org/TR/xml-schema-1", xmft);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

fErrorReporter = (XMLErrorReporter)value;
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
  XMLMessageFormatter xmft = new XMLMessageFormatter();
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
  fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
fErrorReporter.setProperty(propertyId, value);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

(XMLErrorReporter) componentManager.getProperty(ERROR_REPORTER);
try {
  XMLErrorHandler currErrorHandler = fErrorReporter.getErrorHandler();
  Locale currentLocale = fErrorReporter.getLocale();
  if (currentLocale != fSchemaParser.getProperty(LOCALE)) {
    fSchemaParser.setProperty(LOCALE, currentLocale);
  fSchemaParser.setFeature(
      CONTINUE_AFTER_FATAL_ERROR,
      fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
} catch (XMLConfigurationException e) {

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Returns the registered error handler.  */
public XMLErrorHandler getErrorHandler() {
  return fErrorReporter.getErrorHandler();
} // getErrorHandler():  XMLErrorHandler

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void createAnnotationValidator() {
  fAnnotationValidator = new XML11Configuration();
  fGrammarBucketAdapter = new XSAnnotationGrammarPool(fSchemaVersion);
  fAnnotationValidator.setFeature(VALIDATION, true);
  fAnnotationValidator.setFeature(XMLSCHEMA_VALIDATION, true);
  fAnnotationValidator.setProperty(XMLGRAMMAR_POOL, fGrammarBucketAdapter);
  /** Set error handler. **/
  XMLErrorHandler errorHandler = fErrorReporter.getErrorHandler();
  fAnnotationValidator.setProperty(ERROR_HANDLER, (errorHandler != null) ? errorHandler : new DefaultErrorHandler());
  /** Set locale. **/
  Locale locale = fErrorReporter.getLocale();
  fAnnotationValidator.setProperty(LOCALE, locale);
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Calls reset on each of the components owned by this component manager. **/
public void reset() throws XNIException {
  fNamespaceContext.reset();
  fValidationManager.reset();
  fEntityManager.reset(this);
  fErrorReporter.reset(this);
  fSchemaValidator.reset(this);
  // Mark configuration as fixed.
  fConfigUpdated = false;
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Creates an error reporter. */
protected XMLErrorReporter createErrorReporter() {
  return new XMLErrorReporter();
} // createErrorReporter():XMLErrorReporter

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

MessageFormatter messageFormatter = getMessageFormatter(domain);
String message;
if (messageFormatter != null) {

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com