/** * Determine whether this item type matches a given item. * * @param item the item to be tested against this item type * @return true if the item matches this item type, false if it does not match. */ public boolean matches(XdmItem item) { return underlyingType.matchesItem( (Item)item.getUnderlyingValue(), false, processor.getUnderlyingConfiguration()); }
/** * Evaluate the expression as a boolean */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { SequenceIterator iter = operand.iterate(context); int count = 0; while (true) { Item item = iter.next(); if (item == null) break; count++; if (!targetType.matchesItem(item, false, context.getConfiguration())) { return false; } if (count==2 && !Cardinality.allowsMany(targetCardinality)) { return false; } } return !(count == 0 && ((targetCardinality & StaticProperty.ALLOWS_ZERO) == 0)); }
/** * Determine whether a given value is a valid instance of this SequenceType * @param value the value to be tested * @return true if the value is a valid instance of this type */ public boolean matches(Value value, Configuration config) throws XPathException { if (!Cardinality.subsumes(cardinality, value.getCardinality())) { return false; } SequenceIterator iter = value.iterate(); while (true) { Item item = iter.next(); if (item == null) { return true; } if (!primaryType.matchesItem(item, false, config)) { return false; } } }
/** * Evaluate the expression as a boolean */ public boolean effectiveBooleanValue(XPathContext context) throws XPathException { SequenceIterator iter = operand.iterate(context); int count = 0; while (true) { Item item = iter.next(); if (item == null) break; count++; if (!targetType.matchesItem(item, false, context.getConfiguration())) { return false; } if (count==2 && !Cardinality.allowsMany(targetCardinality)) { return false; } } return !(count == 0 && ((targetCardinality & StaticProperty.ALLOWS_ZERO) == 0)); }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
private void testConformance(Item item, XPathContext context) throws XPathException { if (!requiredItemType.matchesItem(item, true, (context == null ? null : context.getConfiguration()))) { String message; if (context == null) { // no name pool available message = "Supplied value of type " + Type.displayTypeName(item) + " does not match the required type of " + role.getMessage(); } else { final NamePool pool = context.getNamePool(); final TypeHierarchy th = context.getConfiguration().getTypeHierarchy(); message = role.composeErrorMessage(requiredItemType, Value.asValue(item).getItemType(th), pool); } String errorCode = role.getErrorCode(); if ("XPDY0050".equals(errorCode)) { // error in "treat as" assertion dynamicError(message, errorCode, context); } else { typeError(message, errorCode, context); } } }
private XPathContextMajor initialContext(DynamicQueryContext dynamicEnv, Controller controller) throws XPathException { Item contextItem = dynamicEnv.getContextItem(); controller.defineGlobalParameters(); XPathContextMajor context = controller.newXPathContext(); if (contextItem != null) { if (!staticContext.getUserQueryContext().getRequiredContextItemType().matchesItem( contextItem, false, dynamicEnv.getConfiguration())) { throw new XPathException("The supplied context item does not match the required context item type"); } UnfailingIterator single = SingletonIterator.makeIterator(contextItem); single.next(); context.setCurrentIterator(single); controller.setInitialContextItem(contextItem); } return context; }
private XPathContextMajor initialContext(DynamicQueryContext dynamicEnv, Controller controller) throws XPathException { Item contextItem = dynamicEnv.getContextItem(); controller.defineGlobalParameters(); XPathContextMajor context = controller.newXPathContext(); if (contextItem != null) { if (!staticContext.getUserQueryContext().getRequiredContextItemType().matchesItem( contextItem, false, dynamicEnv.getConfiguration())) { throw new XPathException("The supplied context item does not match the required context item type"); } UnfailingIterator single = SingletonIterator.makeIterator(contextItem); single.next(); context.setCurrentIterator(single); controller.setInitialContextItem(contextItem); } return context; }
if (!reqItemType.matchesItem(item, false, config)) { XPathException err = new XPathException("Required type is " + reqItemType + "; supplied value has type " + Value.asValue(val).getItemType(th));
if (!reqItemType.matchesItem(item, false, config)) { XPathException err = new XPathException("Required type is " + reqItemType + "; supplied value has type " + Value.asValue(val).getItemType(th));
if (!staticContext.getUserQueryContext().getRequiredContextItemType().matchesItem( contextItem, false, env.getConfiguration())) { throw new XPathException("The supplied context item does not match the required context item type");
if (!staticContext.getUserQueryContext().getRequiredContextItemType().matchesItem( contextItem, false, env.getConfiguration())) { throw new XPathException("The supplied context item does not match the required context item type");