private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList unionMemberTypes) { XSAssertImpl assertImpl = null; for (int memberTypeIdx = 0; memberTypeIdx < unionMemberTypes.getLength(); memberTypeIdx++) { XSSimpleTypeDefinition unionMemberType = (XSSimpleTypeDefinition) unionMemberTypes.item(memberTypeIdx); if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(unionMemberType.getNamespace())) { Vector memberTypeAsserts = XS11TypeHelper.getAssertsFromSimpleType(unionMemberType); if (!memberTypeAsserts.isEmpty()) { assertImpl = (XSAssertImpl) memberTypeAsserts.get(0); break; } } } return assertImpl; } // getFirstAssertFromUnionMemberTypes
public void setXDMTypedValueOf$valueForSTVarietyList(Element rootNodeOfAssertTree, String listStrValue, XSSimpleTypeDefinition itemType, boolean isTypeDerivedFromList, DynamicContext xpath2DynamicContext) throws Exception { if (itemType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION) { // itemType of xs:list has variety 'union' List xdmItemList = new ArrayList(); XSObjectList memberTypes = itemType.getMemberTypes(); // tokenize the list value by a sequence of white spaces StringTokenizer values = new StringTokenizer(listStrValue, " \n\t\r"); while (values.hasMoreTokens()) { String itemValue = values.nextToken(); XSSimpleTypeDefinition listItemTypeForUnion = getActualXDMItemTypeForSTVarietyUnion(memberTypes, itemValue); xdmItemList.add(SchemaTypeValueFactory.newSchemaTypeValue(listItemTypeForUnion.getBuiltInKind(), itemValue)); } xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XS11TypeHelper.getXPath2ResultSequence(xdmItemList)); } else { setXDMTypedValueOf$value(rootNodeOfAssertTree, listStrValue, itemType, null, isTypeDerivedFromList, xpath2DynamicContext); } } // setXDMTypedValueOf$valueForSTVarietyList
void extraCheckForSTUnionAssertsAttrs(XMLAttributes attributes) { XMLAttributes attrsImpl = (XMLAttributesImpl)attributes; for (int attrIdx = 0; attrIdx < attrsImpl.getLength(); attrIdx++) { Augmentations attrAugs = attrsImpl.getAugmentations(attrIdx); AttributePSVImpl attrPsvi = (AttributePSVImpl)attrAugs.getItem(Constants.ATTRIBUTE_PSVI); XSSimpleTypeDefinition attrSimpleType = (XSSimpleTypeDefinition) attrPsvi.getTypeDefinition(); List isAssertProcessingNeededForSTUnionAttrs = fXmlSchemaValidator.getIsAssertProcessingNeededForSTUnionAttrs(); if (attrSimpleType != null && attrSimpleType.getVariety() == XSSimpleTypeDefinition.VARIETY_UNION && ((XSSimpleType) attrSimpleType.getBaseType()).getVariety() != XSSimpleTypeDefinition.VARIETY_UNION) { if (XS11TypeHelper.isAtomicStrValueValidForSTUnion(attrSimpleType.getMemberTypes(), attrsImpl.getValue(attrIdx), attrPsvi.fValue, Constants.SCHEMA_VERSION_1_1)) { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(false)); } else { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(true)); } } else { isAssertProcessingNeededForSTUnionAttrs.add(Boolean.valueOf(true)); } } } // extraCheckForSTUnionAssertsAttrs
public static boolean isSchemaTypesIdentical(XSTypeDefinition typeDefn1, XSTypeDefinition typeDefn2) { boolean typesIdentical = false; String type1Name = typeDefn1.getName(); String type2Name = typeDefn2.getName(); if (("anyType".equals(type1Name) && "anyType".equals(type2Name)) || ("anySimpleType".equals(type1Name) && "anySimpleType".equals(type2Name))) { typesIdentical = true; } if (!typesIdentical && isURIEqual(typeDefn1.getNamespace(), typeDefn2.getNamespace())) { // if targetNamespace of types are same, then check for equality of type names and of the base type if ((type1Name == null && type2Name == null) || (type1Name != null && type1Name.equals(type2Name)) && (isSchemaTypesIdentical(typeDefn1.getBaseType(), typeDefn2.getBaseType()))) { typesIdentical = true; } } return typesIdentical; } // isSchemaTypesIdentical
protected XPath compileXPathStr(String xpathStr, XSAssertImpl assertImpl, XSDHandler fSchemaHandler, Element schemaContextElem) { XPathParser xpathParser = new JFlexCupParser(); XPath xpathObject = null; try { xpathObject = xpathParser.parse("boolean(" + xpathStr + ")", true); } catch (XPathParserException ex) { // XPath parser exception if (SchemaSymbols.XS11_XPATHEXPR_COMPILE_WRN_MESG_1.equals(ex.getMessage())) { fSchemaHandler.reportSchemaWarning("cvc-xpath.3.13.4.2b", new Object[] {assertImpl.getTest().getXPathStr(), XS11TypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem); } else { fSchemaHandler.reportSchemaError("cvc-xpath.3.13.4.2a", new Object[] {assertImpl.getTest().getXPathStr(), XS11TypeHelper.getSchemaTypeName(assertImpl.getTypeDefinition())}, schemaContextElem); } } return xpathObject; } // compileXPathStr
if (complexTypeDef.getDerivationMethod() == XSConstants.DERIVATION_RESTRICTION) { Vector simpleContentAsserts = XS11TypeHelper.getAssertsFromSimpleType(simpleContentType); for (int assertIdx = 0; assertIdx < simpleContentAsserts.size(); assertIdx++) { complexTypeAsserts.addXSObject((XSAssert) simpleContentAsserts.get(assertIdx)); else if (XS11TypeHelper.isComplexTypeDerivedFromSTList(complexTypeDef, XSConstants.DERIVATION_EXTENSION)) { Vector baseItemTypeAsserts = XS11TypeHelper.getAssertsFromSimpleType(((XSSimpleTypeDefinition)complexTypeDef.getBaseType()).getItemType()); for (int assertIdx = 0; assertIdx < baseItemTypeAsserts.size(); assertIdx++) { complexTypeAsserts.addXSObject((XSAssert) baseItemTypeAsserts.get(assertIdx));
if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())) { if (!XS11TypeHelper.simpleTypeHasAsserts(memType) && XS11TypeHelper.isStrValueValidForASimpleType(value, (XSSimpleType)memType, Constants.SCHEMA_VERSION_1_1)) { isValidationFailedForUnion = false; break;
} else { fXpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XS11TypeHelper.getXPath2ResultSequence(new ArrayList())); if (XS11TypeHelper.isComplexTypeDerivedFromSTList(complexTypeDef, XSConstants.DERIVATION_EXTENSION)) {
private XSSimpleTypeDefinition getActualXDMItemTypeForSTVarietyUnion(XSObjectList memberTypes, String xdmItemStrValue) { XSSimpleTypeDefinition xdmItemType = null; // iterate the member types of union in order, to find that which schema type can successfully validate an atomic value first final int memberTypesLength = memberTypes.getLength(); for (int memTypeIdx = 0; memTypeIdx < memberTypesLength; memTypeIdx++) { XSSimpleType memSimpleType = (XSSimpleType) memberTypes.item(memTypeIdx); if (XS11TypeHelper.isStrValueValidForASimpleType(xdmItemStrValue, memSimpleType, Constants.SCHEMA_VERSION_1_1)) { // no more memberTypes need to be checked xdmItemType = memSimpleType; break; } } return xdmItemType; } // getActualXDMItemTypeForSTVarietyUnion
final XSElementDecl gElem = grammar.getGlobalElementDecl(elem.fName); if (gElem != null) { if (gElem != elem && XS11TypeHelper.isTypeTablesComparable(elem.getTypeAlternatives(), gElem.getTypeAlternatives()) && !isTypeTablesEquivalent(elem, gElem)) {
public static boolean isListContainsType(List typeList, XSTypeDefinition targetType) { boolean typeExists = false; for (Iterator iter = typeList.iterator(); iter.hasNext();) { if (XS11TypeHelper.isSchemaTypesIdentical((XSTypeDefinition) iter.next(), targetType)) { typeExists = true; break; } } return typeExists; } // isListContainsType
private boolean isInheritedAttributeOverridden(XMLAttributes attributes, XSAttributeDeclaration inhrAttrDecl) { boolean attrExists = false; for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) { if ((attributes.getLocalName(attrIndx)).equals(inhrAttrDecl.getName()) && XS11TypeHelper.isURIEqual(attributes.getURI(attrIndx), inhrAttrDecl.getNamespace())) { attrExists = true; break; } } return attrExists; } // isInheritedAttributeOverridden
private XSObjectListImpl getAssertsFromAttributes(XMLAttributes attributes) { XSObjectListImpl attrAssertList = new XSObjectListImpl(); List xsTypeList = new ArrayList(); for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) { Augmentations attrAugs = attributes.getAugmentations(attrIndx); AttributePSVImpl attrPSVI = (AttributePSVImpl) attrAugs.getItem(Constants.ATTRIBUTE_PSVI); XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) attrPSVI.getTypeDefinition(); if (attrType != null && !XS11TypeHelper.isListContainsType(xsTypeList, attrType)) { // since different attributes may be validated by the same type, so we deduplicate the type list here // to only store unique assertions. xsTypeList.add(attrType); List attrAsserts = getAssertsFromSimpleType(attrType); // copy assertions to the parent list if (attrAsserts != null) { for (Iterator iter = attrAsserts.iterator(); iter.hasNext();) { attrAssertList.addXSObject((XSAssertImpl)iter.next()); } } } } return attrAssertList; } // getAssertsFromAttributes
errorList.add(new Object[] { element.rawname, xsiType, XS11TypeHelper.getSchemaTypeName(fCurrentType)});
public static boolean isAtomicStrValueValidForSTUnion(XSObjectList memberTypes, String content, ValidatedInfo validatedInfo, short schemaVersion) { boolean isValueValid = false; // check the union member types in order to find validity of an atomic value. the validity of atomic value wrt // to the 1st available type in union's member type collection, is sufficient to achieve the objective of this method. for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) { XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx); if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(simpleTypeDv.getNamespace()) && XS11TypeHelper.isStrValueValidForASimpleType(content, simpleTypeDv, schemaVersion)) { isValueValid = true; validatedInfo.memberType = simpleTypeDv; break; } } return isValueValid; } // isAtomicStrValueValidForSTUnion
final public void findElemInTable(XSComplexTypeDecl type, XSElementDecl elem, SymbolHash elemDeclHash) throws XMLSchemaException { final XSElementDecl existingElem = findExistingElement(elem, elemDeclHash); // First time or is same element if (existingElem == null || existingElem == elem) { return; } if (elem.fType != existingElem.fType) { // Types are not the same throw new XMLSchemaException("cos-element-consistent", new Object[] {type.fName, elem.fName}); } if (XS11TypeHelper.isTypeTablesComparable(elem.getTypeAlternatives(), existingElem.getTypeAlternatives()) && !isTypeTablesEquivalent(elem, existingElem)) { // Type tables are not equivalent throw new XMLSchemaException("cos-element-consistent.4.b", new Object[] {type.fName, elem.fName}); } }
public boolean equals(XSAssertImpl pAssertion) { boolean returnVal = false; String xpathStr = pAssertion.getTest().getXPathStr(); String currXpathStr = this.getTest().getXPathStr(); // if type and the xpath string are same, the asserts are equal if (XS11TypeHelper.isSchemaTypesIdentical(pAssertion.getTypeDefinition(), fTypeDefinition) && currXpathStr.equals(xpathStr)) { returnVal = true; } return returnVal; } // equals
if (ancestorType != null && !((XS11TypeHelper.getSchemaTypeName(ancestorType)).equals(SchemaSymbols.ATTVAL_ANYTYPE) || ancestorType.derivedFrom(Constants.NS_XMLSCHEMA, SchemaSymbols.ATTVAL_ANYATOMICTYPE, XSConstants.DERIVATION_RESTRICTION))) { addAssertsFromBaseTypes(ancestorType);
public void setXDMTypedValueOf$valueForSTVarietyUnion(String value, XSObjectList memberTypes, DynamicContext xpath2DynamicContext) throws Exception { // check member types of union in order to find that which member type can successfully validate the string value // first, and set the type annotation of XPath2 context variable $value with this member type definition. for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); memTypeIdx++) { XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item(memTypeIdx); if (XS11TypeHelper.isStrValueValidForASimpleType(value, simpleTypeDv, Constants.SCHEMA_VERSION_1_1)) { if (simpleTypeDv.getVariety() == XSSimpleTypeDefinition.VARIETY_LIST) { setXDMTypedValueOf$valueForSTVarietyList(fRootNodeOfAssertTree, value, simpleTypeDv, ((XSSimpleTypeDefinition)simpleTypeDv.getBaseType()).getVariety() == XSSimpleTypeDefinition.VARIETY_LIST, xpath2DynamicContext); } else { setXDMTypedValueOf$valueForSTVarietyAtomic(value, getXercesXSDTypeCodeFor$value(simpleTypeDv), xpath2DynamicContext); } break; } } } // setXDMTypedValueOf$valueForSTVarietyUnion
xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XS11TypeHelper.getXPath2ResultSequence(xdmItemList)); xpath2DynamicContext.set_variable(new org.eclipse.wst.xml.xpath2.processor.internal.types.QName("value"), XS11TypeHelper.getXPath2ResultSequence(new ArrayList()));