Package org.apache.xerces.impl.xs

Examples of org.apache.xerces.impl.xs.SchemaGrammar$XSAnyType


   * @param uri URI of XML schema
   * @param in InputStream of XML schema
   */
  public void updateXSDInfo(String uri,Reader in){
    try {
      SchemaGrammar grammer = (SchemaGrammar)new XMLSchemaLoader().loadGrammar(
          new XMLInputSource(null,null,null,in,null));
     
      // clear at first
      String targetNS = grammer.getTargetNamespace();
      nsTagListMap.put(targetNS,new ArrayList());
      List tagList = (List)nsTagListMap.get(targetNS);
//      root = null;
     
      XSNamedMap map = grammer.getComponents(XSConstants.ELEMENT_DECLARATION);
      for(int i=0;i<map.getLength();i++){
        XSElementDeclaration element = (XSElementDeclaration)map.item(i);
        parseXSDElement(tagList,element);
      }
    } catch(Exception ex){
View Full Code Here


    try {
      DTDResolver resolver = new DTDResolver(new IDTDResolver[0],
          getFile().getLocation().makeAbsolute().toFile().getParentFile());
      InputStream in = resolver.getInputStream(this.schemaURI);
      if(in!=null){
        SchemaGrammar grammer = (SchemaGrammar)new XMLSchemaLoader().loadGrammar(
            new XMLInputSource(null,null,null,in,null));
        return grammer.getTargetNamespace();
      }
    } catch(Exception ex){
    }
    return null;
  }
View Full Code Here

            comboDocumentRoot.removeAll();
            DTDResolver resolver = new DTDResolver(new IDTDResolver[0],
                page1.getFile().getLocation().makeAbsolute().toFile().getParentFile());
            InputStream in = resolver.getInputStream(getSchemaURI());
            if(in!=null){
              SchemaGrammar grammer = (SchemaGrammar)new XMLSchemaLoader().loadGrammar(
                  new XMLInputSource(null,null,null,in,null));
              XSNamedMap map = grammer.getComponents(XSConstants.ELEMENT_DECLARATION);
              for(int i=0;i<map.getLength();i++){
                XSElementDeclaration element = (XSElementDeclaration)map.item(i);
                comboDocumentRoot.add(element.getName());
              }
            }
View Full Code Here

        for (int i=0; i<fKeyrefStackPos; i++) {
            Document keyrefDoc = DOMUtil.getDocument(fKeyrefs[i]);
            XSDocumentInfo keyrefSchemaDoc = (XSDocumentInfo)fDoc2XSDocumentMap.get(keyrefDoc);
            keyrefSchemaDoc.fNamespaceSupport.makeGlobal();
            keyrefSchemaDoc.fNamespaceSupport.setEffectiveContext( fKeyrefNamespaceContext[i] );
            SchemaGrammar keyrefGrammar = fGrammarBucket.getGrammar(keyrefSchemaDoc.fTargetNamespace);
            // need to set <keyref> to hidden before traversing it,
            // because it has global scope
            DOMUtil.setHidden(fKeyrefs[i]);
            fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar);
        }
View Full Code Here

        fElementTraverser.fDeferTraversingLocalElements = false;

        for (int i = 0; i < fLocalElemStackPos; i++) {
            Element currElem = fLocalElementDecl[i];
            XSDocumentInfo currSchema = (XSDocumentInfo)fDoc2XSDocumentMap.get(DOMUtil.getDocument(currElem));
            SchemaGrammar currGrammar = fGrammarBucket.getGrammar(currSchema.fTargetNamespace);
            fElementTraverser.traverseLocal (fParticle[i], currElem, currSchema, currGrammar, fAllContext[i], fEnclosingCT[i]);
        }
    }
View Full Code Here

            throws IOException {

        fLocationPairs = locationPairs;

        // first try to find it in the bucket/pool, return if one is found
        SchemaGrammar grammar = findGrammar(desc);
        if (grammar != null)
            return grammar;
       
        if (fSchemaParser != null) {
            fSchemaParser.resetNodePool();
        }

        short referType = desc.getContextType();
        String schemaNamespace = desc.getTargetNamespace();
        // handle empty string URI as null
        if (schemaNamespace != null) {
            schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
        }

        // before parsing a schema, need to clear registries associated with
        // parsing schemas
        prepareForParse();

        // first phase:  construct trees.
        Document schemaRoot = getSchema(schemaNamespace, is,
                                        referType == XSDDescription.CONTEXT_PREPARSE,
                                        referType, null);
        if (schemaRoot == null) {
            // something went wrong right off the hop
            return null;
        }
        if ( schemaNamespace == null && referType == XSDDescription.CONTEXT_PREPARSE) {
            Element schemaElem = DOMUtil.getRoot(schemaRoot);
            schemaNamespace = DOMUtil.getAttrValue(schemaElem, SchemaSymbols.ATT_TARGETNAMESPACE);
            if(schemaNamespace != null && schemaNamespace.length() > 0) {
                schemaNamespace = fSymbolTable.addSymbol(schemaNamespace);
                desc.setTargetNamespace(schemaNamespace);
                String schemaId = XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false);
                XSDKey key = new XSDKey(schemaId, referType, schemaNamespace);
                fTraversed.put(key, schemaRoot );
                if (schemaId != null) {
                    fDoc2SystemId.put(schemaRoot, schemaId );
                }
            }
        }

        // before constructing trees and traversing a schema, need to reset
        // all traversers and clear all registries
        prepareForTraverse();

        fRoot = constructTrees(schemaRoot, is.getSystemId(), desc);
        if (fRoot == null) {
            return null;
        }

        // second phase:  fill global registries.
        buildGlobalNameRegistries();

        // third phase:  call traversers
        traverseSchemas();

        // fourth phase: handle local element decls
        traverseLocalElements();

        // fifth phase:  handle Keyrefs
        resolveKeyRefs();

        // sixth phase:  validate attribute of non-schema namespaces
        // REVISIT: skip this for now. we really don't want to do it.
        //fAttributeChecker.checkNonSchemaAttributes(fGrammarBucket);

        // seventh phase:  store imported grammars
        // for all grammars with <import>s
        for (int i = fAllTNSs.size() - 1; i >= 0; i--) {
            // get its target namespace
            String tns = (String)fAllTNSs.elementAt(i);
            // get all namespaces it imports
            Vector ins = (Vector)fImportMap.get(tns);
            // get the grammar
            SchemaGrammar sg = fGrammarBucket.getGrammar(emptyString2Null(tns));
            if (sg == null)
                continue;
            SchemaGrammar isg;
            // for imported namespace
            int count = 0;
            for (int j = 0; j < ins.size(); j++) {
                // get imported grammar
                isg = fGrammarBucket.getGrammar((String)ins.elementAt(j));
View Full Code Here

     * First try to find a grammar in the bucket, if failed, consult the
     * grammar pool. If a grammar is found in the pool, then add it (and all
     * imported ones) into the bucket.
     */
    protected SchemaGrammar findGrammar(XSDDescription desc) {
        SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace());
        if (sg == null) {
            if (fGrammarPool != null) {
                sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(desc);
                if (sg != null) {
                    // put this grammar into the bucket, along with grammars
View Full Code Here

        // are valid
       
        // a schema document can always access it's own target namespace
        currSchemaInfo.addAllowedNS(currSchemaInfo.fTargetNamespace);

        SchemaGrammar sg = null;
       
        if (referType == XSDDescription.CONTEXT_INCLUDE ||
            referType == XSDDescription.CONTEXT_REDEFINE) {
            sg = fGrammarBucket.getGrammar(currSchemaInfo.fTargetNamespace);
        }
        else {
            sg = new SchemaGrammar(currSchemaInfo.fTargetNamespace, desc.makeClone());
            fGrammarBucket.putGrammar(sg);
        }

        // store the document and its location
        // REVISIT: don't expose the DOM tree
        //sg.addDocument(currSchemaInfo.fSchemaDoc, (String)fDoc2SystemId.get(currSchemaInfo));
        sg.addDocument(null, (String)fDoc2SystemId.get(currSchemaInfo));
           
        fDoc2XSDocumentMap.put(schemaRoot, currSchemaInfo);

        Vector dependencies = new Vector();
        Element rootNode = DOMUtil.getRoot(schemaRoot);
View Full Code Here

        schemasToProcess.push(fRoot);
        while (!schemasToProcess.empty()) {
            XSDocumentInfo currSchemaDoc =
            (XSDocumentInfo)schemasToProcess.pop();
            Document currDoc = currSchemaDoc.fSchemaDoc;
            SchemaGrammar currSG = fGrammarBucket.getGrammar(currSchemaDoc.fTargetNamespace);
            if (DOMUtil.isHidden(currDoc)) {
                // must have processed this already!
                continue;
            }
            Element currRoot = DOMUtil.getRoot(currDoc);
View Full Code Here

            }
            return null;
        }

        // check whether there is grammar for the requested namespace
        SchemaGrammar sGrammar = fGrammarBucket.getGrammar(declToTraverse.uri);
        if (sGrammar == null) {
            if (needReportTNSError(declToTraverse.uri))
                reportSchemaError("src-resolve", new Object[]{declToTraverse.rawname, COMP_TYPE[declType]}, elmNode);
            return null;
        }

        // if there is such grammar, check whether the requested component is in the grammar
        Object retObj = null;
        switch (declType) {
        case ATTRIBUTE_TYPE :
            retObj = sGrammar.getGlobalAttributeDecl(declToTraverse.localpart);
            break;
        case ATTRIBUTEGROUP_TYPE :
            retObj = sGrammar.getGlobalAttributeGroupDecl(declToTraverse.localpart);
            break;
        case ELEMENT_TYPE :
            retObj = sGrammar.getGlobalElementDecl(declToTraverse.localpart);
            break;
        case GROUP_TYPE :
            retObj = sGrammar.getGlobalGroupDecl(declToTraverse.localpart);
            break;
        case IDENTITYCONSTRAINT_TYPE :
            retObj = sGrammar.getIDConstraintDecl(declToTraverse.localpart);
            break;
        case NOTATION_TYPE :
            retObj = sGrammar.getGlobalNotationDecl(declToTraverse.localpart);
            break;
        case TYPEDECL_TYPE :
            retObj = sGrammar.getGlobalTypeDecl(declToTraverse.localpart);
            break;
        }

        // if the component is parsed, return it
        if (retObj != null)
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xs.SchemaGrammar$XSAnyType

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.