Package org.apache.xerces.impl.xs

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


    private void processAnonComplexTypeOnElement(Document document,
                                                 Element elemDeclDomNode,
                                                 XSTypeDefinition typeDef)
                                                 throws DOMException {
      
       XSComplexTypeDecl complexTypeDecl = (XSComplexTypeDecl) typeDef;      
       Element complexTypeDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                            XSD_LANGUAGE_PREFIX +
                                                            "complexType");
       // add annotation to a complex type
       XSAnnotationImpl cmplxTypeAnnotation = (XSAnnotationImpl)
                                            complexTypeDecl.getAnnotations().item(0);
       if (cmplxTypeAnnotation != null) {
          addAnnotationToSchemaComponent(document,
                                         complexTypeDomNode,
                                         cmplxTypeAnnotation);
       }
View Full Code Here


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

                    if (eDecl!=null) {
                      XSTypeDecl type = eDecl.fType;
                      if (type != null) {
                        if (type.getXSType() == XSTypeDecl.COMPLEX_TYPE) {
                          XSComplexTypeDecl ctype = (XSComplexTypeDecl)type;
                          val = ctype.fDatatypeValidator;
                        }
                        else {
                          val = (DatatypeValidator)(type);
                        }
View Full Code Here

        }

        // 2 If the type definition is a complex type definition, then all of the following must be true:
        else {
            // 2.1 its {content type} must be a simple type definition or mixed.
            XSComplexTypeDecl ctype = (XSComplexTypeDecl)element.fType;
            // 2.2 The appropriate case among the following must be true:
            // 2.2.1 If the {content type} is a simple type definition, then the string must be �valid� with respect to that simple type definition as defined by String Valid (�3.14.4).
            if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
                dv = ctype.fDatatypeValidator;
            }
View Full Code Here


        Object[] attrValues = fAttrChecker.checkAttributes(complexTypeNode, false,
                                                           schemaDoc);
        String complexTypeName = genAnonTypeName(complexTypeNode);
        XSComplexTypeDecl type = traverseComplexTypeDecl (complexTypeNode,
                                                          complexTypeName, attrValues, schemaDoc, grammar);
        fAttrChecker.returnAttrArray(attrValues, schemaDoc);

        return type;
    }
View Full Code Here

                                      SchemaGrammar grammar) {

        Object[] attrValues = fAttrChecker.checkAttributes(complexTypeNode, true,
                                                           schemaDoc);
        String complexTypeName = (StringattrValues[XSAttributeChecker.ATTIDX_NAME];
        XSComplexTypeDecl type = traverseComplexTypeDecl (complexTypeNode,
                                                          complexTypeName, attrValues, schemaDoc, grammar);
        grammar.addGlobalTypeDecl(type);
        fAttrChecker.returnAttrArray(attrValues, schemaDoc);

        return type;
View Full Code Here

        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];

        XSComplexTypeDecl complexType = new XSComplexTypeDecl();
        complexType.fName = complexTypeName;
        complexType.fTargetNamespace = schemaDoc.fTargetNamespace;
        complexType.fBlock = blockAtt == null ?
                             schemaDoc.fBlockDefault : blockAtt.shortValue();
        complexType.fFinal = finalAtt == null ?
                             schemaDoc.fFinalDefault : finalAtt.shortValue();
        if (abstractAtt != null && abstractAtt.booleanValue())
            complexType.setIsAbstractType();


        Element child = null;

        try {
            // ---------------------------------------------------------------
            // First, handle any ANNOTATION declaration and get next child
            // ---------------------------------------------------------------
            child = DOMUtil.getFirstChildElement(complexTypeDecl);

            if (child != null) {
                // traverse annotation if any
                if (DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
                    traverseAnnotationDecl(child, attrValues, false, schemaDoc);
                    child = DOMUtil.getNextSiblingElement(child);
                }
                if (child !=null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
                    reportGenericSchemaError("ComplexType "+complexTypeName+" has more than one annotation.");
                }
            }
            // ---------------------------------------------------------------
            // Process the content of the complex type definition
            // ---------------------------------------------------------------
            if (child==null) {
                //
                // EMPTY complexType with complexContent
                //

                // set the base to the anyType
                complexType.fBaseType = SchemaGrammar.fAnyType;
                processComplexContent(child, complexType, mixedAtt.booleanValue(), false,
                                      schemaDoc, grammar);
            }
            else if (DOMUtil.getLocalName(child).equals
                     (SchemaSymbols.ELT_SIMPLECONTENT)) {
                //
                // SIMPLE CONTENT
                //
                traverseSimpleContent(child, complexType, schemaDoc, grammar);
                if (DOMUtil.getNextSiblingElement(child)!=null) {
                    String siblingName = DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(child));
                    throw new ComplexTypeRecoverableError("src-ct",
                                                          new Object[]{complexType.fName,siblingName});
                }
            }
            else if (DOMUtil.getLocalName(child).equals
                     (SchemaSymbols.ELT_COMPLEXCONTENT)) {
                traverseComplexContent(child, complexType, mixedAtt.booleanValue(),
                                       schemaDoc, grammar);
                if (DOMUtil.getNextSiblingElement(child)!=null) {
                    String siblingName = DOMUtil.getLocalName(DOMUtil.getNextSiblingElement(child));
                    throw new ComplexTypeRecoverableError("src-ct",
                                                          new Object[]{complexType.fName,siblingName});
                }
            }
            else {
                //
                // We must have ....
                // GROUP, ALL, SEQUENCE or CHOICE, followed by optional attributes
                // Note that it's possible that only attributes are specified.
                //

                // set the base to the anyType
                complexType.fBaseType = SchemaGrammar.fAnyType;
                processComplexContent(child, complexType, mixedAtt.booleanValue(), false,
                                      schemaDoc, grammar);
            }

        }
        catch (ComplexTypeRecoverableError e) {
            handleComplexTypeError(e.getMessage(),e.errorSubstText, complexType);
        }

        if (DEBUG) {
            System.out.println(complexType.toString());
        }
        return complexType;


    }
View Full Code Here

        typeInfo.fBaseType = type;


        DatatypeValidator baseValidator = null;
        XSComplexTypeDecl baseComplexType = null;
        int baseFinalSet = 0;

        // If the base type is complex, it must have simpleContent
        if ((type instanceof XSComplexTypeDecl)) {
View Full Code Here

            // REVISIT - should create a msg in properties file
            reportGenericSchemaError("ComplexType " + typeName + ": " +
                                     "The base type must be complex");
            throw new ComplexTypeRecoverableError();
        }
        XSComplexTypeDecl baseType = (XSComplexTypeDecl)type;
        typeInfo.fBaseType = baseType;

        // -----------------------------------------------------------------------
        // Check that the base permits the derivation
        // -----------------------------------------------------------------------
View Full Code Here

        if (nameAtt != null)
            nameAtt = fSymbolTable.addSymbol(nameAtt);
       
        // get 'target namespace'
        String tnsAtt = null;
        XSComplexTypeDecl enclCT = null;
        XSObject enclParent = null;
        short scope = XSAttributeDecl.SCOPE_ABSENT;
        if (isGlobal) {
            tnsAtt = schemaDoc.fTargetNamespace;
            scope = XSAttributeDecl.SCOPE_GLOBAL;
        }
        else {
            // For XML 1.0, we only store information about enclosing complex types
            // For XML 1.1, we store information about enclosing complex types or attribute groups
            if (enclosingParent != null) {
                if (enclosingParent instanceof XSComplexTypeDecl) {
                    enclCT = (XSComplexTypeDecl) enclosingParent;
                    enclParent = enclosingParent;
                    scope = XSAttributeDecl.SCOPE_LOCAL;
                }
                else if (fSchemaHandler.fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
                    enclParent = enclosingParent;
                    scope = XSAttributeDecl.SCOPE_LOCAL;
                }
            }
            if (targetNsAtt != null) {
                // XML Schema 1.1, set the target namespace to be the value of the targetNamespace attribute if one is defined
                tnsAtt = fSymbolTable.addSymbol(targetNsAtt);
            } else if (formAtt != null) {
                if (formAtt.intValue() == SchemaSymbols.FORM_QUALIFIED)
                    tnsAtt = schemaDoc.fTargetNamespace;
            } else if (schemaDoc.fAreLocalAttributesQualified) {
                tnsAtt = schemaDoc.fTargetNamespace;
            }
        }
        // get 'value constraint'
        // for local named attribute, value constraint is absent
        ValidatedInfo attDefault = null;
        short constraintType = XSConstants.VC_NONE;
        if (isGlobal) {
            if (fixedAtt != null) {
                attDefault = new ValidatedInfo();
                attDefault.normalizedValue = fixedAtt;
                constraintType = XSConstants.VC_FIXED;
            } else if (defaultAtt != null) {
                attDefault = new ValidatedInfo();
                attDefault.normalizedValue = defaultAtt;
                constraintType = XSConstants.VC_DEFAULT;
            }
        }
       
        // get 'annotation'
        Element child = DOMUtil.getFirstChildElement(attrDecl);
        XSAnnotationImpl annotation = null;
        if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) {
            annotation = traverseAnnotationDecl(child, attrValues, false, schemaDoc);
            child = DOMUtil.getNextSiblingElement(child);
        }
        else {
            String text = DOMUtil.getSyntheticAnnotation(attrDecl);
            if (text != null) {
                annotation = traverseSyntheticAnnotation(attrDecl, text, attrValues, false, schemaDoc);
            }
        }
       
        // get 'type definition'
        XSSimpleType attrType = null;
        boolean haveAnonType = false;
       
        // Handle Anonymous type if there is one
        if (child != null) {
            String childName = DOMUtil.getLocalName(child);
           
            if (childName.equals(SchemaSymbols.ELT_SIMPLETYPE)) {
                attrType = fSchemaHandler.fSimpleTypeTraverser.traverseLocal(child, schemaDoc, grammar, attribute);
                haveAnonType = true;
                child = DOMUtil.getNextSiblingElement(child);
            }
        }
       
        // Handle type attribute
        if (attrType == null && typeAtt != null) {
            XSTypeDefinition type = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, typeAtt, attrDecl);
            if (type != null && type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
                attrType = (XSSimpleType)type;
            }
            else {
                reportSchemaError("src-resolve", new Object[]{typeAtt.rawname, "simpleType definition"}, attrDecl);
                if (type == null) {
                  attribute.fUnresolvedTypeName = typeAtt;
                }
            }
        }
       
        if (attrType == null) {
            attrType = SchemaGrammar.fAnySimpleType;
        }
       
        XSObjectList annotations;
        if (annotation != null) {
            annotations = new XSObjectListImpl();
            ((XSObjectListImpl)annotations).addXSObject(annotation);
        } else {
            annotations = XSObjectListImpl.EMPTY_LIST;
        }
       
        boolean inheritable = false;
        if (inheritableAtt != null) {
          inheritable = inheritableAtt.booleanValue();  
        }
       
        attribute.setValues(nameAtt, tnsAtt, attrType, constraintType, scope,
                attDefault, enclParent, annotations, inheritable);
       
        // Step 3: check against schema for schemas
       
        // required attributes
        if (nameAtt == null) {
            if (isGlobal)
                reportSchemaError("s4s-att-must-appear", new Object[]{SchemaSymbols.ELT_ATTRIBUTE, SchemaSymbols.ATT_NAME}, attrDecl);
            else
                reportSchemaError("src-attribute.3.1", null, attrDecl);
            nameAtt = NO_NAME;
        }
       
        // element
        if (child != null) {
            reportSchemaError("s4s-elt-must-match.1", new Object[]{nameAtt, "(annotation?, (simpleType?))", DOMUtil.getLocalName(child)}, child);
        }
       
        // Step 4: check 3.2.3 constraints
       
        // 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.
        // This is checked in "traverse" method
       
        // 3 If the item's parent is not <schema>, then all of the following must be true:
        // 3.1 One of ref or name must be present, but not both.
        // This is checked in XSAttributeChecker
       
        // 3.2 If ref is present, then all of <simpleType>, form and type must be absent.
        // Attributes are checked in XSAttributeChecker, elements are checked in "traverse" method
       
        // 4 type and <simpleType> must not both be present.
        if (haveAnonType && (typeAtt != null)) {
            reportSchemaError( "src-attribute.4", new Object[]{nameAtt}, attrDecl);
        }
       
        // Step 5: check 3.2.6 constraints
        // check for NOTATION type
        checkNotationType(nameAtt, attrType, attrDecl);
       
        // 6 If the targetNamespace attribute is present then all of the following must be true:        
        if (targetNsAtt != null) {
            // 6.2 The form attribute must not be present.
            if (formAtt != null) {
                reportSchemaError ("src-attribute.6.2", new Object[] {nameAtt}, attrDecl);               
            }
            // 6.3 If the ancestor <schema> does not have a targetNamespace [attribute] or its 'actual value' is different from the 'actual value' of targetNamespace of <attribute>:
            String schemaTns = schemaDoc.fTargetNamespace;
            if (schemaTns==null || tnsAtt!=schemaTns) {
                // 6.3.1 <attribute> must have <complexType> as an ancestor
                if (enclCT == null) {
                    reportSchemaError ("src-attribute.6.3.1", new Object[] {nameAtt}, attrDecl);
                }
                // 6.3.2 There must be a <restriction> ancestor between the <attribute> and the nearest <complexType> ancestor, and the 'actual value' of the base [attribute] of <restriction> does not 'match' the name of 'xs:anyType'.
                else if ((enclCT.getDerivationMethod() != XSConstants.DERIVATION_RESTRICTION) || enclCT.getBaseType() == SchemaGrammar.getXSAnyType(fSchemaHandler.fSchemaVersion)) {
                    reportSchemaError ("src-attribute.6.3.2", new Object[] {nameAtt}, attrDecl);
                }
            }
        }
       
View Full Code Here

TOP

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

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.