/** * Implement the MappingFunction interface */ public SequenceIterator map(Item item) throws XPathException { KeyManager keyManager = keyContext.getController().getKeyManager(); AtomicValue keyValue; if (item instanceof AtomicValue) { keyValue = (AtomicValue)item; } else { keyValue = new StringValue(item.getStringValue()); } return keyManager.selectByKey(keySet, document, keyValue, keyContext); } }
/** * Implement the MappingFunction interface */ public SequenceIterator map(Item item) throws XPathException { KeyManager keyManager = keyContext.getController().getKeyManager(); AtomicValue keyValue; if (item instanceof AtomicValue) { keyValue = (AtomicValue)item; } else { keyValue = new StringValue(item.getStringValue()); } return keyManager.selectByKey(keySet, document, keyValue, keyContext); } }
/** * Implement the MappingFunction interface */ public SequenceIterator map(Item item) throws XPathException { KeyManager keyManager = keyContext.getController().getKeyManager(); AtomicValue keyValue; if (item instanceof AtomicValue) { keyValue = (AtomicValue)item; } else { keyValue = new StringValue(item.getStringValue()); } return keyManager.selectByKey(keySet, document, keyValue, keyContext); } }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException */ public static SequenceIterator getIdrefMultiple(DocumentInfo doc, SequenceIterator keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator allValues = new MappingIterator(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException if a dynamic error occurs */ public static SequenceIterator<NodeInfo> getIdrefMultiple(TreeInfo doc, SequenceIterator<StringValue> keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator<? extends NodeInfo> allValues = new MappingIterator<>(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException */ public static SequenceIterator getIdrefMultiple(DocumentInfo doc, SequenceIterator keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator allValues = new MappingIterator(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException */ public static SequenceIterator getIdrefMultiple(DocumentInfo doc, SequenceIterator keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator allValues = new MappingIterator(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
/** * Get the result when multiple idref values are supplied. Note this is also called from * compiled XQuery code. * * @param doc the document to be searched * @param keys the idref values supplied * @param context the dynamic execution context * @return iterator over the result of the function * @throws XPathException if a dynamic error occurs */ public static SequenceIterator<NodeInfo> getIdrefMultiple(TreeInfo doc, SequenceIterator<StringValue> keys, XPathContext context) throws XPathException { IdrefMappingFunction map = new IdrefMappingFunction(); map.document = doc; map.keyContext = context; map.keyManager = context.getController().getKeyManager(); map.keySet = map.keyManager.getKeyDefinitionSet(StandardNames.getStructuredQName(StandardNames.XS_IDREFS)); SequenceIterator<? extends NodeInfo> allValues = new MappingIterator<>(keys, map); return new DocumentOrderIterator(allValues, LocalOrderComparer.getInstance()); }
dynamicError("Invalid key name: " + err.getMessage(), "XTDE1260", context); selectedKeySet = controller.getKeyManager().getKeyDefinitionSet(qName); if (selectedKeySet == null) { dynamicError("Key '" + givenkeyname + "' has not been defined", "XTDE1260", context); final XPathContext keyContext = context; final DocumentInfo document = doc; final KeyManager keyManager = controller.getKeyManager(); final KeyDefinitionSet keySet = selectedKeySet; MappingFunction map = new MappingFunction() { return EmptyIterator.getInstance(); KeyManager keyManager = controller.getKeyManager(); allResults = keyManager.selectByKey(selectedKeySet, doc, keyValue, context); } catch (XPathException e) {
dynamicError("Invalid key name: " + err.getMessage(), "XTDE1260", context); selectedKeySet = controller.getKeyManager().getKeyDefinitionSet(qName); if (selectedKeySet == null) { dynamicError("Key '" + givenkeyname + "' has not been defined", "XTDE1260", context); final XPathContext keyContext = context; final DocumentInfo document = doc; final KeyManager keyManager = controller.getKeyManager(); final KeyDefinitionSet keySet = selectedKeySet; MappingFunction map = new MappingFunction() { return EmptyIterator.getInstance(); KeyManager keyManager = controller.getKeyManager(); allResults = keyManager.selectByKey(selectedKeySet, doc, keyValue, context); } catch (XPathException e) {
dynamicError("Invalid key name: " + err.getMessage(), "XTDE1260", context); selectedKeySet = controller.getKeyManager().getKeyDefinitionSet(qName); if (selectedKeySet == null) { dynamicError("Key '" + givenkeyname + "' has not been defined", "XTDE1260", context); final XPathContext keyContext = context; final DocumentInfo document = doc; final KeyManager keyManager = controller.getKeyManager(); final KeyDefinitionSet keySet = selectedKeySet; MappingFunction map = new MappingFunction() { return EmptyIterator.getInstance(); KeyManager keyManager = controller.getKeyManager(); allResults = keyManager.selectByKey(selectedKeySet, doc, keyValue, context); } catch (XPathException e) {
return false; KeyManager km = context.getController().getKeyManager(); SequenceIterator iter = keyexp.iterate(context); while (true) {
return false; KeyManager km = context.getController().getKeyManager(); SequenceIterator iter = keyExpression.iterate(context); while (true) {
/** * Enumerate the results of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); NodeInfo arg2 = (NodeInfo)argument[1].evaluateItem(context); arg2 = arg2.getRoot(); if (arg2.getNodeKind() != Type.DOCUMENT) { dynamicError("In the idref() function," + " the tree being searched must be one whose root is a document node", "FODC0001", context); return null; } DocumentInfo doc = (DocumentInfo)arg2; // If the argument is a singleton, we evaluate the function // directly; otherwise we recurse to evaluate it once for each Item // in the sequence. Expression expression = argument[0]; if (Cardinality.allowsMany(expression.getCardinality())) { SequenceIterator keys = argument[0].iterate(context); return getIdrefMultiple(doc, keys, context); } else { AtomicValue keyValue = (AtomicValue)argument[0].evaluateItem(context); if (keyValue == null) { return EmptyIterator.getInstance(); } KeyManager keyManager = controller.getKeyManager(); return keyManager.selectByKey(idRefKey, doc, keyValue, context); } }
return false; KeyManager km = context.getController().getKeyManager(); SequenceIterator iter = keyexp.iterate(context); while (true) {
/** * Enumerate the results of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); NodeInfo arg2 = (NodeInfo)argument[1].evaluateItem(context); arg2 = arg2.getRoot(); if (arg2.getNodeKind() != Type.DOCUMENT) { dynamicError("In the idref() function," + " the tree being searched must be one whose root is a document node", "FODC0001", context); return null; } DocumentInfo doc = (DocumentInfo)arg2; // If the argument is a singleton, we evaluate the function // directly; otherwise we recurse to evaluate it once for each Item // in the sequence. Expression expression = argument[0]; if (Cardinality.allowsMany(expression.getCardinality())) { SequenceIterator keys = argument[0].iterate(context); return getIdrefMultiple(doc, keys, context); } else { AtomicValue keyValue = (AtomicValue)argument[0].evaluateItem(context); if (keyValue == null) { return EmptyIterator.getInstance(); } KeyManager keyManager = controller.getKeyManager(); return keyManager.selectByKey(idRefKey, doc, keyValue, context); } }
/** * Enumerate the results of the expression */ public SequenceIterator iterate(XPathContext context) throws XPathException { Controller controller = context.getController(); NodeInfo arg2 = (NodeInfo)argument[1].evaluateItem(context); arg2 = arg2.getRoot(); if (arg2.getNodeKind() != Type.DOCUMENT) { dynamicError("In the idref() function," + " the tree being searched must be one whose root is a document node", "FODC0001", context); return null; } DocumentInfo doc = (DocumentInfo)arg2; // If the argument is a singleton, we evaluate the function // directly; otherwise we recurse to evaluate it once for each Item // in the sequence. Expression expression = argument[0]; if (Cardinality.allowsMany(expression.getCardinality())) { SequenceIterator keys = argument[0].iterate(context); return getIdrefMultiple(doc, keys, context); } else { AtomicValue keyValue = (AtomicValue)argument[0].evaluateItem(context); if (keyValue == null) { return EmptyIterator.getInstance(); } KeyManager keyManager = controller.getKeyManager(); return keyManager.selectByKey(idRefKey, doc, keyValue, context); } }