Examples of XMLGrammarPoolImpl


Examples of org.apache.xerces.impl.validation.XMLGrammarPoolImpl

    // Constructors
    //

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

Examples of org.apache.xerces.impl.validation.XMLGrammarPoolImpl

    private void initGrammarPool(ASModelImpl currModel) {
        // put all the grammars in fAbstractSchema into the grammar pool.
        // REVISIT:  straighten this out when grammar caching's properly implemented!
        if(!(fGrammarPool instanceof XMLGrammarPoolImpl)) return;
        XMLGrammarPoolImpl poolImpl = (XMLGrammarPoolImpl)fGrammarPool;
        SchemaGrammar grammar = null;
        if((grammar = currModel.getGrammar()) != null) {
            String tns = grammar.getTargetNamespace();
            poolImpl.putGrammarNS(tns, grammar);
        }
        Vector modelStore = currModel.getInternalASModels();
        for (int i = 0; i < modelStore.size(); i++) {
            initGrammarPool((ASModelImpl)modelStore.elementAt(i));
        }
View Full Code Here

Examples of org.apache.xerces.impl.validation.XMLGrammarPoolImpl

        // clear grammars, and put the one for schema namespace there
        fGrammarBucket.reset();
        fGrammarPool = (XMLGrammarPool)componentManager.getProperty(XMLGRAMMAR_POOL);
        if(fGrammarPool instanceof XMLGrammarPoolImpl) {
            XMLGrammarPoolImpl poolImpl = (XMLGrammarPoolImpl)fGrammarPool;
            Grammar [] initialGrammars = poolImpl.getGrammarsNS();
            for (int i = 0; i < initialGrammars.length; i++) {
                fGrammarBucket.putGrammar((SchemaGrammar)(initialGrammars[i]));
            }
        }
View Full Code Here

Examples of org.apache.xerces.impl.validation.XMLGrammarPoolImpl

        };
        addRecognizedProperties(recognizedProperties);

        // create and register missing components
        if (grammarPool == null) {
            grammarPool = new XMLGrammarPoolImpl();
        }
        fGrammarPool = grammarPool;
        setProperty(XMLGRAMMAR_POOL, fGrammarPool);

        fEntityManager = createEntityManager();
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

        return null;
    }//normalizeNode

    private XMLGrammarPool createGrammarPool(DocumentTypeImpl docType) {

        XMLGrammarPoolImpl pool = new XMLGrammarPoolImpl();
       
        XMLGrammarPreparser preParser = new XMLGrammarPreparser(fSymbolTable);
        preParser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
        preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true);
        preParser.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true);
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

        }
       
        XMLGrammarPool pool = (XMLGrammarPool)config.getProperty(DOMValidationConfiguration.GRAMMAR_POOL);
        if (pool != null) {
            // copy the grammar pool
            XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
            grammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, 
                                      pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA));
            fConfiguration.setProperty(DOMValidationConfiguration.GRAMMAR_POOL, grammarPool);
        }
    }
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

        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);
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

  protected void setupValidation(NestedValidatorContext context)
  {
  super.setupValidation(context);
   
  XMLGrammarPool xsdGrammarPool = new InlineSchemaModelGrammarPoolImpl();
  XMLGrammarPool xmlGrammarPool = new XMLGrammarPoolImpl();
 
  xsdGrammarPools.put(context, xsdGrammarPool);
  xmlGrammarPools.put(context, xmlGrammarPool);
  }
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

      // Catch the exception and ignore if we can't set this feature.
    }

    // cs : toggle the comments on these 2 lines to easily disable caching
      // grammarPreparser.setGrammarPool(new XMLGrammarPoolImpl());    
    grammarPreparser.setGrammarPool(grammarPool != null ? grammarPool : new XMLGrammarPoolImpl());
    grammarPreparser.setErrorHandler(errorHandler);
    if (entityResolver != null)
    {
      grammarPreparser.setEntityResolver(entityResolver);
    }

    try
    {
      XMLInputSource is = null;
      List oldGrammars = null;
      XMLGrammarPoolImpl pool = null;
      // This allows support for the inline schema in WSDL documents.
      if (inlineXSD)
      {      
        Reader reader = new StringReader(schema);
      is = new XMLInputSource(null,filelocation,filelocation,reader,null);
       
      ((InlineXSDResolver)inlineSchemaEntityResolver).addReferringSchema(is,targetNamespace);
      // In the case that 'shared' grammar pool is used we need to consider
      // that we might have already added a schema to the pool with the same target namespace
      // as the inline schema we're hoping to construct.  In this case we need to remove
      // the schema from the pool before constructing our inline schema.  We can add it
      // back when we're all done.
      pool = (XMLGrammarPoolImpl)grammarPreparser.getGrammarPool();               
      oldGrammars = new ArrayList();
      // Remove the inline schema namespace if it is listed directly
      // in the pool. If it is indirectly listed as an import of a grammar listed
      // directly in the pool hide the grammar to continue to get caching benefits
      // from the cached grammar.
      Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA);
      int numGrammars = grammars.length;
      for(int i = 0; i < numGrammars; i++)
      {
        XMLGrammarDescription desc = grammars[i].getGrammarDescription();
        if(targetNamespace.equals(desc.getNamespace()))
        {
          oldGrammars.add(pool.removeGrammar(desc));
        }
        else
        {
          if(grammars[i] instanceof XSGrammar)
          {
          XSGrammar grammar = (XSGrammar)grammars[i];
               
          StringList namespaces = grammar.toXSModel().getNamespaces();
          if(namespaces.contains(targetNamespace))
          {
            oldGrammars.add(pool.removeGrammar(desc));
                  //pool.putGrammar(new XSGrammarHider(grammar, targetNamespace));
          }
          }
        }
      }
         
      Set inlineNSs = ((InlineXSDResolver)inlineSchemaEntityResolver).getInlineSchemaNSs();
      Iterator nsiter = inlineNSs.iterator();
      while(nsiter.hasNext())
      {
        XSDDescription desc = new XSDDescription();
        desc.setNamespace((String)nsiter.next());     
        Grammar oldGrammar = pool.removeGrammar(desc);
        if(oldGrammar != null)
          oldGrammars.add(oldGrammar);
      }

      }
      // get the input source for an external schema file
      else
      {
        is = new XMLInputSource(null,schema,schema);
      }

      XSGrammar grammar = (XSGrammar)grammarPreparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,is);
      xsModel = grammar.toXSModel();
     
      // Here we add the temporiliy removed schema back.
    if (inlineXSD && oldGrammars != null)
    {
      XSDDescription description = new XSDDescription();
      description.setNamespace(targetNamespace);
      pool.removeGrammar(description);
       
      Set inlineNSs = ((InlineXSDResolver)inlineSchemaEntityResolver).getInlineSchemaNSs();
      Iterator nsiter = inlineNSs.iterator();
      while(nsiter.hasNext())
      {
      XSDDescription desc = new XSDDescription();
        desc.setNamespace((String)nsiter.next());  
        pool.removeGrammar(desc);
      }
     
      Iterator oldGIter = oldGrammars.iterator();
        while(oldGIter.hasNext())
      {
       Grammar oldGrammar = (Grammar)oldGIter.next();
       if(oldGrammar != null)
         pool.putGrammar(oldGrammar);
      }
    } 
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.apache.xerces.util.XMLGrammarPoolImpl

    ValidateErrorHandler errorHandler = new ValidateErrorHandler();
    errorHandler.getErrorMessages().clear();
    try
    {
    XMLGrammarPreparser grammarPreparser = new XMLGrammarPreparser();
    XMLGrammarPool grammarPool = new XMLGrammarPoolImpl();
    grammarPreparser.setGrammarPool(grammarPool);
  
      grammarPreparser.setErrorHandler(errorHandler);
      if (entityResolver != null)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.