Java Code Examples for com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#getTypeCategory()
The following examples show how to use
com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#getTypeCategory() .
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: SubstitutionGroupHandler.java From JDKSourceCode1.8 with MIT License | 6 votes |
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 2
Source File: SubstitutionGroupHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 3
Source File: SubstitutionGroupHandler.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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 4
Source File: XSConstraints.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * 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 5
Source File: XSDAbstractTraverser.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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 6
Source File: Field.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fIdentityConstraint.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); }
Example 7
Source File: XSConstraints.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * 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 8
Source File: XSNamedMap4Types.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Retrieves an <code>XSObject</code> specified by local name and namespace * URI. * @param namespace The namespace URI of the <code>XSObject</code> to * retrieve. * @param localName The local name of the <code>XSObject</code> to retrieve. * @return A <code>XSObject</code> (of any type) with the specified local * name and namespace URI, or <code>null</code> if they do not * identify any <code>XSObject</code> in this map. */ public XSObject itemByName(String namespace, String localName) { for (int i = 0; i < fNSNum; i++) { if (isEqual(namespace, fNamespaces[i])) { XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName); // only return it if it matches the required type if (type != null && type.getTypeCategory() == fType) { return type; } return null; } } return null; }
Example 9
Source File: XSDAbstractTraverser.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * 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 10
Source File: XSNamedMap4Types.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Retrieves an <code>XSObject</code> specified by local name and namespace * URI. * @param namespace The namespace URI of the <code>XSObject</code> to * retrieve. * @param localName The local name of the <code>XSObject</code> to retrieve. * @return A <code>XSObject</code> (of any type) with the specified local * name and namespace URI, or <code>null</code> if they do not * identify any <code>XSObject</code> in this map. */ public XSObject itemByName(String namespace, String localName) { for (int i = 0; i < fNSNum; i++) { if (isEqual(namespace, fNamespaces[i])) { XSTypeDefinition type = (XSTypeDefinition)fMaps[i].get(localName); // only return it if it matches the required type if (type != null && type.getTypeCategory() == fType) { return type; } return null; } } return null; }
Example 11
Source File: Field.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fIdentityConstraint.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); }
Example 12
Source File: Field.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void handleContent(XSTypeDefinition type, boolean nillable, Object actualValue, short valueType, ShortList itemValueType) { if (type == null || type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE && ((XSComplexTypeDefinition) type).getContentType() != XSComplexTypeDefinition.CONTENTTYPE_SIMPLE) { // the content must be simpleType content fStore.reportError( "cvc-id.3", new Object[] { fIdentityConstraint.getName(), fIdentityConstraint.getElementName()}); } fMatchedString = actualValue; matched(fMatchedString, valueType, itemValueType, nillable); }
Example 13
Source File: XSDAbstractTraverser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * 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 14
Source File: XSConstraints.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 15
Source File: SubstitutionGroupHandler.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }
Example 16
Source File: XSConstraints.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Note: this will be a private method, and it assumes that derived is not * anyType. Another method will be introduced for public use, * which will call this method. */ private static boolean checkComplexDerivation(XSComplexTypeDecl derived, XSTypeDefinition base, short block) { // 2.1 B and D must be the same type definition. if (derived == base) return true; // 1 If B and D are not the same type definition, then the {derivation method} of D must not be in the subset. if ((derived.fDerivedBy & block) != 0) return false; // 2 One of the following must be true: XSTypeDefinition directBase = derived.fBaseType; // 2.2 B must be D's {base type definition}. if (directBase == base) return true; // 2.3 All of the following must be true: // 2.3.1 D's {base type definition} must not be the ur-type definition. if (directBase == SchemaGrammar.fAnyType || directBase == SchemaGrammar.fAnySimpleType) { return false; } // 2.3.2 The appropriate case among the following must be true: // 2.3.2.1 If D's {base type definition} is complex, then it must be validly derived from B given the subset as defined by this constraint. if (directBase.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) return checkComplexDerivation((XSComplexTypeDecl)directBase, base, block); // 2.3.2.2 If D's {base type definition} is simple, then it must be validly derived from B given the subset as defined in Type Derivation OK (Simple) (3.14.6). if (directBase.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)directBase, (XSSimpleType)base, block); } return false; }
Example 17
Source File: SubstitutionGroupHandler.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }
Example 18
Source File: XSConstraints.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Note: this will be a private method, and it assumes that derived is not * anyType. Another method will be introduced for public use, * which will call this method. */ private static boolean checkComplexDerivation(XSComplexTypeDecl derived, XSTypeDefinition base, short block) { // 2.1 B and D must be the same type definition. if (derived == base) return true; // 1 If B and D are not the same type definition, then the {derivation method} of D must not be in the subset. if ((derived.fDerivedBy & block) != 0) return false; // 2 One of the following must be true: XSTypeDefinition directBase = derived.fBaseType; // 2.2 B must be D's {base type definition}. if (directBase == base) return true; // 2.3 All of the following must be true: // 2.3.1 D's {base type definition} must not be the ur-type definition. if (directBase == SchemaGrammar.fAnyType || directBase == SchemaGrammar.fAnySimpleType) { return false; } // 2.3.2 The appropriate case among the following must be true: // 2.3.2.1 If D's {base type definition} is complex, then it must be validly derived from B given the subset as defined by this constraint. if (directBase.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) return checkComplexDerivation((XSComplexTypeDecl)directBase, base, block); // 2.3.2.2 If D's {base type definition} is simple, then it must be validly derived from B given the subset as defined in Type Derivation OK (Simple) (3.14.6). if (directBase.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)directBase, (XSSimpleType)base, block); } return false; }
Example 19
Source File: XSDSimpleTypeTraverser.java From JDKSourceCode1.8 with MIT License | 4 votes |
private XSSimpleType findDTValidator(Element elm, String refName, QName baseTypeStr, short baseRefContext, XSDocumentInfo schemaDoc) { if (baseTypeStr == null) return null; XSTypeDefinition baseType = (XSTypeDefinition)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.TYPEDECL_TYPE, baseTypeStr, elm); if (baseType == null) { return null; } if (baseType.getTypeCategory() != XSTypeDefinition.SIMPLE_TYPE) { reportSchemaError("cos-st-restricts.1.1", new Object[]{baseTypeStr.rawname, refName}, elm); return null; } // if it's a complex type, or if its restriction of anySimpleType if (baseType == SchemaGrammar.fAnySimpleType && baseRefContext == XSConstants.DERIVATION_RESTRICTION) { // if the base type is anySimpleType and the current type is // a S4S built-in type, return null. (not an error). if (checkBuiltIn(refName, schemaDoc.fTargetNamespace)) { return null; } reportSchemaError("cos-st-restricts.1.1", new Object[]{baseTypeStr.rawname, refName}, elm); return null; } if ((baseType.getFinal() & baseRefContext) != 0) { if (baseRefContext == XSConstants.DERIVATION_RESTRICTION) { reportSchemaError("st-props-correct.3", new Object[]{refName, baseTypeStr.rawname}, elm); } else if (baseRefContext == XSConstants.DERIVATION_LIST) { reportSchemaError("cos-st-restricts.2.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm); } else if (baseRefContext == XSConstants.DERIVATION_UNION) { reportSchemaError("cos-st-restricts.3.3.1.1", new Object[]{baseTypeStr.rawname, refName}, elm); } return null; } return (XSSimpleType)baseType; }
Example 20
Source File: SubstitutionGroupHandler.java From Bytecoder with Apache License 2.0 | 4 votes |
private boolean typeDerivationOK(XSTypeDefinition derived, XSTypeDefinition base, short blockingConstraint) { short devMethod = 0, blockConstraint = blockingConstraint; // "derived" should be derived from "base" // add derivation methods of derived types to devMethod; // add block of base types to blockConstraint. XSTypeDefinition type = derived; while (type != base && type != SchemaGrammar.fAnyType) { if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { devMethod |= ((XSComplexTypeDecl)type).fDerivedBy; } else { devMethod |= XSConstants.DERIVATION_RESTRICTION; } type = type.getBaseType(); // type == null means the current type is anySimpleType, // whose base type should be anyType if (type == null) { type = SchemaGrammar.fAnyType; } if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { blockConstraint |= ((XSComplexTypeDecl)type).fBlock; } } if (type != base) { // If the base is a union, check if "derived" is allowed through any of the member types. if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { XSSimpleTypeDefinition st = (XSSimpleTypeDefinition) base; if (st.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { XSObjectList memberTypes = st.getMemberTypes(); final int length = memberTypes.getLength(); for (int i = 0; i < length; ++i) { if (typeDerivationOK(derived, (XSTypeDefinition) memberTypes.item(i), blockingConstraint)) { return true; } } } } return false; } if ((devMethod & blockConstraint) != 0) { return false; } return true; }