Package org.apache.xerces.xs

Examples of org.apache.xerces.xs.XSNamedMap


      Map schemaMap = new HashMap();
      schemaMap.put("http://org.jboss.ws/types", xsdFile.toURL());
      schemaMap.put("http://org.jboss.ws/types2", new File("resources/tools/xsd/schemaimport/SchemaImport.xsd").toURL());
      XSModel xsmodel = parseSchema(schemaMap);
      assertNotNull("XSModel is null?", xsmodel);
      XSNamedMap xsmap = xsmodel.getComponentsByNamespace(XSConstants.TYPE_DEFINITION, "http://org.jboss.ws/types2");
      assertNotNull("XSNamedMap is null?", xsmap);
      XSObject xsobj = xsmap.itemByName("http://org.jboss.ws/types2", "USAddress");
      assertNotNull("Is XSObject null?", xsobj);
   }
View Full Code Here


        // and a close tag, instead of an empty element tag.  This isn't a big
        // deal, though
        sendIndentedElement("psv:schemaComponents");

        // typeDefinitions
        XSNamedMap components = item.getComponents(XSConstants.TYPE_DEFINITION);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVITypeDefinition((XSTypeDefinition)components.item(i));
        }
        // elementDeclarations
        components = item.getComponents(XSConstants.ELEMENT_DECLARATION);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVIElementDeclaration(
                (XSElementDeclaration)components.item(i));
        }
        // attributeDeclarations
        components = item.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVIAttributeDeclaration(
                (XSAttributeDeclaration)components.item(i));
        }
        // modelGroupDefinitions
        components = item.getComponents(XSConstants.MODEL_GROUP_DEFINITION);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVIModelGroupDefinition(
                (XSModelGroupDefinition)components.item(i));
        }
        // attributeGroupDefinitions
        components = item.getComponents(XSConstants.ATTRIBUTE_GROUP);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVIAttributeGroupDefinition(
                (XSAttributeGroupDefinition)components.item(i));
        }
        // notationDeclarations
        components = item.getComponents(XSConstants.NOTATION_DECLARATION);
        for (int i = 0; i < components.getLength(); i++) {
            processPSVINotationDeclaration(
                (XSNotationDeclaration)components.item(i));
        }
        sendUnIndentedElement("psv:schemaComponents");
    }
View Full Code Here

                                                            + "schema");    
      
       document.appendChild(schemaDeclDomNode);
      
       // process global element declarations
       XSNamedMap globalElemDecls = xsModel.getComponents
                                            (XSConstants.ELEMENT_DECLARATION);
       processGlobalElementDecl(globalElemDecls, document, schemaDeclDomNode);
      
       // process global complex type declarations
       XSNamedMap globalComplexTypeDecls = xsModel.getComponents
                                             (XSTypeDefinition.COMPLEX_TYPE);
       processGlobalComplexTypeDecl(globalComplexTypeDecls, document, schemaDeclDomNode);
      
       // process global simple type declarations
       XSNamedMap globalSimpleTypeDecls = xsModel.getComponents
                                             (XSTypeDefinition.SIMPLE_TYPE);
       processGlobalSimpleTypeDecl(globalSimpleTypeDecls, document, schemaDeclDomNode);
      
       // process global attribute declarations
       XSNamedMap globalAttrDecls = xsModel.getComponents
                                             (XSConstants.ATTRIBUTE_DECLARATION);
       processGlobalAttrDecl(globalAttrDecls, document, schemaDeclDomNode);
      
       // process global attribute group declarations
       XSNamedMap globalAttrGroupDecls = xsModel.getComponents
                                             (XSConstants.ATTRIBUTE_GROUP);
       processGlobalAttrGroupDecl(globalAttrGroupDecls, document, schemaDeclDomNode);
      
       // process global model group declarations
       XSNamedMap globalGroupDecls = xsModel.getComponents
                                             (XSConstants.MODEL_GROUP_DEFINITION);
       processGlobalGroupDecl(globalGroupDecls, document, schemaDeclDomNode);

       return document;
    } // end of, transformXSModelToDOM
View Full Code Here

     */
    private void addIDConstraintsToElementDecl(Document document,
                                               XSElementDecl elemDecl,
                                               Element elemDeclDomNode)
                                               throws DOMException {
         XSNamedMap idConstraintsMap = elemDecl.getIdentityConstraints();
        
         // iterate all identity constraints on an element declaration
         for (int idConsIdx = 0; idConsIdx < idConstraintsMap.getLength();
                                               idConsIdx++) {
             IdentityConstraint idCons = (IdentityConstraint)
                                           idConstraintsMap.item(idConsIdx);
             String consType = null;
             String idReferStr = null;            
             if (idCons.getCategory() == XSIDCDefinition.IC_UNIQUE) {
                 consType = "unique"
             }
View Full Code Here

            // parse document
            System.out.println("Parsing " + argv[0] + "...");
            XSModel model = schemaLoader.loadURI(argv[0]);
            if (model != null) {
              // element declarations
                XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION);
                if (map.getLength() != 0) {
          System.out.println("*************************************************");
          System.out.println("* Global element declarations: {namespace} name ");
          System.out.println("*************************************************");
                    for (int i = 0; i < map.getLength(); i++) {
                        XSObject item = map.item(i);
                        System.out.println("{" + item.getNamespace() + "}" + item.getName());
                    }
                }
                // attribute declarations
                map = model.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
                if (map.getLength() != 0) {
          System.out.println("*************************************************");
                    System.out.println("* Global attribute declarations: {namespace} name");
          System.out.println("*************************************************");
                    for (int i = 0; i < map.getLength(); i++) {
                        XSObject item = map.item(i);
                        System.out.println("{" + item.getNamespace() + "}" + item.getName());
                    }
                }
        // notation declarations
        map = model.getComponents(XSConstants.TYPE_DEFINITION);
        if (map.getLength() != 0) {
          System.out.println("*************************************************");
          System.out.println("* Global type declarations: {namespace} name");
          System.out.println("*************************************************");
          for (int i = 0; i < map.getLength(); i++) {
            XSObject item = map.item(i);
            System.out.println("{" + item.getNamespace() + "}" + item.getName());
          }
        }
               
        // notation declarations
        map = model.getComponents(XSConstants.NOTATION_DECLARATION);
        if (map.getLength() != 0) {
          System.out.println("*************************************************");
          System.out.println("* Global notation declarations: {namespace} name");
          System.out.println("*************************************************");
          for (int i = 0; i < map.getLength(); i++) {
            XSObject item = map.item(i);
            System.out.println("{" + item.getNamespace() + "}" + item.getName());
          }
        }

            }
View Full Code Here

        }
       
        private void mergeSchemaGrammars(SchemaGrammar cachedGrammar, SchemaGrammar newGrammar) {

            /** Add new top-level element declarations. **/
            XSNamedMap map = newGrammar.getComponents(XSConstants.ELEMENT_DECLARATION);
            int length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSElementDecl decl = (XSElementDecl) map.item(i);
                if (cachedGrammar.getGlobalElementDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalElementDecl(decl);
                }
            }
           
            /** Add new top-level attribute declarations. **/
            map = newGrammar.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
            length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSAttributeDecl decl = (XSAttributeDecl) map.item(i);
                if (cachedGrammar.getGlobalAttributeDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalAttributeDecl(decl);
                }
            }
           
            /** Add new top-level type definitions. **/
            map = newGrammar.getComponents(XSConstants.TYPE_DEFINITION);
            length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSTypeDefinition decl = (XSTypeDefinition) map.item(i);
                if (cachedGrammar.getGlobalTypeDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalTypeDecl(decl);
                }
            }
           
            /** Add new top-level attribute group definitions. **/
            map = newGrammar.getComponents(XSConstants.ATTRIBUTE_GROUP);
            length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSAttributeGroupDecl decl = (XSAttributeGroupDecl) map.item(i);
                if (cachedGrammar.getGlobalAttributeGroupDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalAttributeGroupDecl(decl);
                }
            }
           
            /** Add new top-level model group definitions. **/
            map = newGrammar.getComponents(XSConstants.MODEL_GROUP);
            length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSGroupDecl decl = (XSGroupDecl) map.item(i);
                if (cachedGrammar.getGlobalGroupDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalGroupDecl(decl);
                }
            }
           
            /** Add new top-level notation declarations. **/
            map = newGrammar.getComponents(XSConstants.NOTATION_DECLARATION);
            length = map.getLength();
            for (int i = 0; i < length; ++i) {
                XSNotationDecl decl = (XSNotationDecl) map.item(i);
                if (cachedGrammar.getGlobalNotationDecl(decl.getName()) == null) {
                    cachedGrammar.addGlobalNotationDecl(decl);
                }
            }
           
View Full Code Here

        // TODO: we dont have type alternative for now.
    } // getElidedComponents()

    // apply the first step for the components of result
    private void applyFirstStep(Step step) throws SCDException {
        XSNamedMap map = null;

        switch (step.getAxisType()) {
        case Axis.ANNOTATION:
            XSObjectList annotations = xsModel.getAnnotations();
            for (int i = 0, n = annotations.size(); i < n; ++i) {
                addComponent(annotations.item(i), step.getNametest(), result);
            }
            break;
        case Axis.SCHEMA_ELEMENT:
            map = xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);
            break;
        case Axis.TYPE:
            map = xsModel.getComponents(XSConstants.TYPE_DEFINITION);
            break;
        case Axis.SCHEMA_ATTRIBUTE:
            map = xsModel.getComponents(XSConstants.ATTRIBUTE_DECLARATION);
            break;
        case Axis.ATTRIBUTE_GROUP:
            map = xsModel.getComponents(XSConstants.ATTRIBUTE_GROUP);
            break;
        case Axis.GROUP:
            map = xsModel.getComponents(XSConstants.MODEL_GROUP_DEFINITION); // TODO: correct?
            break;
        case Axis.NOTATION:
            map = xsModel.getComponents(XSConstants.NOTATION_DECLARATION);
            break;
        case Axis.COMPONENT:
        case Axis.SPECIAL_COMPONENT: {
            currentComponents.clear();
            addTopLevelComponents(step.getNametest());
            int size = currentComponents.size();
            for (int i = 0; i < currentComponents.size(); ++i) {
                componentChildren((XSObject)currentComponents.get(i), NO_FILTER, SCDParser.WILDCARD, currentComponents);
            }
            int start = step.getAxisType() == Axis.SPECIAL_COMPONENT ? 0 : size;
            for (int i = start; i < currentComponents.size(); ++i) {
                addComponent((XSObject)currentComponents.get(i), step.getNametest(), result);
            }
        }
        break;
        default:
            throw new SCDException("Error in SCD: Unsupported top level component type "
                    + step.getAxisName());
        }
        if (map != null && !map.isEmpty()) {
            for (int i = 0, n = map.size(); i < n; ++i) {
                addComponent(map.item(i), step.getNametest(), result);
            }
        }
        applyPredicate(step.getPredicate());
    } // applyFirstStep()
View Full Code Here

        final short[] SCHEMA_COMPONENTS = new short[] {
                XSConstants.ELEMENT_DECLARATION, XSConstants.TYPE_DEFINITION, XSConstants.ATTRIBUTE_DECLARATION,
                XSConstants.ATTRIBUTE_GROUP, XSConstants.MODEL_GROUP_DEFINITION, XSConstants.NOTATION_DECLARATION,
                // XSConstants.IDENTITY_CONSTRAINT // TODO: return empty. we don't support IDC at top level
        };
        XSNamedMap map;
        for (int i = 0; i < SCHEMA_COMPONENTS.length; ++i) {
            map = xsModel.getComponents(SCHEMA_COMPONENTS[i]);
            if (!map.isEmpty()) {
                for (int j = 0, n =map.size(); j < n; ++j) {
                    addComponent(map.item(i), nameTest, result);
                }
            }
        }
    } // getTopLevelComponents()
View Full Code Here

                    addComponent(((XSElementDeclaration)sourceComponent).getEnclosingCTDefinition(),
                            nameTest, targetComponents);
                }
            }
            if (NO_FILTER == filter || XSConstants.IDENTITY_CONSTRAINT == filter) {
                XSNamedMap idcs = ((XSElementDeclaration)sourceComponent).getIdentityConstraints();
                for (int i = 0, n = idcs.size(); i < n; ++i) {
                    addComponent(idcs.item(i),
                            nameTest, targetComponents);
                }
            }
            if (NO_FILTER == filter || XSConstants.ELEMENT_DECLARATION == filter) {
                addComponent(((XSElementDeclaration)sourceComponent).getSubstitutionGroupAffiliation(),
View Full Code Here

                                                            + "schema");    
      
       document.appendChild(schemaDeclDomNode);
      
       // process global element declarations
       XSNamedMap globalElemDecls = xsModel.getComponents
                                            (XSConstants.ELEMENT_DECLARATION);
       processGlobalElementDecl(globalElemDecls, document, schemaDeclDomNode);
      
       // process global complex type declarations
       XSNamedMap globalComplexTypeDecls = xsModel.getComponents
                                             (XSTypeDefinition.COMPLEX_TYPE);
       processGlobalComplexTypeDecl(globalComplexTypeDecls, document, schemaDeclDomNode);
      
       // process global simple type declarations
       XSNamedMap globalSimpleTypeDecls = xsModel.getComponents
                                             (XSTypeDefinition.SIMPLE_TYPE);
       processGlobalSimpleTypeDecl(globalSimpleTypeDecls, document, schemaDeclDomNode);
      
       // process global attribute declarations
       XSNamedMap globalAttrDecls = xsModel.getComponents
                                             (XSConstants.ATTRIBUTE_DECLARATION);
       processGlobalAttrDecl(globalAttrDecls, document, schemaDeclDomNode);
      
       // process global attribute group declarations
       XSNamedMap globalAttrGroupDecls = xsModel.getComponents
                                             (XSConstants.ATTRIBUTE_GROUP);
       processGlobalAttrGroupDecl(globalAttrGroupDecls, document, schemaDeclDomNode);
      
       // process global model group declarations
       XSNamedMap globalGroupDecls = xsModel.getComponents
                                             (XSConstants.MODEL_GROUP_DEFINITION);
       processGlobalGroupDecl(globalGroupDecls, document, schemaDeclDomNode);

       return document;
      
View Full Code Here

TOP

Related Classes of org.apache.xerces.xs.XSNamedMap

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.