org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(139)

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

XMLSchemaLoader.loadGrammar介绍

[英]Returns a Grammar object by parsing the contents of the entity pointed to by source.
[中]通过解析源指向的实体的内容返回语法对象。

代码示例

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

/**
 * Returns a Grammar object by parsing the contents of the
 * entities pointed to by sources.
 * 
 * @param source the locations of the entity which forms 
 *                      the staring point of the grammars to be constructed
 * @throws IOException  when a problem is encounted reading the entity
 * @throws XNIException when a condition arises (such as a FatalError) that requires parsing
 *                          of the entity be terminated
 */
public void loadGrammar(XMLInputSource source[]) 
throws IOException, XNIException {
  int numSource = source.length;
  for (int i = 0; i < numSource; ++i) {
    loadGrammar(source[i]);
  }   
}

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

public XSModel load(LSInput is) {
  try {
    Grammar g = loadGrammar(dom2xmlInputSource(is));
    return ((XSGrammar) g).toXSModel();
  } catch (Exception e) {
    reportDOMFatalError(e);
    return null;
  }
}

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

public XSModel loadURI(String uri) {
  try {
    Grammar g = loadGrammar(new XMLInputSource(null, uri, null));
    return ((XSGrammar)g).toXSModel();
  }
  catch (Exception e){
    reportDOMFatalError(e);
    return null;
  }
}

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

/**
 *  Parse an XML Schema document from a resource identified by a 
 * <code>LSInput</code> . 
 * @param is  The <code>LSInput</code> from which the source 
 *   document is to be read. 
 * @return An XSModel representing this schema.
 */
public XSModel load(LSInput is) {
  try {
    fGrammarPool.clear();
    return ((XSGrammar) fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is))).toXSModel();
  } 
  catch (Exception e) {
    fSchemaLoader.reportDOMFatalError(e);
    return null;
  }
}

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

/**
 * Parse an XML Schema document from a location identified by a URI 
 * reference. If the URI contains a fragment identifier, the behavior is 
 * not defined by this specification. 
 * @param uri The location of the XML Schema document to be read.
 * @return An XSModel representing this schema.
 */
public XSModel loadURI(String uri) {
  try {
    fGrammarPool.clear();
    return ((XSGrammar) fSchemaLoader.loadGrammar(new XMLInputSource(null, uri, null))).toXSModel();
  }
  catch (Exception e){
    fSchemaLoader.reportDOMFatalError(e);
    return null;
  }
}

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

public XSModel loadInputList(LSInputList is) {
  int length = is.getLength();
  SchemaGrammar[] gs = new SchemaGrammar[length];
  for (int i = 0; i < length; i++) {
    try {
      gs[i] = (SchemaGrammar) loadGrammar(dom2xmlInputSource(is.item(i)));
    } catch (Exception e) {
      reportDOMFatalError(e);
      return null;
    }
  }
  return new XSModelImpl(gs);
}

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

public XSModel loadURIList(StringList uriList) {
  int length = uriList.getLength();
  SchemaGrammar[] gs = new SchemaGrammar[length];
  for (int i = 0; i < length; i++) {
    try {
      gs[i] =
        (SchemaGrammar) loadGrammar(new XMLInputSource(null, uriList.item(i), null));
    } catch (Exception e) {
      reportDOMFatalError(e);
      return null;
    }
  }
  return new XSModelImpl(gs);
}

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

inputSource.setByteStream(in);
SchemaGrammar grammar = (SchemaGrammar)loader.loadGrammar(inputSource);
if (grammar == null)
  throw NativeMessages.MESSAGES.cannotLoadGrammar(url);

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

/**
 *  Parses the content of XML Schema documents specified as a list of 
 * <code>LSInput</code>s. 
 * @param is  The list of <code>LSInput</code>s from which the XML 
 *   Schema documents are to be read. 
 * @return An XSModel representing the schema documents.
 */
public XSModel loadInputList(LSInputList is) {
  final int length = is.getLength();
  try {
    fGrammarPool.clear();
    for (int i = 0; i < length; ++i) {
      fSchemaLoader.loadGrammar(fSchemaLoader.dom2xmlInputSource(is.item(i)));
    }
    return fGrammarPool.toXSModel();
  } 
  catch (Exception e) {
    fSchemaLoader.reportDOMFatalError(e);
    return null;
  }
}

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

/**
 * Parses the content of XML Schema documents specified as the list of URI 
 * references. If the URI contains a fragment identifier, the behavior 
 * is not defined by this specification. 
 * @param uriList The list of URI locations.
 * @return An XSModel representing the schema documents.
 */
public XSModel loadURIList(StringList uriList) {
  int length = uriList.getLength();
  try {
    fGrammarPool.clear();
    for (int i = 0; i < length; ++i) {
      fSchemaLoader.loadGrammar(new XMLInputSource(null, uriList.item(i), null));
    }
    return fGrammarPool.toXSModel();
  } 
  catch (Exception e) {
    fSchemaLoader.reportDOMFatalError(e);
    return null;
  }
}

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

fXMLSchemaLoader.loadGrammar(xmlInputSources);

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

SchemaGrammar parseXMLSchema(XMLInputSource is) 
      throws IOException {
  XMLEntityResolver resolver = getEntityResolver();
  if(resolver != null) {
    fSchemaLoader.setEntityResolver(resolver);
  }
  if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
    fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
  } 
  fSchemaLoader.setProperty(ERROR_REPORTER, fErrorReporter);
  String propPrefix = Constants.XERCES_PROPERTY_PREFIX;
  String propName = propPrefix + Constants.SCHEMA_LOCATION;
  fSchemaLoader.setProperty(propName, getProperty(propName));
  propName = propPrefix + Constants.SCHEMA_NONS_LOCATION;
  fSchemaLoader.setProperty(propName, getProperty(propName));
  propName = Constants.JAXP_PROPERTY_PREFIX+Constants.SCHEMA_SOURCE;
  fSchemaLoader.setProperty(propName, getProperty(propName));
  fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, getFeature(SCHEMA_FULL_CHECKING));
  // Should check whether the grammar with this namespace is already in
  // the grammar resolver. But since we don't know the target namespace
  // of the document here, we leave such check to XSDHandler
  SchemaGrammar grammar = (SchemaGrammar)fSchemaLoader.loadGrammar(is);
  // by default, hand it off to the grammar pool
  if (grammar != null) {
    fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA,
                 new Grammar[]{grammar});
  }
  
  return grammar;
} // parseXMLSchema(XMLInputSource) :  SchemaGrammar

相关文章