Package org.apache.xerces.impl.dv

Examples of org.apache.xerces.impl.dv.XSSimpleType


        if (type==null)
            throw new ComplexTypeRecoverableError();

        typeInfo.fBaseType = type;

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

        // If the base type is complex, it must have simpleContent
        if ((type.getXSType() == XSTypeDecl.COMPLEX_TYPE)) {

            baseComplexType = (XSComplexTypeDecl)type;
            if (baseComplexType.fContentType != XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
                throw new ComplexTypeRecoverableError("src-ct.2",
                                new Object[]{typeInfo.fName});
            }
            baseFinalSet = baseComplexType.fFinal;
            baseValidator = baseComplexType.fXSSimpleType;
        }
        else {
            baseValidator = (XSSimpleType)type;
            if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {
                throw new ComplexTypeRecoverableError("src-ct.2",
                                new Object[]{typeInfo.fName});
            }
            baseFinalSet=baseValidator.getFinalSet();
        }

        // -----------------------------------------------------------------------
        // Check that the base permits the derivation
        // -----------------------------------------------------------------------
        if ((baseFinalSet & typeInfo.fDerivedBy)!=0) {
            String errorKey = (typeInfo.fDerivedBy==SchemaSymbols.EXTENSION) ?
                              "cos-ct-extends.1.1" : "derivation-ok-restriction.1";
            throw new ComplexTypeRecoverableError(errorKey,
                                new Object[]{typeInfo.fName});
        }

        // -----------------------------------------------------------------------
        // Skip over any potential annotations
        // -----------------------------------------------------------------------
        simpleContent = DOMUtil.getFirstChildElement(simpleContent);
        if (simpleContent != null) {
            // traverse annotation if any

            if (DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)) {
                traverseAnnotationDecl(simpleContent, null, false, schemaDoc);
                simpleContent = DOMUtil.getNextSiblingElement(simpleContent);
            }

            if (simpleContent !=null &&
                DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_ANNOTATION)){
                throw new ComplexTypeRecoverableError("src-ct.0.1",
                       new Object[]{typeName,SchemaSymbols.ELT_ANNOTATION});
            }
        }

        // -----------------------------------------------------------------------
        // Process a RESTRICTION
        // -----------------------------------------------------------------------
        if (typeInfo.fDerivedBy == SchemaSymbols.RESTRICTION) {

            // -----------------------------------------------------------------------
            // There may be a simple type definition in the restriction element
            // The data type validator will be based on it, if specified
            // -----------------------------------------------------------------------
            if (simpleContent !=null &&
            DOMUtil.getLocalName(simpleContent).equals(SchemaSymbols.ELT_SIMPLETYPE )) {

                XSSimpleType dv = fSchemaHandler.fSimpleTypeTraverser.traverseLocal(
                      simpleContent, schemaDoc, grammar);
                if (dv == null)
                    throw new ComplexTypeRecoverableError();

                //check that this datatype validator is validly derived from the base
View Full Code Here


            return false;
        }

        // 2.2 One of the following must be true:
        // 2.2.1 D's base type definition is B.
        XSSimpleType directBase = (XSSimpleType)derived.getBaseType();
        if (directBase == base)
            return true;

        // 2.2.2 D's base type definition is not the simple ur-type definition and is validly derived from B given the subset, as defined by this constraint.
        if (directBase != SchemaGrammar.fAnySimpleType &&
View Full Code Here

     * returns the compiled form of the value
     * The parameter value could be either a String or a ValidatedInfo object
     */
    public static Object ElementDefaultValidImmediate(XSTypeDecl type, Object value, ValidationContext context, ValidatedInfo vinfo) {

        XSSimpleType dv = null;

        // e-props-correct
        // For a string to be a valid default with respect to a type definition the appropriate case among the following must be true:
        // 1 If the type definition is a simple type definition, then the string must be valid with respect to that definition as defined by String Valid (3.14.4).
        if (type.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
            dv = (XSSimpleType)type;
        }

        // 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)type;
            // 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.fXSSimpleType;
            }
            // 2.2.2 If the {content type} is mixed, then the {content type}'s particle must be emptiable as defined by Particle Emptiable (3.9.6).
            else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
                if (!ctype.fParticle.emptiable())
                    return null;
            }
            else {
                return null;
            }
        }

        // get the simple type declaration, and validate
        Object actualValue = null;
        if (dv != null) {
            try {
                if (value instanceof String) {
                    actualValue = dv.validate((String)value, context, vinfo);
                } else {
                    ValidatedInfo info = (ValidatedInfo)value;
                    dv.validate(context, info);
                    actualValue = info.actualValue;
                }
            } catch (InvalidDatatypeValueException ide) {
                return null;
            }
View Full Code Here

            throw new XMLSchemaException("rcase-NameAndTypeOK.4",
                                      new Object[]{dElement.fName});
         }

         // get simple type
         XSSimpleType dv = null;
         if (dElement.fType.getXSType() == XSTypeDecl.SIMPLE_TYPE)
            dv = (XSSimpleType)dElement.fType;
         else if (((XSComplexTypeDecl)dElement.fType).fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE)
            dv = ((XSComplexTypeDecl)dElement.fType).fXSSimpleType;

         // if there is no simple type, then compare based on string
         if (dv == null && !bElement.fDefault.normalizedValue.equals(dElement.fDefault.normalizedValue) ||
             dv != null && !dv.isEqual(bElement.fDefault.actualValue, dElement.fDefault.actualValue)) {
            throw new XMLSchemaException("rcase-NameAndTypeOK.4",
                                      new Object[]{dElement.fName});
         }
      }
View Full Code Here

            // For an attribute information item to be locally valid with respect to an attribute declaration all of the following must be true:
            // 1 The declaration must not be absent (see Missing Sub-components (5.3) for how this can fail to be the case).
            // 2 Its {type definition} must not be absent.
            // 3 The item's normalized value must be locally valid with respect to that {type definition} as per String Valid (3.14.4).
            // get simple type
            XSSimpleType attDV = currDecl.fType;

            // PSVI: attribute declaration
            attrPSVI.fDeclaration = currDecl;
            // PSVI: attribute type
            attrPSVI.fTypeDecl = attDV;

            // PSVI: validation attempted:
            attrPSVI.fValidationAttempted = AttributePSVI.FULL_VALIDATION;

            // needed to update type for DOM Parser to implement getElementById
            if (attributes.getType(index).equals("CDATA")) {
                String type = (currDecl.fType.isIDType())?"ID":"CDATA";
                attributes.setType(index, type);
            }

            // get attribute value
            String attrValue = attributes.getValue(index);

            Object actualValue = null;
            try {
                actualValue = attDV.validate(attrValue, fValidationState, fValidatedInfo);
                // PSVI: attribute normalized value
                attrPSVI.fNormalizedValue = fValidatedInfo.normalizedValue;
                // PSVI: attribute memberType
                attrPSVI.fMemberType = fValidatedInfo.memberType;
                // PSVI: element notation
                if (attDV.isNOTATIONType()){
                   QName qName = (QName)actualValue;
                   SchemaGrammar grammar = fGrammarResolver.getGrammar(qName.uri);
                   if (grammar != null)
                       fCurrentPSVI.fNotation = grammar.getNotationDecl(qName.localpart);
                }
            }
            catch (InvalidDatatypeValueException idve) {

                // PSVI: attribute is invalid, record errors
                attrPSVI.fValidity = AttributePSVI.INVALID_VALIDITY;
                attrPSVI.addErrorCode("cvc-attribute.3");
                reportSchemaError("cvc-attribute.3", new Object[]{element.rawname, fTempQName.rawname, attrValue});
            }

            // get the value constraint from use or decl
            // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed.                 // now check the value against the simpleType
            if (actualValue != null &&
                currDecl.getConstraintType() == XSAttributeDecl.FIXED_VALUE) {
                if (!attDV.isEqual(actualValue, currDecl.fDefault.actualValue)){

                    // PSVI: attribute is invalid, record errors
                    attrPSVI.fValidity = AttributePSVI.INVALID_VALIDITY;
                    attrPSVI.addErrorCode("cvc-attribute.4");
                    reportSchemaError("cvc-attribute.4", new Object[]{element.rawname, fTempQName.rawname, attrValue});
                }
            }

            // 3.1 If there is among the {attribute uses} an attribute use with an {attribute declaration} whose {name} matches the attribute information item's [local name] and whose {target namespace} is identical to the attribute information item's [namespace name] (where an absent {target namespace} is taken to be identical to a [namespace name] with no value), then the attribute information must be valid with respect to that attribute use as per Attribute Locally Valid (Use) (3.5.4). In this case the {attribute declaration} of that attribute use is the context-determined declaration for the attribute information item with respect to Schema-Validity Assessment (Attribute) (3.2.4) and Assessment Outcome (Attribute) (3.2.5).
            if (actualValue != null &&
                currUse != null && currUse.fConstraintType == XSAttributeDecl.FIXED_VALUE) {
                if (!attDV.isEqual(actualValue, currUse.fDefault.actualValue)){
                    // PSVI: attribute is invalid, record errors
                    attrPSVI.fValidity = AttributePSVI.INVALID_VALIDITY;
                    attrPSVI.addErrorCode("cvc-complex-type.3.1");
                    reportSchemaError("cvc-complex-type.3.1", new Object[]{element.rawname, fTempQName.rawname, attrValue});
                }
View Full Code Here

                                !ctype.fXSSimpleType.isEqual(actualValue, fCurrentElemDecl.fDefault.actualValue))
                                reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
                        }
                    }
                    else if (fCurrentType.getXSType() == XSTypeDecl.SIMPLE_TYPE) {
                        XSSimpleType sType = (XSSimpleType)fCurrentType;
                        if (!sType.isEqual(actualValue, fCurrentElemDecl.fDefault.actualValue))
                            reportSchemaError("cvc-elt.5.2.2.2.2", new Object[]{element.rawname, content, fCurrentElemDecl.fDefault.normalizedValue});
                    }
                }
            }
        } // if fDoValidation
View Full Code Here

            // 3.1.2 The element information item must have no element information item [children].
            if (fChildCount != 0)
                reportSchemaError("cvc-type.3.1.2", new Object[]{element.rawname});
            // 3.1.3 If clause 3.2 of Element Locally Valid (Element) (3.3.4) did not apply, then the normalized value must be valid with respect to the type definition as defined by String Valid (3.14.4).
            if (!fNil) {
                XSSimpleType dv = (XSSimpleType)fCurrentType;
                try {
                    retValue = dv.validate(textContent, fValidationState, fValidatedInfo);
                    // PSVI: schema normalized value
                    //
                    fCurrentPSVI.fNormalizedValue = fValidatedInfo.normalizedValue;
                    // PSVI: memberType
                    fCurrentPSVI.fMemberType = fValidatedInfo.memberType;
View Full Code Here

            }
            // 2.2 If the {content type} is a simple type definition, then the element information item has no element information item [children], and the normalized value of the element information item is valid with respect to that simple type definition as defined by String Valid (3.14.4).
            else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
                if (fChildCount != 0)
                    reportSchemaError("cvc-complex-type.2.2", new Object[]{element.rawname});
                XSSimpleType dv = ctype.fXSSimpleType;
                try {
                    actualValue = dv.validate(textContent, fValidationState, fValidatedInfo);

                    // PSVI: schema normalized value
                    //
                    fCurrentPSVI.fNormalizedValue = fValidatedInfo.normalizedValue;
                    // PSVI: memberType
View Full Code Here

                // xpath values are validated in xpath parser
                if (oneAttr.dvIndex >= 0) {
                    if (oneAttr.dvIndex != DT_STRING &&
                        oneAttr.dvIndex != DT_XPATH &&
                        oneAttr.dvIndex != DT_XPATH1) {
                        XSSimpleType dv = fExtraDVs[oneAttr.dvIndex];
                        Object avalue = dv.validate(attrVal, schemaDoc.fValidationContext, null);
                        // kludge to handle chameleon includes/redefines...
                        if (oneAttr.dvIndex == DT_QNAME) {
                            QName qname = (QName)avalue;
                            if(qname.prefix == fSchemaHandler.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema)
                                qname.uri = schemaDoc.fTargetNamespace;
View Full Code Here

   
                // 4 attributes, so initialize the size as 4*2 = 8
                fGlobalAttrDecls  = new SymbolHash(8);
                String name = null;
                String tns = null;
                XSSimpleType type = null;
                short scope = XSConstants.SCOPE_GLOBAL;
               
                // xsi:type
                name = SchemaSymbols.XSI_TYPE;
                tns = SchemaSymbols.URI_XSI;
                type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_QNAME);
                fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
               
                // xsi:nil
                name = SchemaSymbols.XSI_NIL;
                tns = SchemaSymbols.URI_XSI;
                type = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_BOOLEAN);
                fGlobalAttrDecls.put(name, new BuiltinAttrDecl(name, tns, type, scope));
               
                XSSimpleType anyURI = schemaFactory.getBuiltInType(SchemaSymbols.ATTVAL_ANYURI);
   
                // xsi:schemaLocation
                name = SchemaSymbols.XSI_SCHEMALOCATION;
                tns = SchemaSymbols.URI_XSI;
                type = schemaFactory.createTypeList(null, SchemaSymbols.URI_XSI, (short)0, anyURI, null);
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.dv.XSSimpleType

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.