Java Code Examples for com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#getBaseType()
The following examples show how to use
com.sun.org.apache.xerces.internal.xs.XSTypeDefinition#getBaseType() .
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: XSSimpleTypeDecl.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * DOM Level 3 * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the * reference type */ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) { XSTypeDefinition oldType = null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType = type; type = type.getBaseType(); } return false; }
Example 2
Source File: XSSimpleTypeDecl.java From Bytecoder with Apache License 2.0 | 6 votes |
public boolean derivedFrom(String ancestorNS, String ancestorName, short derivation) { // REVISIT: implement according to derivation // ancestor is null, retur false if (ancestorName == null) return false; // ancestor is anyType, return true if (URI_SCHEMAFORSCHEMA.equals(ancestorNS) && ANY_TYPE.equals(ancestorName)) { return true; } // recursively get base, and compare it with ancestor XSTypeDefinition type = this; while (!(ancestorName.equals(type.getName()) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) && // compare with ancestor type != fAnySimpleType) { // reached anySimpleType type = type.getBaseType(); } return type != fAnySimpleType; }
Example 3
Source File: XSSimpleTypeDecl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * DOM Level 3 * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the * reference type */ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) { XSTypeDefinition oldType = null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType = type; type = type.getBaseType(); } return false; }
Example 4
Source File: SubstitutionGroupHandler.java From openjdk-jdk9 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 5
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 6
Source File: SubstitutionGroupHandler.java From Bytecoder with Apache License 2.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 7
Source File: XSSimpleTypeDecl.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * DOM Level 3 * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the * reference type */ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) { XSTypeDefinition oldType = null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType = type; type = type.getBaseType(); } return false; }
Example 8
Source File: SubstitutionGroupHandler.java From jdk8u60 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 9
Source File: SubstitutionGroupHandler.java From openjdk-jdk8u-backup 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 10
Source File: SubstitutionGroupHandler.java From TencentKona-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 11
Source File: XSSimpleTypeDecl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * DOM Level 3 * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the * reference type */ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) { XSTypeDefinition oldType = null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType = type; type = type.getBaseType(); } return false; }
Example 12
Source File: XSSimpleTypeDecl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * DOM Level 3 * Checks if a type is derived from another by restriction. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the * reference type */ private boolean isDerivedByRestriction (String ancestorNS, String ancestorName, XSTypeDefinition type) { XSTypeDefinition oldType = null; while (type != null && type != oldType) { if ((ancestorName.equals(type.getName())) && ((ancestorNS != null && ancestorNS.equals(type.getNamespace())) || (type.getNamespace() == null && ancestorNS == null))) { return true; } oldType = type; type = type.getBaseType(); } return false; }
Example 13
Source File: SubstitutionGroupHandler.java From hottub 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 14
Source File: SubstitutionGroupHandler.java From jdk8u60 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 15
Source File: XSSimpleTypeDecl.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Checks if a type is derived from another by any combination of restriction, list ir union. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the reference type */ private boolean isDerivedByAny(String ancestorNS, String ancestorName, XSTypeDefinition type) { boolean derivedFrom = false; XSTypeDefinition oldType = null; // for each base, item or member type while (type != null && type != oldType) { // If the ancestor type is reached or is the same as this type. if ((ancestorName.equals(type.getName())) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) { derivedFrom = true; break; } // check if derived by restriction or list or union if (isDerivedByRestriction(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByList(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) { return true; } oldType = type; // get the base, item or member type depending on the variety if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) { type = type.getBaseType(); } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) { for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) { return isDerivedByAny(ancestorNS, ancestorName, (XSTypeDefinition) ((XSSimpleTypeDecl) type) .getMemberTypes().item(i)); } } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) { type = ((XSSimpleTypeDecl) type).getItemType(); } } return derivedFrom; }
Example 16
Source File: XSSimpleTypeDecl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Checks if a type is derived from another by any combination of restriction, list ir union. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the reference type */ private boolean isDerivedByAny(String ancestorNS, String ancestorName, XSTypeDefinition type) { boolean derivedFrom = false; XSTypeDefinition oldType = null; // for each base, item or member type while (type != null && type != oldType) { // If the ancestor type is reached or is the same as this type. if ((ancestorName.equals(type.getName())) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) { derivedFrom = true; break; } // check if derived by restriction or list or union if (isDerivedByRestriction(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByList(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) { return true; } oldType = type; // get the base, item or member type depending on the variety if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) { type = type.getBaseType(); } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) { for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) { return isDerivedByAny(ancestorNS, ancestorName, (XSTypeDefinition) ((XSSimpleTypeDecl) type) .getMemberTypes().item(i)); } } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) { type = ((XSSimpleTypeDecl) type).getItemType(); } } return derivedFrom; }
Example 17
Source File: SubstitutionGroupHandler.java From openjdk-jdk8u-backup 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: XSSimpleTypeDecl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Checks if a type is derived from another by any combination of restriction, list ir union. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the reference type */ private boolean isDerivedByAny(String ancestorNS, String ancestorName, XSTypeDefinition type) { boolean derivedFrom = false; XSTypeDefinition oldType = null; // for each base, item or member type while (type != null && type != oldType) { // If the ancestor type is reached or is the same as this type. if ((ancestorName.equals(type.getName())) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) { derivedFrom = true; break; } // check if derived by restriction or list or union if (isDerivedByRestriction(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByList(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) { return true; } oldType = type; // get the base, item or member type depending on the variety if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) { type = type.getBaseType(); } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) { for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) { return isDerivedByAny(ancestorNS, ancestorName, (XSTypeDefinition) ((XSSimpleTypeDecl) type) .getMemberTypes().item(i)); } } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) { type = ((XSSimpleTypeDecl) type).getItemType(); } } return derivedFrom; }
Example 19
Source File: SubstitutionGroupHandler.java From openjdk-jdk8u 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 20
Source File: XSSimpleTypeDecl.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Checks if a type is derived from another by any combination of restriction, list ir union. See: * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom * * @param ancestorNS * The namspace of the ancestor type declaration * @param ancestorName * The name of the ancestor type declaration * @param type * The reference type definition * * @return boolean True if the type is derived by restriciton for the reference type */ private boolean isDerivedByAny(String ancestorNS, String ancestorName, XSTypeDefinition type) { boolean derivedFrom = false; XSTypeDefinition oldType = null; // for each base, item or member type while (type != null && type != oldType) { // If the ancestor type is reached or is the same as this type. if ((ancestorName.equals(type.getName())) && ((ancestorNS == null && type.getNamespace() == null) || (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) { derivedFrom = true; break; } // check if derived by restriction or list or union if (isDerivedByRestriction(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByList(ancestorNS, ancestorName, type)) { return true; } else if (isDerivedByUnion(ancestorNS, ancestorName, type)) { return true; } oldType = type; // get the base, item or member type depending on the variety if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_ABSENT || ((XSSimpleTypeDecl) type).getVariety() == VARIETY_ATOMIC) { type = type.getBaseType(); } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_UNION) { for (int i = 0; i < ((XSSimpleTypeDecl) type).getMemberTypes().getLength(); i++) { return isDerivedByAny(ancestorNS, ancestorName, (XSTypeDefinition) ((XSSimpleTypeDecl) type) .getMemberTypes().item(i)); } } else if (((XSSimpleTypeDecl) type).getVariety() == VARIETY_LIST) { type = ((XSSimpleTypeDecl) type).getItemType(); } } return derivedFrom; }