Package org.apache.xerces.xni.grammars

Examples of org.apache.xerces.xni.grammars.XMLGrammarDescription


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


  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 : " +
View Full Code Here

     * @param grammar The Grammar.
     */
    public void putGrammar(Grammar grammar) {
        if(!fPoolIsLocked) {
            synchronized (fGrammars) {
                XMLGrammarDescription desc = grammar.getGrammarDescription();
                int hash = hashCode(desc);
                int index = (hash & 0x7FFFFFFF) % fGrammars.length;
                for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                    if (entry.hash == hash && equals(entry.desc, desc)) {
                        entry.grammar = grammar;
View Full Code Here

    } // resolveEntity(String,String,String):XMLInputSource
   
    /** Determines the type of resource being resolved **/
    private String getType(XMLResourceIdentifier resourceIdentifier) {
        if (resourceIdentifier instanceof XMLGrammarDescription) {
            XMLGrammarDescription desc = (XMLGrammarDescription) resourceIdentifier;
            if (XMLGrammarDescription.XML_SCHEMA.equals(desc.getGrammarType())) {
                return XSD_TYPE;
            }
        }
        return XML_TYPE;
    } // getType(XMLResourceIdentifier):String
View Full Code Here

     */
    public void putGrammar(Grammar grammar) {
        if (!fPoolIsLocked) {
            synchronized (fGrammars) {
                clean();
                XMLGrammarDescription desc = grammar.getGrammarDescription();
                int hash = hashCode(desc);
                int index = (hash & 0x7FFFFFFF) % fGrammars.length;
                for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                    if (entry.hash == hash && equals(entry.desc, desc)) {
                        if (entry.grammar.get() != grammar) {
View Full Code Here

    } // resolveEntity(String,String,String):XMLInputSource
   
    /** Determines the type of resource being resolved **/
    private String getType(XMLResourceIdentifier resourceIdentifier) {
        if (resourceIdentifier instanceof XMLGrammarDescription) {
            XMLGrammarDescription desc = (XMLGrammarDescription) resourceIdentifier;
            if (XMLGrammarDescription.XML_SCHEMA.equals(desc.getGrammarType())) {
                return XSD_TYPE;
            }
        }
        return XML_TYPE;
    } // getType(XMLResourceIdentifier):String
View Full Code Here

     * @param grammar The Grammar.
     */
    public void putGrammar(Grammar grammar) {
        if(!fPoolIsLocked) {
            synchronized (fGrammars) {
                XMLGrammarDescription desc = grammar.getGrammarDescription();
                int hash = hashCode(desc);
                int index = (hash & 0x7FFFFFFF) % fGrammars.length;
                for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                    if (entry.hash == hash && equals(entry.desc, desc)) {
                        entry.grammar = grammar;
View Full Code Here

     */
    public void putGrammar(Grammar grammar) {
        if (!fPoolIsLocked) {
            synchronized (fGrammars) {
                clean();
                XMLGrammarDescription desc = grammar.getGrammarDescription();
                int hash = hashCode(desc);
                int index = (hash & 0x7FFFFFFF) % fGrammars.length;
                for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                    if (entry.hash == hash && equals(entry.desc, desc)) {
                        if (entry.grammar.get() != grammar) {
View Full Code Here

     * @param desc The description of the grammar to be compared with
     * @return     True if they are equal, else false
     */
    public boolean equals(Object descObj) {
        if(!(descObj instanceof XMLGrammarDescription)) return false;
        XMLGrammarDescription desc = (XMLGrammarDescription)descObj;
        if (!getGrammarType().equals(desc.getGrammarType())) {
            return false;
        }
        if (fTargetNamespace != null && fTargetNamespace.equals(((XSDDescription)desc).getTargetNamespace())) {
            return true;
        }
View Full Code Here

     * @param grammar The Grammar.
     */
    public void putGrammar(Grammar grammar) {
        if(!fPoolIsLocked) {
            synchronized (fGrammars) {
                XMLGrammarDescription desc = grammar.getGrammarDescription();
                int hash = hashCode(desc);
                int index = (hash & 0x7FFFFFFF) % fGrammars.length;
                for (Entry entry = fGrammars[index]; entry != null; entry = entry.next) {
                    if (entry.hash == hash && equals(entry.desc, desc)) {
                        entry.grammar = grammar;
View Full Code Here

TOP

Related Classes of org.apache.xerces.xni.grammars.XMLGrammarDescription

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.