Package org.apache.xerces.impl.xs

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


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


                                       Element schemaDeclDomNode)
                                       throws DOMException {
       
        // iterating global attribute declarations in the Schema            
        for (int attrIdx = 0; attrIdx < globalAttrDecls.size(); attrIdx++) {
           XSAttributeDecl attrDecl = (XSAttributeDecl)
                                       globalAttrDecls.item(attrIdx);
           String constraintName = null;
           String constraintVal = null;          
           if (attrDecl.getConstraintType() != XSConstants.VC_NONE) {
              constraintName = (attrDecl.getConstraintType() ==
                                          XSConstants.VC_DEFAULT) ?
                                          "default" : "fixed";
              constraintVal = attrDecl.getConstraintValue();
           }
           addAttributeToSchemaComponent(document, schemaDeclDomNode,
                                         attrDecl, constraintName,
                                         constraintVal, null);
        }
View Full Code Here

              constraintVal = attrUse.getConstraintValue();
           }
          
           String requiredVal = (attrUse.getRequired() == true) ? "required" : "optional";
          
           XSAttributeDecl attrDecl = (XSAttributeDecl)
                                                  attrUse.getAttrDeclaration();
           XSComplexTypeDefinition enclosingCTDefn = attrDecl.
                                                  getEnclosingCTDefinition();
           boolean complexTypesIdentical = (enclosingCTDefn == null) ? false : XSTypeHelper.isSchemaTypesIdentical(
                                                                                  complexTypeDecl, enclosingCTDefn);
           // do not add attributes, from the base type. they will be serialized as part of the base type serialization.
           if (complexTypesIdentical) {
View Full Code Here

    //          of structure {element node, attr name/qname, attr value)?
    // REVISIT: pass the proper element node to reportSchemaError
    public void checkNonSchemaAttributes(XSGrammarBucket grammarBucket) {
        // for all attributes
        Iterator entries = fNonSchemaAttrs.entrySet().iterator();
        XSAttributeDecl attrDecl;
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            // get name, uri, localpart
            String attrRName = (String) entry.getKey();
            String attrURI = attrRName.substring(0,attrRName.indexOf(','));
            String attrLocal = attrRName.substring(attrRName.indexOf(',')+1);
            // find associated grammar
            SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI);
            if (sGrammar == null) {
                continue;
            }
            // and get the datatype validator, if there is one
            attrDecl = sGrammar.getGlobalAttributeDecl(attrLocal);
            if (attrDecl == null) {
                continue;
            }
            XSSimpleType dv = (XSSimpleType)attrDecl.getTypeDefinition();
            if (dv == null) {
                continue;
            }

            // get all values appeared with this attribute name
View Full Code Here

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

        String nameAtt    = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
        QName  refAtt     = (QNameattrValues[XSAttributeChecker.ATTIDX_REF];
        XInt   useAtt     = (XInt)   attrValues[XSAttributeChecker.ATTIDX_USE];

        // get 'attribute declaration'
        XSAttributeDecl attribute = null;
        if (attrDecl.getAttributeNode(SchemaSymbols.ATT_REF) != null) {
            if (refAtt != null) {
                attribute = (XSAttributeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ATTRIBUTE_TYPE, refAtt, attrDecl);

                Element child = DOMUtil.getFirstChildElement(attrDecl);
View Full Code Here

                                             SchemaGrammar grammar) {

        // General Attribute Checking
        Object[] attrValues = fAttrChecker.checkAttributes(attrDecl, true, schemaDoc);

        XSAttributeDecl attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, grammar, true);
        fAttrChecker.returnAttrArray(attrValues, schemaDoc);

        if (attribute != null)
            attribute.setIsGlobal();

        return attribute;
    }
View Full Code Here

        XInt    formAtt    = (XInt)   attrValues[XSAttributeChecker.ATTIDX_FORM];
        String  nameAtt    = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
        QName   typeAtt    = (QNameattrValues[XSAttributeChecker.ATTIDX_TYPE];

        // Step 1: get declaration information
        XSAttributeDecl attribute = new XSAttributeDecl();

        // get 'name'
        if (nameAtt != null)
            attribute.fName = fSymbolTable.addSymbol(nameAtt);

        // get 'target namespace'
        if (isGlobal) {
            attribute.fTargetNamespace = schemaDoc.fTargetNamespace;
        }
        else if (formAtt != null) {
            if (formAtt.intValue() == SchemaSymbols.FORM_QUALIFIED)
                attribute.fTargetNamespace = schemaDoc.fTargetNamespace;
            else
                attribute.fTargetNamespace = null;
        } else if (schemaDoc.fAreLocalAttributesQualified) {
            attribute.fTargetNamespace = schemaDoc.fTargetNamespace;
        } else {
            attribute.fTargetNamespace = null;
        }

        // get 'value constraint'
        // for local named attribute, value constraint is absent
        if (isGlobal) {
            if (fixedAtt != null) {
                attribute.fDefault = new ValidatedInfo();
                attribute.fDefault.normalizedValue = fixedAtt;
                attribute.setConstraintType(XSElementDecl.FIXED_VALUE);
            } else if (defaultAtt != null) {
                attribute.fDefault = new ValidatedInfo();
                attribute.fDefault.normalizedValue = defaultAtt;
                attribute.setConstraintType(XSElementDecl.DEFAULT_VALUE);
            } else {
                attribute.setConstraintType(XSElementDecl.NO_CONSTRAINT);
            }
        }

        // get 'annotation'
        Element child = DOMUtil.getFirstChildElement(attrDecl);
View Full Code Here

        String nameAtt    = (String) attrValues[XSAttributeChecker.ATTIDX_NAME];
        QName  refAtt     = (QNameattrValues[XSAttributeChecker.ATTIDX_REF];
        XInt   useAtt     = (XInt)   attrValues[XSAttributeChecker.ATTIDX_USE];
       
        // get 'attribute declaration'
        XSAttributeDecl attribute = null;
        if (attrDecl.getAttributeNode(SchemaSymbols.ATT_REF) != null) {
            if (refAtt != null) {
                attribute = (XSAttributeDecl)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.ATTRIBUTE_TYPE, refAtt, attrDecl);
               
                Element child = DOMUtil.getFirstChildElement(attrDecl);
                if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
                    // REVISIT:  put this somewhere
                    traverseAnnotationDecl(child, attrValues, false, schemaDoc);
                    child = DOMUtil.getNextSiblingElement(child);
                }
               
                if (child != null) {
                    reportSchemaError("src-attribute.3.2", new Object[]{refAtt.rawname}, child);
                }
                // for error reporting
                nameAtt = refAtt.localpart;
            } else {
                attribute = null;
            }
        } else {
            attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, grammar, false, enclosingCT);
        }
       
        // get 'value constraint'
        short consType = XSConstants.VC_NONE;
        if (defaultAtt != null) {
            consType = XSConstants.VC_DEFAULT;
        } else if (fixedAtt != null) {
            consType = XSConstants.VC_FIXED;
            defaultAtt = fixedAtt;
            fixedAtt = null;
        }
       
        XSAttributeUseImpl attrUse = null;
        if (attribute != null) {
            if (fSchemaHandler.fDeclPool !=null) {
                attrUse = fSchemaHandler.fDeclPool.getAttributeUse();
            } else {
                attrUse = new XSAttributeUseImpl();
            }
            attrUse.fAttrDecl = attribute;
            attrUse.fUse = useAtt.shortValue();
            attrUse.fConstraintType = consType;
            if (defaultAtt != null) {
                attrUse.fDefault = new ValidatedInfo();
                attrUse.fDefault.normalizedValue = defaultAtt;
            }
        }
       
        //src-attribute
       
        // 1 default and fixed must not both be present.
        if (defaultAtt != null && fixedAtt != null) {
            reportSchemaError("src-attribute.1", new Object[]{nameAtt}, attrDecl);
        }
       
        // 2 If default and use are both present, use must have the actual value optional.
        if (consType == XSConstants.VC_DEFAULT &&
                useAtt != null && useAtt.intValue() != SchemaSymbols.USE_OPTIONAL) {
            reportSchemaError("src-attribute.2", new Object[]{nameAtt}, attrDecl);
        }
       
        // a-props-correct
       
        if (defaultAtt != null && attrUse != null) {
            // 2 if there is a {value constraint}, the canonical lexical representation of its value must be valid with respect to the {type definition} as defined in String Valid (3.14.4).
            fValidationState.setNamespaceSupport(schemaDoc.fNamespaceSupport);
            try {
                checkDefaultValid(attrUse);
            }
            catch (InvalidDatatypeValueException ide) {
                reportSchemaError (ide.getKey(), ide.getArgs(), attrDecl);
                reportSchemaError ("a-props-correct.2", new Object[]{nameAtt, defaultAtt}, attrDecl);
            }
           
            // 3 If the {type definition} is or is derived from ID then there must not be a {value constraint}.
            if (((XSSimpleType)attribute.getTypeDefinition()).isIDType() ) {
                reportSchemaError ("a-props-correct.3", new Object[]{nameAtt}, attrDecl);
            }
           
            // check 3.5.6 constraint
            // Attribute Use Correct
View Full Code Here

            XSDocumentInfo schemaDoc,
            SchemaGrammar grammar) {
       
        // General Attribute Checking
        Object[] attrValues = fAttrChecker.checkAttributes(attrDecl, true, schemaDoc);
        XSAttributeDecl attribute = traverseNamedAttr(attrDecl, attrValues, schemaDoc, grammar, true, null);
        fAttrChecker.returnAttrArray(attrValues, schemaDoc);
        return attribute;
       
    }
View Full Code Here

TOP

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

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.