Package org.apache.xerces.util

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


        }
       
        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

        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

  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

      // 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

    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

        // in a grammar pool, possibly instantiate an
        // appropriate configuration, and we're on our way.

        SymbolTable sym = new SymbolTable(BIG_PRIME);
        XMLGrammarPreparser preparser = new XMLGrammarPreparser(sym);
        XMLGrammarPoolImpl grammarPool = new XMLGrammarPoolImpl();
        boolean isDTD = false;
        if(externalDTDs != null) {
            preparser.registerPreparser(XMLGrammarDescription.XML_DTD, null);
            isDTD = true;
        } else if(schemas != null) {
View Full Code Here

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

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

    // Constructors
    //

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

TOP

Related Classes of org.apache.xerces.util.XMLGrammarPoolImpl

Copyright © 2018 www.massapicom. 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.