com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XSDAbstractTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private boolean containsQName(XSSimpleType type) {
    if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) {
        short primitive = type.getPrimitiveKind();
        return (primitive == XSSimpleType.PRIMITIVE_QNAME ||
                primitive == XSSimpleType.PRIMITIVE_NOTATION);
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_LIST) {
        return containsQName((XSSimpleType)type.getItemType());
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_UNION) {
        XSObjectList members = type.getMemberTypes();
        for (int i = 0; i < members.getLength(); i++) {
            if (containsQName((XSSimpleType)members.item(i)))
                return true;
        }
    }
    return false;
}
 
Example #2
Source File: XSDComplexTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void contentRestore() {
    fAnnotations = (XSAnnotationImpl [])fGlobalStore[--fGlobalStorePos];
    fXSSimpleType = (XSSimpleType)fGlobalStore[--fGlobalStorePos];
    fParticle = (XSParticleDecl)fGlobalStore[--fGlobalStorePos];
    fAttrGrp = (XSAttributeGroupDecl)fGlobalStore[--fGlobalStorePos];
    fBaseType = (XSTypeDefinition)fGlobalStore[--fGlobalStorePos];
    int i = ((Integer)(fGlobalStore[--fGlobalStorePos])).intValue();
    fBlock = (short)(i >> 16);
    fContentType = (short)i;
    i = ((Integer)(fGlobalStore[--fGlobalStorePos])).intValue();
    fDerivedBy = (short)(i >> 16);
    fFinal = (short)i;
    fTargetNamespace = (String)fGlobalStore[--fGlobalStorePos];
    fName = (String)fGlobalStore[--fGlobalStorePos];
    fIsAbstract = ((Boolean)fGlobalStore[--fGlobalStorePos]).booleanValue();
    fComplexTypeDecl = (XSComplexTypeDecl)fGlobalStore[--fGlobalStorePos];
}
 
Example #3
Source File: XSDAbstractTraverser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private boolean containsQName(XSSimpleType type) {
    if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) {
        short primitive = type.getPrimitiveKind();
        return (primitive == XSSimpleType.PRIMITIVE_QNAME ||
                primitive == XSSimpleType.PRIMITIVE_NOTATION);
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_LIST) {
        return containsQName((XSSimpleType)type.getItemType());
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_UNION) {
        XSObjectList members = type.getMemberTypes();
        for (int i = 0; i < members.getLength(); i++) {
            if (containsQName((XSSimpleType)members.item(i)))
                return true;
        }
    }
    return false;
}
 
Example #4
Source File: XSComplexTypeDecl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void setValues(String name, String targetNamespace,
         XSTypeDefinition baseType, short derivedBy, short schemaFinal,
         short block, short contentType,
         boolean isAbstract, XSAttributeGroupDecl attrGrp,
         XSSimpleType simpleType, XSParticleDecl particle,
         XSObjectListImpl annotations) {
     fTargetNamespace = targetNamespace;
     fBaseType = baseType;
     fDerivedBy = derivedBy;
     fFinal = schemaFinal;
     fBlock = block;
     fContentType = contentType;
     if(isAbstract)
         fMiscFlags |= CT_IS_ABSTRACT;
     fAttrGrp = attrGrp;
     fXSSimpleType = simpleType;
     fParticle = particle;
     fAnnotations = annotations;
}
 
Example #5
Source File: DOMResultAugmentor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example #6
Source File: DOMResultAugmentor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example #7
Source File: ExtendedSchemaDVFactoryImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
static void createBuiltInTypes() {
    final String ANYATOMICTYPE     = "anyAtomicType";
    final String DURATION          = "duration";
    final String YEARMONTHDURATION = "yearMonthDuration";
    final String DAYTIMEDURATION   = "dayTimeDuration";

    createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);

    // add anyAtomicType
    fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);

    // add 2 duration types
    XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
    fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
    fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
}
 
Example #8
Source File: XSConstraints.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * check whether simple type derived is valid derived from base,
 * given a subset of {restriction, extension}.
 */
public static boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) {
    // if derived is anySimpleType, then it's valid only if the base
    // is ur-type
    if (derived == SchemaGrammar.fAnySimpleType) {
        return (base == SchemaGrammar.fAnyType ||
                base == SchemaGrammar.fAnySimpleType);
    }

    // if base is complex type
    if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
        // if base is anyType, change base to anySimpleType,
        // otherwise, not valid
        if (base == SchemaGrammar.fAnyType)
            base = SchemaGrammar.fAnySimpleType;
        else
            return false;
    }
    return checkSimpleDerivation((XSSimpleType)derived,
            (XSSimpleType)base, block);
}
 
Example #9
Source File: ExtendedSchemaDVFactoryImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void createBuiltInTypes() {
    final String ANYATOMICTYPE     = "anyAtomicType";
    final String DURATION          = "duration";
    final String YEARMONTHDURATION = "yearMonthDuration";
    final String DAYTIMEDURATION   = "dayTimeDuration";

    createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);

    // add anyAtomicType
    fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);

    // add 2 duration types
    XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
    fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
    fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
}
 
Example #10
Source File: XSDAbstractTraverser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private boolean containsQName(XSSimpleType type) {
    if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) {
        short primitive = type.getPrimitiveKind();
        return (primitive == XSSimpleType.PRIMITIVE_QNAME ||
                primitive == XSSimpleType.PRIMITIVE_NOTATION);
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_LIST) {
        return containsQName((XSSimpleType)type.getItemType());
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_UNION) {
        XSObjectList members = type.getMemberTypes();
        for (int i = 0; i < members.getLength(); i++) {
            if (containsQName((XSSimpleType)members.item(i)))
                return true;
        }
    }
    return false;
}
 
Example #11
Source File: XSComplexTypeDecl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void setValues(String name, String targetNamespace,
         XSTypeDefinition baseType, short derivedBy, short schemaFinal,
         short block, short contentType,
         boolean isAbstract, XSAttributeGroupDecl attrGrp,
         XSSimpleType simpleType, XSParticleDecl particle,
         XSObjectListImpl annotations) {
     fTargetNamespace = targetNamespace;
     fBaseType = baseType;
     fDerivedBy = derivedBy;
     fFinal = schemaFinal;
     fBlock = block;
     fContentType = contentType;
     if(isAbstract)
         fMiscFlags |= CT_IS_ABSTRACT;
     fAttrGrp = attrGrp;
     fXSSimpleType = simpleType;
     fParticle = particle;
     fAnnotations = annotations;
}
 
Example #12
Source File: ExtendedSchemaDVFactoryImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void createBuiltInTypes() {
    final String ANYATOMICTYPE     = "anyAtomicType";
    final String DURATION          = "duration";
    final String YEARMONTHDURATION = "yearMonthDuration";
    final String DAYTIMEDURATION   = "dayTimeDuration";

    createBuiltInTypes(fBuiltInTypes, XSSimpleTypeDecl.fAnyAtomicType);

    // add anyAtomicType
    fBuiltInTypes.put(ANYATOMICTYPE, XSSimpleTypeDecl.fAnyAtomicType);

    // add 2 duration types
    XSSimpleTypeDecl durationDV = (XSSimpleTypeDecl)fBuiltInTypes.get(DURATION);
    fBuiltInTypes.put(YEARMONTHDURATION, new XSSimpleTypeDecl(durationDV, YEARMONTHDURATION, XSSimpleTypeDecl.DV_YEARMONTHDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.YEARMONTHDURATION_DT));
    fBuiltInTypes.put(DAYTIMEDURATION, new XSSimpleTypeDecl(durationDV, DAYTIMEDURATION, XSSimpleTypeDecl.DV_DAYTIMEDURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSSimpleTypeDecl.DAYTIMEDURATION_DT));
}
 
Example #13
Source File: XSDAbstractTraverser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private boolean containsQName(XSSimpleType type) {
    if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) {
        short primitive = type.getPrimitiveKind();
        return (primitive == XSSimpleType.PRIMITIVE_QNAME ||
                primitive == XSSimpleType.PRIMITIVE_NOTATION);
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_LIST) {
        return containsQName((XSSimpleType)type.getItemType());
    }
    else if (type.getVariety() == XSSimpleType.VARIETY_UNION) {
        XSObjectList members = type.getMemberTypes();
        for (int i = 0; i < members.getLength(); i++) {
            if (containsQName((XSSimpleType)members.item(i)))
                return true;
        }
    }
    return false;
}
 
Example #14
Source File: XSSimpleTypeDecl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void setNumeric(){
    if(fVariety == VARIETY_ATOMIC){
        this.fNumeric = fBase.fNumeric;
    }
    else if(fVariety == VARIETY_LIST){
        this.fNumeric = false;
    }
    else if(fVariety == VARIETY_UNION){
        XSSimpleType[] memberTypes = fMemberTypes;
        for(int i = 0 ; i < memberTypes.length ; i++){
            if(!memberTypes[i].getNumeric() ){
                this.fNumeric = false;
                return;
            }
        }
        this.fNumeric = true;
    }

}
 
Example #15
Source File: XSSimpleTypeDecl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void setNumeric(){
    if(fVariety == VARIETY_ATOMIC){
        this.fNumeric = fBase.fNumeric;
    }
    else if(fVariety == VARIETY_LIST){
        this.fNumeric = false;
    }
    else if(fVariety == VARIETY_UNION){
        XSSimpleType[] memberTypes = fMemberTypes;
        for(int i = 0 ; i < memberTypes.length ; i++){
            if(!memberTypes[i].getNumeric() ){
                this.fNumeric = false;
                return;
            }
        }
        this.fNumeric = true;
    }

}
 
Example #16
Source File: XSDComplexTypeTraverser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void contentRestore() {
    fAnnotations = (XSAnnotationImpl [])fGlobalStore[--fGlobalStorePos];
    fXSSimpleType = (XSSimpleType)fGlobalStore[--fGlobalStorePos];
    fParticle = (XSParticleDecl)fGlobalStore[--fGlobalStorePos];
    fAttrGrp = (XSAttributeGroupDecl)fGlobalStore[--fGlobalStorePos];
    fBaseType = (XSTypeDefinition)fGlobalStore[--fGlobalStorePos];
    int i = ((Integer)(fGlobalStore[--fGlobalStorePos])).intValue();
    fBlock = (short)(i >> 16);
    fContentType = (short)i;
    i = ((Integer)(fGlobalStore[--fGlobalStorePos])).intValue();
    fDerivedBy = (short)(i >> 16);
    fFinal = (short)i;
    fTargetNamespace = (String)fGlobalStore[--fGlobalStorePos];
    fName = (String)fGlobalStore[--fGlobalStorePos];
    fIsAbstract = ((Boolean)fGlobalStore[--fGlobalStorePos]).booleanValue();
    fComplexTypeDecl = (XSComplexTypeDecl)fGlobalStore[--fGlobalStorePos];
}
 
Example #17
Source File: XSConstraints.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * check whether simple type derived is valid derived from base,
 * given a subset of {restriction, extension}.
 */
public static boolean checkSimpleDerivationOk(XSSimpleType derived, XSTypeDefinition base, short block) {
    // if derived is anySimpleType, then it's valid only if the base
    // is ur-type
    if (derived == SchemaGrammar.fAnySimpleType) {
        return (base == SchemaGrammar.fAnyType ||
                base == SchemaGrammar.fAnySimpleType);
    }

    // if base is complex type
    if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
        // if base is anyType, change base to anySimpleType,
        // otherwise, not valid
        if (base == SchemaGrammar.fAnyType)
            base = SchemaGrammar.fAnySimpleType;
        else
            return false;
    }
    return checkSimpleDerivation((XSSimpleType)derived,
            (XSSimpleType)base, block);
}
 
Example #18
Source File: XSDSimpleTypeTraverser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private XSSimpleType traverseSimpleTypeDecl(Element simpleTypeDecl,
        Object[] attrValues,
        XSDocumentInfo schemaDoc,
        SchemaGrammar grammar) {

    // get name and final values
    String name = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
    return getSimpleType(name, simpleTypeDecl, attrValues, schemaDoc, grammar);
}
 
Example #19
Source File: ShortHandPointer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}
 
Example #20
Source File: XSDSimpleTypeTraverser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
XSSimpleType traverseLocal(Element elmNode,
        XSDocumentInfo schemaDoc,
        SchemaGrammar grammar) {

    // General Attribute Checking
    Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc);
    String name = genAnonTypeName(elmNode);
    XSSimpleType type = getSimpleType (name, elmNode, attrValues, schemaDoc, grammar);
    if (type instanceof XSSimpleTypeDecl) {
        ((XSSimpleTypeDecl)type).setAnonymous(true);
    }
    fAttrChecker.returnAttrArray(attrValues, schemaDoc);

    return type;
}
 
Example #21
Source File: XSDSimpleTypeTraverser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private XSSimpleType traverseSimpleTypeDecl(Element simpleTypeDecl,
        Object[] attrValues,
        XSDocumentInfo schemaDoc,
        SchemaGrammar grammar) {

    // get name and final values
    String name = (String)attrValues[XSAttributeChecker.ATTIDX_NAME];
    return getSimpleType(name, simpleTypeDecl, attrValues, schemaDoc, grammar);
}
 
Example #22
Source File: XMLSchemaValidator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
Object elementLocallyValidType(QName element, Object textContent) {
    if (fCurrentType == null)
        return null;

    Object retValue = null;
    // Element Locally Valid (Type)
    // 3 The appropriate case among the following must be true:
    // 3.1 If the type definition is a simple type definition, then all of the following must be true:
    if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
        // 3.1.2 The element information item must have no element information item [children].
        if (fSubElement)
            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 {
                if (!fNormalizeData || fUnionType) {
                    fValidationState.setNormalizationRequired(true);
                }
                retValue = dv.validate(textContent, fValidationState, fValidatedInfo);
            } catch (InvalidDatatypeValueException e) {
                reportSchemaError(e.getKey(), e.getArgs());
                reportSchemaError(
                    "cvc-type.3.1.3",
                    new Object[] { element.rawname, textContent });
            }
        }
    } else {
        // 3.2 If the type definition is a complex type definition, then the element information item must be valid with respect to the type definition as per Element Locally Valid (Complex Type) (3.4.4);
        retValue = elementLocallyValidComplexType(element, textContent);
    }

    return retValue;
}
 
Example #23
Source File: XSConstraints.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * check whether derived is valid derived from base, given a subset
 * of {restriction, extension}.B
 */
public static boolean checkTypeDerivationOk(XSTypeDefinition derived, XSTypeDefinition base, short block) {
    // if derived is anyType, then it's valid only if base is anyType too
    if (derived == SchemaGrammar.fAnyType)
        return derived == base;
    // if derived is anySimpleType, then it's valid only if the base
    // is ur-type
    if (derived == SchemaGrammar.fAnySimpleType) {
        return (base == SchemaGrammar.fAnyType ||
                base == SchemaGrammar.fAnySimpleType);
    }

    // if derived is simple type
    if (derived.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
        // if base is complex type
        if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            // if base is anyType, change base to anySimpleType,
            // otherwise, not valid
            if (base == SchemaGrammar.fAnyType)
                base = SchemaGrammar.fAnySimpleType;
            else
                return false;
        }
        return checkSimpleDerivation((XSSimpleType)derived,
                (XSSimpleType)base, block);
    }
    else {
        return checkComplexDerivation((XSComplexTypeDecl)derived, base, block);
    }
}
 
Example #24
Source File: XSDAbstractTraverser.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Element/Attribute traversers call this method to check whether
 * the type is NOTATION without enumeration facet
 */
void checkNotationType(String refName, XSTypeDefinition typeDecl, Element elem) {
    if (typeDecl.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE &&
            ((XSSimpleType)typeDecl).getVariety() == XSSimpleType.VARIETY_ATOMIC &&
            ((XSSimpleType)typeDecl).getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) {
        if ((((XSSimpleType)typeDecl).getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0) {
            reportSchemaError("enumeration-required-notation", new Object[]{typeDecl.getName(), refName, DOMUtil.getLocalName(elem)}, elem);
        }
    }
}
 
Example #25
Source File: XSSimpleTypeDecl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkExtraRules(ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {

        Object ob = validatedInfo.actualValue;

        if (fVariety == VARIETY_ATOMIC) {

            fDVs[fValidationDV].checkExtraRules(ob, context);

        } else if (fVariety == VARIETY_LIST) {

            ListDV.ListData values = (ListDV.ListData)ob;
            XSSimpleType memberType = validatedInfo.memberType;
            int len = values.getLength();
            try {
                if (fItemType.fVariety == VARIETY_UNION) {
                    XSSimpleTypeDecl[] memberTypes = (XSSimpleTypeDecl[])validatedInfo.memberTypes;
                    for (int i = len-1; i >= 0; i--) {
                        validatedInfo.actualValue = values.item(i);
                        validatedInfo.memberType = memberTypes[i];
                        fItemType.checkExtraRules(context, validatedInfo);
                    }
                } else { // (fVariety == VARIETY_ATOMIC)
                    for (int i = len-1; i >= 0; i--) {
                        validatedInfo.actualValue = values.item(i);
                        fItemType.checkExtraRules(context, validatedInfo);
                    }
                }
            }
            finally {
                validatedInfo.actualValue = values;
                validatedInfo.memberType = memberType;
            }

        } else { // (fVariety == VARIETY_UNION)

            ((XSSimpleTypeDecl)validatedInfo.memberType).checkExtraRules(context, validatedInfo);

        }

    }
 
Example #26
Source File: SchemaGrammar.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void setValues(String name, String targetNamespace,
        XSTypeDefinition baseType, short derivedBy, short schemaFinal,
        short block, short contentType,
        boolean isAbstract, XSAttributeGroupDecl attrGrp,
        XSSimpleType simpleType, XSParticleDecl particle) {
    // don't allow this.
}
 
Example #27
Source File: XSSimpleTypeDecl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkExtraRules(ValidationContext context, ValidatedInfo validatedInfo) throws InvalidDatatypeValueException {

        Object ob = validatedInfo.actualValue;

        if (fVariety == VARIETY_ATOMIC) {

            fDVs[fValidationDV].checkExtraRules(ob, context);

        } else if (fVariety == VARIETY_LIST) {

            ListDV.ListData values = (ListDV.ListData)ob;
            XSSimpleType memberType = validatedInfo.memberType;
            int len = values.getLength();
            try {
                if (fItemType.fVariety == VARIETY_UNION) {
                    XSSimpleTypeDecl[] memberTypes = (XSSimpleTypeDecl[])validatedInfo.memberTypes;
                    for (int i = len-1; i >= 0; i--) {
                        validatedInfo.actualValue = values.item(i);
                        validatedInfo.memberType = memberTypes[i];
                        fItemType.checkExtraRules(context, validatedInfo);
                    }
                } else { // (fVariety == VARIETY_ATOMIC)
                    for (int i = len-1; i >= 0; i--) {
                        validatedInfo.actualValue = values.item(i);
                        fItemType.checkExtraRules(context, validatedInfo);
                    }
                }
            }
            finally {
                validatedInfo.actualValue = values;
                validatedInfo.memberType = memberType;
            }

        } else { // (fVariety == VARIETY_UNION)

            ((XSSimpleTypeDecl)validatedInfo.memberType).checkExtraRules(context, validatedInfo);

        }

    }
 
Example #28
Source File: BaseSchemaDVFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new simple type which is derived by union from a list of other
 * simple types.
 *
 * @param name              name of the new type, could be null
 * @param targetNamespace   target namespace of the new type, could be null
 * @param finalSet          value of "final"
 * @param memberTypes       member types of the union type
 * @param annotations       set of annotations
 * @return                  the newly created simple type
 */
public XSSimpleType createTypeUnion(String name, String targetNamespace,
                                    short finalSet, XSSimpleType[] memberTypes,
                                    XSObjectList annotations) {
    int typeNum = memberTypes.length;
    XSSimpleTypeDecl[] mtypes = new XSSimpleTypeDecl[typeNum];
    System.arraycopy(memberTypes, 0, mtypes, 0, typeNum);

    if (fDeclPool != null) {
       XSSimpleTypeDecl st= fDeclPool.getSimpleTypeDecl();
       return st.setUnionValues(name, targetNamespace, finalSet, mtypes, annotations);
    }
    return new XSSimpleTypeDecl(name, targetNamespace, finalSet, mtypes, annotations);
}
 
Example #29
Source File: XMLSchemaValidator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Object elementLocallyValidType(QName element, Object textContent) {
    if (fCurrentType == null)
        return null;

    Object retValue = null;
    // Element Locally Valid (Type)
    // 3 The appropriate case among the following must be true:
    // 3.1 If the type definition is a simple type definition, then all of the following must be true:
    if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
        // 3.1.2 The element information item must have no element information item [children].
        if (fSubElement)
            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 {
                if (!fNormalizeData || fUnionType) {
                    fValidationState.setNormalizationRequired(true);
                }
                retValue = dv.validate(textContent, fValidationState, fValidatedInfo);
            } catch (InvalidDatatypeValueException e) {
                reportSchemaError(e.getKey(), e.getArgs());
                reportSchemaError(
                    "cvc-type.3.1.3",
                    new Object[] { element.rawname, textContent });
            }
        }
    } else {
        // 3.2 If the type definition is a complex type definition, then the element information item must be valid with respect to the type definition as per Element Locally Valid (Complex Type) (3.4.4);
        retValue = elementLocallyValidComplexType(element, textContent);
    }

    return retValue;
}
 
Example #30
Source File: ShortHandPointer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaValue().getNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}