private int stringifyItem(XdmItem item, StringBuilder thisVal, int numberOfVals) {
        if (item instanceof XdmAtomicValue) {
            if (numberOfVals > 0) {
                thisVal.append(multipleValueDelimiter);
            }
            String value = item.getStringValue();
            thisVal.append(value);
            numberOfVals++;
        } else if (item instanceof final XdmNode node) {
            XdmNodeKind type = node.getNodeKind();

            if (type == XdmNodeKind.ELEMENT) {
                boolean hasChildElement = false;
                XdmSequenceIterator<XdmNode> iterator = node.axisIterator(Axis.ATTRIBUTE);
                while (iterator.hasNext()) {
                    final XdmNode childNode = iterator.next();
                    final XdmNodeKind childType = childNode.getNodeKind();
                    if (childType == XdmNodeKind.ATTRIBUTE) {
                        hasChildElement = true;
                        break;
                    }
                }
                if (!hasChildElement) {
                    iterator = node.axisIterator(Axis.CHILD);
                    while (iterator.hasNext()) {
                        final XdmNode childNode = iterator.next();
                        final XdmNodeKind childType = childNode.getNodeKind();
                        if (childType == XdmNodeKind.ELEMENT) {
                            hasChildElement = true;
                            break;
                        }
                    }
                }

                if (hasChildElement) {
                    boolean createJson = false;
                    if (createJson) {
                        String serialisedForm = complexElementToJson(node.toString());
                        thisVal.append(serialisedForm);
                    } else {
                        thisVal.append(node);
                    }
                    numberOfVals++;
                } else {
                    iterator = node.axisIterator(Axis.CHILD);
                    while (iterator.hasNext()) {
                        XdmNode childNode = iterator.next();
//                        if (item instanceof XdmAtomicValue) {
//                            if (numberOfVals > 0) {
//                                thisVal.append(multipleValueDelimiter);
//                            }
//                            String value = item.getStringValue();
//                            thisVal.append(value);
//                            numberOfVals++;
//                        } else if (item instanceof XdmNode) {
//                            XdmNode childNode = child;
                        XdmNodeKind childType = childNode.getNodeKind();

                        if (childType == XdmNodeKind.TEXT) {
                            if (numberOfVals > 0) {
                                thisVal.append(multipleValueDelimiter);
                            }
                            String value = item.getStringValue();
                            thisVal.append(value);
                            numberOfVals++;
                        }
//                        }
                    }
                }
            } else {
                if (numberOfVals > 0) {
                    thisVal.append(multipleValueDelimiter);
                }
                numberOfVals++;
                thisVal.append(item.getStringValue());
            }
        } else {
            log(Severity.ERROR, LogUtil.message("Unknown type of XdmItem:{}", item.getClass().getName()), null);
        }

        return numberOfVals;
    }
Sets the locator to use when reporting errors.

@param locator The locator to use.
stroom-search/stroom-search-extraction/src/main/java/stroom/search/extraction/XPathExtractionOutputFilter.java