gpt4 book ai didi

org.apache.xerces.util.XMLGrammarPoolImpl类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 17:53:05 29 4
gpt4 key购买 nike

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

XMLGrammarPoolImpl介绍

[英]Stores grammars in a pool associated to a specific key. This grammar pool implementation stores two types of grammars: those keyed by the root element name, and those keyed by the grammar's target namespace. This is the default implementation of the GrammarPool interface. As we move forward, this will become more function-rich and robust.
[中]将语法存储在与特定键关联的池中。这个语法池实现存储两种类型的语法:由根元素名设置键的语法和由语法的目标命名空间设置键的语法。这是GrammarPool接口的默认实现。随着我们的前进,这将变得更加功能丰富和强大。

代码示例

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

/** Default constructor. */
public CachingParserPool() {
  this(new SymbolTable(), new XMLGrammarPoolImpl());
} // <init>()

代码示例来源:origin: stackoverflow.com

XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl();
pool.putGrammar(grammar);

XMLSchema11Factory factory = new XMLSchema11Factory();
Schema schema = factory.newSchema(pool);

Validator validator = schema.newValidator();

DOMSource source = new DOMSource(document);
validator.validate(source);

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

/**
 * Returns the grammar associated to the specified description.
 * 
 * @param desc The description of the grammar.
 */
public Grammar getGrammar(XMLGrammarDescription desc) {
  if (super.containsGrammar(desc)) {
    return super.getGrammar(desc);
  }
  return null;
} // getGrammar(XMLGrammarDescription):Grammar

代码示例来源:origin: org.wso2.wsdl.validator/wsdl-validator

grammarPreparser.setGrammarPool(grammarPool != null ? grammarPool : new XMLGrammarPoolImpl()); 
grammarPreparser.setErrorHandler(errorHandler);
if (entityResolver != null)
  Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
  int numGrammars = grammars.length;
  for(int i = 0; i < numGrammars; i++)
   if(targetNamespace.equals(desc.getNamespace()))
    oldGrammars.add(pool.removeGrammar(desc));
     if(namespaces.contains(targetNamespace))
      oldGrammars.add(pool.removeGrammar(desc));
   Grammar oldGrammar = pool.removeGrammar(desc);
   if(oldGrammar != null)
    oldGrammars.add(oldGrammar);
  pool.removeGrammar(description);
   pool.removeGrammar(desc);
     pool.putGrammar(oldGrammar);

代码示例来源:origin: dita-ot/dita-ot

/**
 * @see org.apache.xerces.util.XMLGrammarPoolImpl#putGrammar(org.apache.xerces.xni.grammars.Grammar)
 */
@Override
public void putGrammar(Grammar grammar) {
 //Avoid caching any type of XSD grammar
 if (grammar instanceof org.apache.xerces.impl.xs.SchemaGrammar) {
 return;
 }
 super.putGrammar(grammar);
}

代码示例来源:origin: org.wso2.wsdl.validator/wsdl-validator

public void putGrammar(Grammar grammar) 
 {
  if (grammar == null)
   return;
  // we overide this method to perform 'selective' caching of schemas
  XMLGrammarDescription description = grammar.getGrammarDescription();
  if (!fPoolIsLocked && !containsGrammar(grammar.getGrammarDescription())) 
  {
   // in order to avoid caching the inline schemas
   // we ensure the literal system id does not end with wsdl
   // before we attempt to 'put' the grammar
   String litSysId = description.getLiteralSystemId();
   String basSysId = description.getBaseSystemId();
   if (litSysId != null && litSysId.endsWith("xsd")
      && basSysId != null && basSysId.endsWith("wsdl")) 
   {
        /*
         * System.out.println("putGramamr : " +
         * schemaDescription.getNamespace() + ", " +
         * schemaDescription.getExpandedSystemId() + ", " +
         * schemaDescription.getBaseSystemId());
         */
    super.putGrammar(grammar);
   }
  }
 }
}

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

/**
 * Retrieve the initial set of grammars for the validator to work with.
 * REVISIT:  does this need to be synchronized since it's just reading?
 * 
 * @param grammarType Type of the grammars to be retrieved.
 * @return            The initial grammar set the validator may place in its "bucket"
 */
public Grammar [] retrieveInitialGrammarSet(String grammarType ) {
  Grammar [] grammars = super.retrieveInitialGrammarSet(grammarType);
  if (grammars != null) return grammars;
  return fGrammarPool.retrieveInitialGrammarSet(grammarType);
} // retrieveInitialGrammarSet(String):  Grammar[]

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

/**
 * Returns true if the grammar pool contains a grammar associated
 * to the specified description.
 *
 * @param desc The description of the grammar.
 */
public boolean containsGrammar(XMLGrammarDescription desc) {
  return super.containsGrammar(desc);
} // containsGrammar(XMLGrammarDescription):boolean

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

/** 
 * Give the grammarPool the option of caching these grammars.
 * This certainly must be synchronized.
 * 
 * @param grammarType The type of the grammars to be cached.
 * @param grammars    The Grammars that may be cached (unordered, Grammars previously
 *                given to the validator may be included).
 */
public void cacheGrammars(String grammarType, Grammar[] grammars) { 
  // better give both grammars a shot...
  super.cacheGrammars(grammarType, grammars);
  fGrammarPool.cacheGrammars(grammarType, grammars);
} // cacheGrammars(grammarType, Grammar[]);

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

public void cacheGrammars(String grammarType, Grammar[] grammars) {
  if(!fPoolIsLocked) {
    for (int i = 0; i < grammars.length; i++) {
      if(DEBUG) {
        System.out.println("CACHED GRAMMAR " + (i+1) ) ;
        Grammar temp = grammars[i] ;
        //print(temp.getGrammarDescription());
      }
      putGrammar(grammars[i]);
    }
  }
} // cacheGrammars(String, Grammar[]);

代码示例来源:origin: org.wso2.wsdl.validator/wsdl-validator

/** 
 * Create and configure the two grammar pools for this WSDL validation context.
 * 
 * @see org.eclipse.wst.xml.core.internal.validation.core.AbstractNestedValidator#setupValidation(org.eclipse.wst.xml.core.internal.validation.core.NestedValidatorContext)
 */
protected void setupValidation(NestedValidatorContext context) 
{
 super.setupValidation(context);
 
 XMLGrammarPool xsdGrammarPool = new InlineSchemaModelGrammarPoolImpl();
 XMLGrammarPool xmlGrammarPool = new XMLGrammarPoolImpl();
 
 xsdGrammarPools.put(context, xsdGrammarPool);
 xmlGrammarPools.put(context, xmlGrammarPool);
}

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

/**
* Get an instance of XSLoader that is capable of
* parsing schema files
*
* @return
*/
public XSLoader getXSLoader()
{
 XMLSchemaLoader xsloader = new XMLSchemaLoader();
 JBossXSErrorHandler eh = new JBossXSErrorHandler();
 xsloader.setErrorHandler(eh);
 xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
 return xsloader;
}

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

/**
* Get an instance of XSLoader that is capable of
* parsing schema files
* @param xeh XML Error handler
* @param xer XML Entity Resolver
* @return
*/
public XSLoader getXSLoader(XMLErrorHandler xeh, XMLEntityResolver xer)
{
 XMLSchemaLoader xsloader = new XMLSchemaLoader();
 xsloader.setEntityResolver(xer);
 xsloader.setErrorHandler(xeh);
 xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
 return xsloader;
}

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

/**
 * Associate an <code>ASModel</code> with a document instance. This
 * <code>ASModel</code> will be used by the "
 * <code>validate-if-schema</code>" and "
 * <code>datatype-normalization</code>" options during the load of a new
 * <code>Document</code>.
 */
public void setAbstractSchema(ASModel abstractSchema) {
  // since the ASModel associated with this object is an attribute
  // according to the DOM IDL, we must obliterate anything
  // that was set before, rather than adding to it.
  // REVISIT:  so shouldn't we attempt to clear the
  // grammarPool before adding stuff to it?  - NG
  fAbstractSchema = (ASModelImpl)abstractSchema;
  // make sure the GrammarPool is properly initialized.
  XMLGrammarPool grammarPool = (XMLGrammarPool)fConfiguration.getProperty(StandardParserConfiguration.XMLGRAMMAR_POOL);
  // if there is no grammar pool, create one
  // REVISIT: ASBuilder should always create one.
  if (grammarPool == null) {
    // something's not right in this situation...
    grammarPool = new XMLGrammarPoolImpl();
    fConfiguration.setProperty(StandardParserConfiguration.XMLGRAMMAR_POOL,
                  grammarPool);
  }
  if (fAbstractSchema != null) {
    initGrammarPool(fAbstractSchema, grammarPool);
  }
}

代码示例来源:origin: org.wso2.wsdl.validator/wsdl-validator

XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
grammarPreparser.setGrammarPool(grammarPool);

代码示例来源:origin: org.eclipse/org.eclipse.wst.wsi

XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
grammarPreparser.setGrammarPool(grammarPool);

代码示例来源:origin: com.thaiopensource/jing

SymbolTable symbolTable = new SymbolTable();
XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable);
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
preparser.setGrammarPool(grammarPool);

代码示例来源:origin: org.daisy.libs/jing

SymbolTable symbolTable = new SymbolTable();
XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable);
XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
preparser.setGrammarPool(grammarPool);

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