@Override public Stream<? extends XdmAtomicValue> apply(XdmItem item) { if (item instanceof XdmAtomicValue) { return Stream.of((XdmAtomicValue)item); } else if (item instanceof XdmNode) { try { return (XdmStream<XdmAtomicValue>) ((XdmNode) item).getTypedValue().stream(); } catch (SaxonApiException e) { throw new SaxonApiUncheckedException(e); } } else if (item instanceof XdmArray) { try { ArrayItem arrayItem = ((XdmArray)item).getUnderlyingValue(); AtomicSequence data = arrayItem.atomize(); return (XdmStream<XdmAtomicValue>)XdmValue.wrap(data).stream(); } catch (XPathException e) { throw new SaxonApiUncheckedException(new SaxonApiException(e)); } } else { throw new SaxonApiUncheckedException(new SaxonApiException("Cannot atomize supplied value")); } } };
@Override public Stream<? extends XdmAtomicValue> apply(XdmItem item) { if (item instanceof XdmAtomicValue) { return Stream.of((XdmAtomicValue)item); } else if (item instanceof XdmNode) { try { return (XdmStream<XdmAtomicValue>) ((XdmNode) item).getTypedValue().stream(); } catch (SaxonApiException e) { throw new SaxonApiUncheckedException(e); } } else if (item instanceof XdmArray) { try { ArrayItem arrayItem = ((XdmArray)item).getUnderlyingValue(); AtomicSequence data = arrayItem.atomize(); return (XdmStream<XdmAtomicValue>)XdmValue.wrap(data).stream(); } catch (XPathException e) { throw new SaxonApiUncheckedException(new SaxonApiException(e)); } } else { throw new SaxonApiUncheckedException(new SaxonApiException("Cannot atomize supplied value")); } } };