com.sun.org.apache.xerces.internal.xs.XSConstants Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xs.XSConstants. 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: XSModelImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #2
Source File: XSDSimpleTypeTraverser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private XSSimpleType errorType(String name, String namespace, short refType) {
    XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string");
    switch (refType) {
    case XSConstants.DERIVATION_RESTRICTION:
        return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_LIST:
        return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_UNION:
        return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0,
                new XSSimpleType[]{stringType}, null);
    }

    return null;
}
 
Example #3
Source File: Field.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private short convertToPrimitiveKind(short valueType) {
    /** Primitive datatypes. */
    if (valueType <= XSConstants.NOTATION_DT) {
        return valueType;
    }
    /** Types derived from string. */
    if (valueType <= XSConstants.ENTITY_DT) {
        return XSConstants.STRING_DT;
    }
    /** Types derived from decimal. */
    if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
        return XSConstants.DECIMAL_DT;
    }
    /** Other types. */
    return valueType;
}
 
Example #4
Source File: XSElementDecl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
  * Reset current element declaration
  */
public void reset(){
    fScope = XSConstants.SCOPE_ABSENT;
    fName = null;
    fTargetNamespace = null;
    fType = null;
    fUnresolvedTypeName = null;
    fMiscFlags = 0;
    fBlock = XSConstants.DERIVATION_NONE;
    fFinal = XSConstants.DERIVATION_NONE;
    fDefault = null;
    fAnnotations = null;
    fSubGroup = null;
    // reset identity constraints
    for (int i=0;i<fIDCPos;i++) {
        fIDConstraints[i] = null;
    }

    fIDCPos = 0;
}
 
Example #5
Source File: XSDHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void expandRelatedComponents(XSObject component, Vector componentList, Map<String, Vector> dependencies) {
    short componentType = component.getType();
    switch (componentType) {
    case XSConstants.TYPE_DEFINITION :
        expandRelatedTypeComponents((XSTypeDefinition) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_DECLARATION :
        expandRelatedAttributeComponents((XSAttributeDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_GROUP :
        expandRelatedAttributeGroupComponents((XSAttributeGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ELEMENT_DECLARATION :
        expandRelatedElementComponents((XSElementDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.MODEL_GROUP_DEFINITION :
        expandRelatedModelGroupDefinitionComponents((XSModelGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ATTRIBUTE_USE :
        //expandRelatedAttributeUseComponents((XSAttributeUse)component, componentList, dependencies);
    case XSConstants.NOTATION_DECLARATION :
    case XSConstants.IDENTITY_CONSTRAINT :
    default :
        break;
    }
}
 
Example #6
Source File: XSDHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void expandRelatedComponents(XSObject component, Vector componentList, Map<String, Vector> dependencies) {
    short componentType = component.getType();
    switch (componentType) {
    case XSConstants.TYPE_DEFINITION :
        expandRelatedTypeComponents((XSTypeDefinition) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_DECLARATION :
        expandRelatedAttributeComponents((XSAttributeDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_GROUP :
        expandRelatedAttributeGroupComponents((XSAttributeGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ELEMENT_DECLARATION :
        expandRelatedElementComponents((XSElementDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.MODEL_GROUP_DEFINITION :
        expandRelatedModelGroupDefinitionComponents((XSModelGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ATTRIBUTE_USE :
        //expandRelatedAttributeUseComponents((XSAttributeUse)component, componentList, dependencies);
    case XSConstants.NOTATION_DECLARATION :
    case XSConstants.IDENTITY_CONSTRAINT :
    default :
        break;
    }
}
 
Example #7
Source File: XSSimpleTypeDecl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private short convertToPrimitiveKind(short valueType) {
    /** Primitive datatypes. */
    if (valueType <= XSConstants.NOTATION_DT) {
        return valueType;
    }
    /** Types derived from string. */
    if (valueType <= XSConstants.ENTITY_DT) {
        return XSConstants.STRING_DT;
    }
    /** Types derived from decimal. */
    if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
        return XSConstants.DECIMAL_DT;
    }
    /** Other types. */
    return valueType;
}
 
Example #8
Source File: XSDSimpleTypeTraverser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private XSSimpleType errorType(String name, String namespace, short refType) {
    XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string");
    switch (refType) {
    case XSConstants.DERIVATION_RESTRICTION:
        return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_LIST:
        return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_UNION:
        return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0,
                new XSSimpleType[]{stringType}, null);
    }

    return null;
}
 
Example #9
Source File: XSModelImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #10
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private void expandRelatedComponents(XSObject component, Vector componentList, Map<String, Vector> dependencies) {
    short componentType = component.getType();
    switch (componentType) {
    case XSConstants.TYPE_DEFINITION :
        expandRelatedTypeComponents((XSTypeDefinition) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_DECLARATION :
        expandRelatedAttributeComponents((XSAttributeDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_GROUP :
        expandRelatedAttributeGroupComponents((XSAttributeGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ELEMENT_DECLARATION :
        expandRelatedElementComponents((XSElementDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.MODEL_GROUP_DEFINITION :
        expandRelatedModelGroupDefinitionComponents((XSModelGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ATTRIBUTE_USE :
        //expandRelatedAttributeUseComponents((XSAttributeUse)component, componentList, dependencies);
    case XSConstants.NOTATION_DECLARATION :
    case XSConstants.IDENTITY_CONSTRAINT :
    default :
        break;
    }
}
 
Example #11
Source File: XSSimpleTypeDecl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private short convertToPrimitiveKind(short valueType) {
    /** Primitive datatypes. */
    if (valueType <= XSConstants.NOTATION_DT) {
        return valueType;
    }
    /** Types derived from string. */
    if (valueType <= XSConstants.ENTITY_DT) {
        return XSConstants.STRING_DT;
    }
    /** Types derived from decimal. */
    if (valueType <= XSConstants.POSITIVEINTEGER_DT) {
        return XSConstants.DECIMAL_DT;
    }
    /** Other types. */
    return valueType;
}
 
Example #12
Source File: XSDSimpleTypeTraverser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private XSSimpleType errorType(String name, String namespace, short refType) {
    XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string");
    switch (refType) {
    case XSConstants.DERIVATION_RESTRICTION:
        return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_LIST:
        return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_UNION:
        return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0,
                new XSSimpleType[]{stringType}, null);
    }

    return null;
}
 
Example #13
Source File: XSDSimpleTypeTraverser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private XSSimpleType errorType(String name, String namespace, short refType) {
    XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string");
    switch (refType) {
    case XSConstants.DERIVATION_RESTRICTION:
        return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_LIST:
        return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0,
                stringType, null);
    case XSConstants.DERIVATION_UNION:
        return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0,
                new XSSimpleType[]{stringType}, null);
    }

    return null;
}
 
Example #14
Source File: SubstitutionGroupHandler.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
private boolean getDBMethods(XSTypeDefinition typed, XSTypeDefinition typeb,
                             OneSubGroup methods) {
    short dMethod = 0, bMethod = 0;
    while (typed != typeb && typed != SchemaGrammar.fAnyType) {
        if (typed.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
            dMethod |= ((XSComplexTypeDecl)typed).fDerivedBy;
        else
            dMethod |= XSConstants.DERIVATION_RESTRICTION;
        typed = typed.getBaseType();
        // type == null means the current type is anySimpleType,
        // whose base type should be anyType
        if (typed == null)
            typed = SchemaGrammar.fAnyType;
        if (typed.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
            bMethod |= ((XSComplexTypeDecl)typed).fBlock;
    }
    // No derivation relation, or blocked, return false
    if (typed != typeb || (dMethod & bMethod) != 0)
        return false;

    // Remember the derivation methods and blocks, return true.
    methods.dMethod = dMethod;
    methods.bMethod = bMethod;
    return true;
}
 
Example #15
Source File: XSModelImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private SymbolHash buildSubGroups_Org() {
    SubstitutionGroupHandler sgHandler = new SubstitutionGroupHandler(null);
    for (int i = 0 ; i < fGrammarCount; i++) {
        sgHandler.addSubstitutionGroup(fGrammarList[i].getSubstitutionGroups());
    }

    final XSNamedMap elements = getComponents(XSConstants.ELEMENT_DECLARATION);
    final int len = elements.getLength();
    final SymbolHash subGroupMap = new SymbolHash(len*2);
    XSElementDecl head;
    XSElementDeclaration[] subGroup;
    for (int i = 0; i < len; i++) {
        head = (XSElementDecl)elements.item(i);
        subGroup = sgHandler.getSubstitutionGroup(head);
        subGroupMap.put(head, subGroup.length > 0 ?
                new XSObjectListImpl(subGroup, subGroup.length) : XSObjectListImpl.EMPTY_LIST);
    }
    return subGroupMap;
}
 
Example #16
Source File: XSDHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void expandRelatedComponents(XSObject component, Vector componentList, Map<String, Vector> dependencies) {
    short componentType = component.getType();
    switch (componentType) {
    case XSConstants.TYPE_DEFINITION :
        expandRelatedTypeComponents((XSTypeDefinition) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_DECLARATION :
        expandRelatedAttributeComponents((XSAttributeDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.ATTRIBUTE_GROUP :
        expandRelatedAttributeGroupComponents((XSAttributeGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ELEMENT_DECLARATION :
        expandRelatedElementComponents((XSElementDeclaration) component, componentList, component.getNamespace(), dependencies);
        break;
    case XSConstants.MODEL_GROUP_DEFINITION :
        expandRelatedModelGroupDefinitionComponents((XSModelGroupDefinition) component, componentList, component.getNamespace(), dependencies);
    case XSConstants.ATTRIBUTE_USE :
        //expandRelatedAttributeUseComponents((XSAttributeUse)component, componentList, dependencies);
    case XSConstants.NOTATION_DECLARATION :
    case XSConstants.IDENTITY_CONSTRAINT :
    default :
        break;
    }
}
 
Example #17
Source File: ElementPSVImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Reset() should be called in validator startElement(..) method.
 */
public void reset() {
    fDeclaration = null;
    fTypeDecl = null;
    fNil = false;
    fSpecified = false;
    fNotation = null;
    fMemberType = null;
    fValidationAttempted = ElementPSVI.VALIDATION_NONE;
    fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
    fErrorCodes = null;
    fValidationContext = null;
    fNormalizedValue = null;
    fActualValue = null;
    fActualValueType = XSConstants.UNAVAILABLE_DT;
    fItemValueTypes = null;
}
 
Example #18
Source File: SchemaGrammar.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example #19
Source File: SchemaGrammar.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private XSElementDecl createAnnotationElementDecl(String localName) {
    XSElementDecl eDecl = new XSElementDecl();
    eDecl.fName = localName;
    eDecl.fTargetNamespace = fTargetNamespace;
    eDecl.setIsGlobal();
    eDecl.fBlock = (XSConstants.DERIVATION_EXTENSION |
            XSConstants.DERIVATION_RESTRICTION | XSConstants.DERIVATION_SUBSTITUTION);
    eDecl.setConstraintType(XSConstants.VC_NONE);
    return eDecl;
}
 
Example #20
Source File: XSConstraints.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #21
Source File: SubstitutionGroupHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
protected boolean substitutionGroupOK(XSElementDecl element, XSElementDecl exemplar, short blockingConstraint) {
    // For an element declaration (call it D) to be validly substitutable for another element declaration (call it C) subject to a blocking constraint (a subset of {substitution, extension, restriction}, the value of a {disallowed substitutions}) one of the following must be true:
    // 1. D and C are the same element declaration.
    if (element == exemplar) {
        return true;
    }

    // 2 All of the following must be true:
    // 2.1 The blocking constraint does not contain substitution.
    if ((blockingConstraint & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
        return false;
    }

    // 2.2 There is a chain of {substitution group affiliation}s from D to C, that is, either D's {substitution group affiliation} is C, or D's {substitution group affiliation}'s {substitution group affiliation} is C, or . . .
    XSElementDecl subGroup = element.fSubGroup;
    while (subGroup != null && subGroup != exemplar) {
        subGroup = subGroup.fSubGroup;
    }

    if (subGroup == null) {
        return false;
    }

    // 2.3 The set of all {derivation method}s involved in the derivation of D's {type definition} from C's {type definition} does not intersect with the union of the blocking constraint, C's {prohibited substitutions} (if C is complex, otherwise the empty set) and the {prohibited substitutions} (respectively the empty set) of any intermediate {type definition}s in the derivation of D's {type definition} from C's {type definition}.
    // prepare the combination of {derivation method} and
    // {disallowed substitution}
    return typeDerivationOK(element.fType, exemplar.fType, blockingConstraint);
}
 
Example #22
Source File: XSAttributeDecl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void reset(){
    fName = null;
    fTargetNamespace = null;
    fType = null;
    fUnresolvedTypeName = null;
    fConstraintType = XSConstants.VC_NONE;
    fScope = XSConstants.SCOPE_ABSENT;
    fDefault = null;
    fAnnotations = null;
}
 
Example #23
Source File: XSDHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void expandRelatedParticleComponents(XSParticle component, Vector componentList,
        String namespace, Map<String, Vector> dependencies) {
    XSTerm term = component.getTerm();
    switch (term.getType()) {
    case XSConstants.ELEMENT_DECLARATION :
        addRelatedElement((XSElementDeclaration) term, componentList, namespace, dependencies);
        break;
    case XSConstants.MODEL_GROUP :
        expandRelatedModelGroupComponents((XSModelGroup) term, componentList, namespace, dependencies);
        break;
    default:
        break;
    }
}
 
Example #24
Source File: XSSimpleTypeDecl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected XSSimpleTypeDecl setUnionValues(String name, String uri, short finalSet, XSSimpleTypeDecl[] memberTypes,
        XSObjectList annotations) {
    //decline to do anything if the object is immutable.
    if(fIsImmutable) return null;
    fBase = fAnySimpleType;
    fAnonymous = false;
    fTypeName = name;
    fTargetNamespace = uri;
    fFinalSet = finalSet;
    fAnnotations = annotations;

    fVariety = VARIETY_UNION;
    fMemberTypes = memberTypes;
    fValidationDV = DV_UNION;
    // even for union, we set whitespace to something
    // this will never be used, but we can use fFacetsDefined to check
    // whether applyFacets() is allwwed: it's not allowed
    // if fFacetsDefined != 0
    fFacetsDefined = FACET_WHITESPACE;
    fWhiteSpace = WS_COLLAPSE;

    //setting fundamental facets
    calcFundamentalFacets();

    // No value can be of this type, so it's unavailable.
    fBuiltInKind = XSConstants.UNAVAILABLE_DT;

    return this;
}
 
Example #25
Source File: XMLSchemaValidator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example #26
Source File: XMLSchemaValidator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** Returns true if the two ValidatedInfo objects can be compared in the same value space. **/
private boolean isComparable(ValidatedInfo info1, ValidatedInfo info2) {
    final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType);
    final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType);
    if (primitiveType1 != primitiveType2) {
        return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT ||
                primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT);
    }
    else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) {
        final ShortList typeList1 = info1.itemValueTypes;
        final ShortList typeList2 = info2.itemValueTypes;
        final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0;
        final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0;
        if (typeList1Length != typeList2Length) {
            return false;
        }
        for (int i = 0; i < typeList1Length; ++i) {
            final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i));
            final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i));
            if (primitiveItem1 != primitiveItem2) {
                if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT ||
                    primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) {
                    continue;
                }
                return false;
            }
        }
    }
    return true;
}
 
Example #27
Source File: XMLSchemaValidator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
boolean getXsiNil(QName element, String xsiNil) {
    // Element Locally Valid (Element)
    // 3 The appropriate case among the following must be true:
    // 3.1 If {nillable} is false, then there must be no attribute information item among the element information item's [attributes] whose [namespace name] is identical to http://www.w3.org/2001/XMLSchema-instance and whose [local name] is nil.
    if (fCurrentElemDecl != null && !fCurrentElemDecl.getNillable()) {
        reportSchemaError(
            "cvc-elt.3.1",
            new Object[] {
                element.rawname,
                SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
    }
    // 3.2 If {nillable} is true and there is such an attribute information item and its actual value is true , then all of the following must be true:
    // 3.2.2 There must be no fixed {value constraint}.
    else {
        String value = XMLChar.trim(xsiNil);
        if (value.equals(SchemaSymbols.ATTVAL_TRUE)
            || value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
            if (fCurrentElemDecl != null
                && fCurrentElemDecl.getConstraintType() == XSConstants.VC_FIXED) {
                reportSchemaError(
                    "cvc-elt.3.2.2",
                    new Object[] {
                        element.rawname,
                        SchemaSymbols.URI_XSI + "," + SchemaSymbols.XSI_NIL });
            }
            return true;
        }
    }
    return false;
}
 
Example #28
Source File: SchemaGrammar.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public XSAnyType () {
    fName = SchemaSymbols.ATTVAL_ANYTYPE;
    super.fTargetNamespace = SchemaSymbols.URI_SCHEMAFORSCHEMA;
    fBaseType = this;
    fDerivedBy = XSConstants.DERIVATION_RESTRICTION;
    fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED;

    fParticle = null;
    fAttrGrp = null;
}
 
Example #29
Source File: XSConstraints.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void checkElementDeclsConsistent(XSComplexTypeDecl type,
        XSParticleDecl particle,
        SymbolHash elemDeclHash,
        SubstitutionGroupHandler sgHandler)
    throws XMLSchemaException {

    // check for elements in the tree with the same name and namespace

    int pType = particle.fType;

    if (pType == XSParticleDecl.PARTICLE_WILDCARD)
        return;

    if (pType == XSParticleDecl.PARTICLE_ELEMENT) {
        XSElementDecl elem = (XSElementDecl)(particle.fValue);
        findElemInTable(type, elem, elemDeclHash);

        if (elem.fScope == XSConstants.SCOPE_GLOBAL) {
            // Check for subsitution groups.
            XSElementDecl[] subGroup = sgHandler.getSubstitutionGroup(elem);
            for (int i = 0; i < subGroup.length; i++) {
                findElemInTable(type, subGroup[i], elemDeclHash);
            }
        }
        return;
    }

    XSModelGroupImpl group = (XSModelGroupImpl)particle.fValue;
    for (int i = 0; i < group.fParticleCount; i++)
        checkElementDeclsConsistent(type, group.fParticles[i], elemDeclHash, sgHandler);
}
 
Example #30
Source File: XSDHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private void expandRelatedParticleComponents(XSParticle component, Vector componentList,
        String namespace, Map<String, Vector> dependencies) {
    XSTerm term = component.getTerm();
    switch (term.getType()) {
    case XSConstants.ELEMENT_DECLARATION :
        addRelatedElement((XSElementDeclaration) term, componentList, namespace, dependencies);
        break;
    case XSConstants.MODEL_GROUP :
        expandRelatedModelGroupComponents((XSModelGroup) term, componentList, namespace, dependencies);
        break;
    default:
        break;
    }
}