Package org.apache.xerces.impl.xs

Examples of org.apache.xerces.impl.xs.XSAttributeGroupDecl


            Object[] attrValues,
            XSDocumentInfo schemaDoc,
            SchemaGrammar grammar) {
       
        fComplexTypeDecl = new XSComplexTypeDecl();
        fAttrGrp = new XSAttributeGroupDecl();
        Boolean abstractAtt  = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
        XInt    blockAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_BLOCK];
        Boolean mixedAtt     = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
        XInt    finalAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_FINAL];
       
View Full Code Here


    private void processGlobalAttrGroupDecl(XSNamedMap globalAttrGpDecls,
                                            Document document,
                                            Element schemaDeclDomNode) {
        // iterating global attribute group declarations in the Schema
        for (int attrGpIdx = 0; attrGpIdx < globalAttrGpDecls.size(); attrGpIdx++) {
            XSAttributeGroupDecl attrGpDecl = (XSAttributeGroupDecl)
                                                 globalAttrGpDecls.item(attrGpIdx);           
            String attrGpName = attrGpDecl.getName();
            Element attrGpDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                             XSD_LANGUAGE_PREFIX
                                                             + "attributeGroup");
            attrGpDomNode.setAttributeNS(null, "name", attrGpName);
           
            // add annotation to attribute group
            XSAnnotationImpl attrGpAnnotation = (XSAnnotationImpl)
                                                 attrGpDecl.getAnnotation();
            if (attrGpAnnotation != null) {
               addAnnotationToSchemaComponent(document,
                                              attrGpDomNode,
                                              attrGpAnnotation);
            }
           
            XSObjectList attrUses = attrGpDecl.getAttributeUses();
            for (int attrUsesIdx = 0; attrUsesIdx < attrUses.size(); attrUsesIdx++) {
               XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(attrUsesIdx);
               XSAttributeDecl attrDecl = (XSAttributeDecl) attrUse.getAttrDeclaration();
               String constraintName = null;
               String constraintVal = null;          
               if (attrUse.getConstraintType() != XSConstants.VC_NONE) {
                   constraintName = (attrUse.getConstraintType() ==
                                               XSConstants.VC_DEFAULT) ?
                                               "default" : "fixed";
                   constraintVal = attrUse.getConstraintValue();
               }
               String requiredVal = (attrUse.getRequired() == true) ?
                                              "required" : "optional";
               addAttributeToSchemaComponent(document, attrGpDomNode,
                                             attrDecl, constraintName,
                                             constraintVal, requiredVal);
            }
           
            XSWildcard attrWildCard = attrGpDecl.getAttributeWildcard();
            if (attrWildCard != null) {
               addWildcardToSchemaComponent(document, attrGpDomNode,
                                           (XSWildcardDecl) attrWildCard,
                                           "anyAttribute");
            }
View Full Code Here

        Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc);

        // get attribute
        QName   refAttr  = (QName)   attrValues[XSAttributeChecker.ATTIDX_REF];

        XSAttributeGroupDecl attrGrp = null;

        // ref should be here.
        if (refAttr == null) {
            reportGenericSchemaError("Local attributeGroup declaration should have ref.");
            fAttrChecker.returnAttrArray(attrValues, schemaDoc);
View Full Code Here

    XSAttributeGroupDecl traverseGlobal(Element elmNode,
                                        XSDocumentInfo schemaDoc,
                                        SchemaGrammar grammar) {

        XSAttributeGroupDecl attrGrp = new XSAttributeGroupDecl();

        // General Attribute Checking for elmNode declared globally
        Object[] attrValues = fAttrChecker.checkAttributes(elmNode, true, schemaDoc);

        String  nameAttr   = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];

        // global declaration must have a name
        if (nameAttr == null) {
            reportGenericSchemaError("Global attributeGroup declaration must have a name.");
            nameAttr = "no name";
        }

        attrGrp.fName = nameAttr;
        attrGrp.fTargetNamespace = schemaDoc.fTargetNamespace;

        // check the content
        Element child = DOMUtil.getFirstChildElement(elmNode);

        if (child!=null) {
            String childName = DOMUtil.getLocalName(child);
            if (childName.equals(SchemaSymbols.ELT_ANNOTATION)) {
              traverseAnnotationDecl(child, attrValues, false, schemaDoc);
              child = DOMUtil.getNextSiblingElement(child);
          }
        }

        // Traverse the attribute and attribute group elements and fill in the
        // attributeGroup structure

        Element nextNode = traverseAttrsAndAttrGrps(child, attrGrp, schemaDoc, grammar);
        if (nextNode!=null) {
            // An invalid element was found...
            Object[] args = new Object [] {nameAttr, DOMUtil.getLocalName(nextNode)};
            reportSchemaError("src-attribute_group", args);
        }
        // Remove prohibited attributes from the set
        attrGrp.removeProhibitedAttrs();

        // make an entry in global declarations.
        grammar.addGlobalAttributeGroupDecl(attrGrp);

        fAttrChecker.returnAttrArray(attrValues, schemaDoc);
View Full Code Here

                    QName aname = new QName(); // REVISIT: cache this

                    // Get the list of attributes from the element decl.
                    // REVISIT - is this correct?   This is what was done in xerces-1,
                    // but is it right?                             
                    XSAttributeGroupDecl attrGrp = null;
                    if (elementDecl != null) {
                        XSTypeDecl type = elementDecl.fType;
                        if (type != null) {
                          if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
                            XSComplexTypeDecl ctype = (XSComplexTypeDecl)type;
                            attrGrp = ctype.fAttrGrp;
                          }
                        }
                    }
                   
                    for (int aindex = 0; aindex < attrCount; aindex++) {
                        attributes.getName(aindex, aname);
                        if (nodeTest.type != XPath.NodeTest.QNAME ||
                            nodeTest.name.equals(aname)) {
                            fCurrentStep[i]++;
                            if (fCurrentStep[i] == steps.length) {
                                fMatched[i] = true;
                                int j=0;
                                for(; j<i && !fMatched[j]; j++);
                                if(j==i) {
                                    String avalue = attributes.getValue(aindex);
                                    fMatchedString = avalue;
                                    // now, we have to go on the hunt for
                                    // datatype validator; not an easy or pleasant task...

                                    DatatypeValidator aValidator = null;
                                    if (attrGrp != null) {
                                      XSAttributeUse tempAttUse = attrGrp.getAttributeUse(aname.uri, aname.localpart);
                                      if (tempAttUse != null) {
                                        XSAttributeDecl tempAttDecl = tempAttUse.fAttrDecl;
                                        aValidator = tempAttDecl.fType;
                                      }
                                    }
View Full Code Here

    //
    Element traverseAttrsAndAttrGrps(Element firstAttr, XSAttributeGroupDecl attrGrp,
                                     XSDocumentInfo schemaDoc, SchemaGrammar grammar ) {

        Element child=null;
        XSAttributeGroupDecl tempAttrGrp = null;
        XSAttributeUse tempAttrUse = null;
        String childName;

        for (child=firstAttr; child!=null; child=DOMUtil.getNextSiblingElement(child)) {
            childName = DOMUtil.getLocalName(child);
            if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
                tempAttrUse = fSchemaHandler.fAttributeTraverser.traverseLocal(child,
                                                                               schemaDoc, grammar);
                if (tempAttrUse == null) break;
                if (attrGrp.getAttributeUse(tempAttrUse.fAttrDecl.fTargetNamespace,
                                            tempAttrUse.fAttrDecl.fName)==null) {
                    String idName = attrGrp.addAttributeUse(tempAttrUse);
                    if (idName != null) {
                        reportGenericSchemaError("Two distinct members of the {attribute uses} '" +
                                                 idName + "' and '" + tempAttrUse.fAttrDecl.fName +
                                                 "' have {attribute declaration}s both of whose {type definition}s are or are derived from ID");
                    }
                }
                else {
                    // REVISIT: what if one of the attribute uses is "prohibited"
                    reportGenericSchemaError("Duplicate attribute " +
                                             tempAttrUse.fAttrDecl.fName + " found ");
                }
            }
            else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
                //REVISIT: do we need to save some state at this point??
                tempAttrGrp = fSchemaHandler.fAttributeGroupTraverser.traverseLocal(
                       child, schemaDoc, grammar);
                if(tempAttrGrp == null ) break;
                XSAttributeUse[] attrUseS = tempAttrGrp.getAttributeUses();
                XSAttributeUse existingAttrUse = null;
                for (int i=0; i<attrUseS.length; i++) {
                    existingAttrUse = attrGrp.getAttributeUse(attrUseS[i].fAttrDecl.fTargetNamespace,
                                                              attrUseS[i].fAttrDecl.fName);
                    if (existingAttrUse == null) {
View Full Code Here

    Element traverseAttrsAndAttrGrps(Element firstAttr, XSAttributeGroupDecl attrGrp,
            XSDocumentInfo schemaDoc, SchemaGrammar grammar,
            XSObject enclosingParent) {
       
        Element child=null;
        XSAttributeGroupDecl tempAttrGrp = null;
        XSAttributeUseImpl tempAttrUse = null;
        XSAttributeUse otherUse = null;
        String childName;
       
        for (child=firstAttr; child!=null; child=DOMUtil.getNextSiblingElement(child)) {
            childName = DOMUtil.getLocalName(child);
            if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) {
                tempAttrUse = fSchemaHandler.fAttributeTraverser.traverseLocal(child,
                        schemaDoc,
                        grammar,
                        enclosingParent);
                if (tempAttrUse == null) continue;
                if (tempAttrUse.fUse == SchemaSymbols.USE_PROHIBITED) {
                    // Revisit: not passing schema version information, since we do not check for
                    //          attributes of type id when the attribute use is prohibited.
                    attrGrp.addAttributeUse(tempAttrUse);
                    continue;
                }
                otherUse = attrGrp.getAttributeUseNoProhibited(
                        tempAttrUse.fAttrDecl.getNamespace(),
                        tempAttrUse.fAttrDecl.getName());
                if (otherUse==null) {
                    String idName = attrGrp.addAttributeUse(tempAttrUse, fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1);
                    // For XML Schema 1.1, we return null
                    if (idName != null) {
                        String code = (enclosingParent instanceof XSAttributeGroupDecl) ? "ag-props-correct.3" : "ct-props-correct.5";
                        String name = enclosingParent.getName();
                        reportSchemaError(code, new Object[]{name, tempAttrUse.fAttrDecl.getName(), idName}, child);
                    }
                }
                else if (otherUse != tempAttrUse) {
                    String code = (enclosingParent instanceof XSAttributeGroupDecl) ? "ag-props-correct.2" : "ct-props-correct.4";
                    String name = enclosingParent.getName();
                    reportSchemaError(code, new Object[]{name, tempAttrUse.fAttrDecl.getName()}, child);
                }
            }
            else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) {
                //REVISIT: do we need to save some state at this point??
                tempAttrGrp = fSchemaHandler.fAttributeGroupTraverser.traverseLocal(
                        child, schemaDoc, grammar);
                if(tempAttrGrp == null ) continue;
                XSObjectList attrUseS = tempAttrGrp.getAttributeUses();
                XSAttributeUseImpl oneAttrUse;
                int attrCount = attrUseS.getLength();
                for (int i=0; i<attrCount; i++) {
                    oneAttrUse = (XSAttributeUseImpl)attrUseS.item(i);
                    if (oneAttrUse.fUse == SchemaSymbols.USE_PROHIBITED) {
View Full Code Here

            XSDocumentInfo schemaDoc,
            SchemaGrammar grammar,
            XSObject context) {
       
        fComplexTypeDecl = new XSComplexTypeDecl();
        fAttrGrp = new XSAttributeGroupDecl();
        Boolean abstractAtt  = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
        XInt    blockAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_BLOCK];
        Boolean mixedAtt     = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
        XInt    finalAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_FINAL];
       
View Full Code Here

                                            Document document,
                                            Element schemaDeclDomNode) {
       
        // iterating global attribute group declarations in the Schema
        for (int attrGpIdx = 0; attrGpIdx < globalAttrGpDecls.size(); attrGpIdx++) {
            XSAttributeGroupDecl attrGpDecl = (XSAttributeGroupDecl)
                                                 globalAttrGpDecls.item(attrGpIdx);           
            String attrGpName = attrGpDecl.getName();
            Element attrGpDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                             XSD_LANGUAGE_PREFIX
                                                             + "attributeGroup");
            attrGpDomNode.setAttributeNS(null, "name", attrGpName);
           
            // add annotation to attribute group
            XSAnnotationImpl attrGpAnnotation = (XSAnnotationImpl)
                                                 attrGpDecl.getAnnotation();
            if (attrGpAnnotation != null) {
               addAnnotationToSchemaComponent(document,
                                              attrGpDomNode,
                                              attrGpAnnotation);
            }
           
            XSObjectList attrUses = attrGpDecl.getAttributeUses();
            for (int attrUsesIdx = 0; attrUsesIdx < attrUses.size(); attrUsesIdx++) {
               XSAttributeUse attrUse = (XSAttributeUse) attrUses.item(attrUsesIdx);
               XSAttributeDecl attrDecl = (XSAttributeDecl) attrUse.getAttrDeclaration();
               String constraintName = null;
               String constraintVal = null;          
               if (attrUse.getConstraintType() != XSConstants.VC_NONE) {
                   constraintName = (attrUse.getConstraintType() ==
                                               XSConstants.VC_DEFAULT) ?
                                               "default" : "fixed";
                   constraintVal = attrUse.getConstraintValue();
               }
               String requiredVal = (attrUse.getRequired() == true) ?
                                              "required" : "optional";
               addAttributeToSchemaComponent(document, attrGpDomNode,
                                             attrDecl, constraintName,
                                             constraintVal, requiredVal);
            }
           
            XSWildcard attrWildCard = attrGpDecl.getAttributeWildcard();
            if (attrWildCard != null) {
               addWildcardToSchemaComponent(document, attrGpDomNode,
                                           (XSWildcardDecl) attrWildCard,
                                           "anyAttribute");
            }
View Full Code Here

            Object[] attrValues,
            XSDocumentInfo schemaDoc,
            SchemaGrammar grammar) {
       
        fComplexTypeDecl = new XSComplexTypeDecl();
        fAttrGrp = new XSAttributeGroupDecl();
        Boolean abstractAtt  = (Boolean) attrValues[XSAttributeChecker.ATTIDX_ABSTRACT];
        XInt    blockAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_BLOCK];
        Boolean mixedAtt     = (Boolean) attrValues[XSAttributeChecker.ATTIDX_MIXED];
        XInt    finalAtt     = (XInt)    attrValues[XSAttributeChecker.ATTIDX_FINAL];
       
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xs.XSAttributeGroupDecl

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.