Search in sources :

Example 6 with XMLString

use of org.exist.util.XMLString in project exist by eXist-db.

the class Indexer method processText.

private void processText(ElementImpl last, ProcessTextParent ptp) {
    // from startElement method
    if (charBuf != null && charBuf.length() > 0) {
        XMLString normalized = null;
        switch(ptp) {
            case COMMENT:
            case PI:
            case CDATA_START:
                normalized = charBuf;
                break;
            default:
                if (charBuf.isWhitespaceOnly()) {
                    if (last.preserveSpace() || last.getChildCount() == 0) {
                        normalized = charBuf;
                    } else if (preserveWSmixed) {
                        if (!(last.getChildCount() == 0 && (normalize & XMLString.SUPPRESS_LEADING_WS) != 0)) {
                            normalized = charBuf;
                        }
                    } else {
                        normalized = charBuf.normalize(normalize);
                    }
                } else {
                    // normalized = charBuf;
                    if (last.preserveSpace()) {
                        normalized = charBuf;
                    } else if (last.getChildCount() == 0) {
                        normalized = charBuf.normalize(normalize);
                    } else {
                        // just check if there is any text at all
                        if (preserveWSmixed) {
                            normalized = charBuf;
                        } else {
                            if ((normalize & XMLString.SUPPRESS_LEADING_WS) != 0) {
                                normalized = charBuf.normalize(XMLString.SUPPRESS_LEADING_WS | XMLString.COLLAPSE_WS);
                            } else if ((normalize & XMLString.SUPPRESS_TRAILING_WS) != 0) {
                                normalized = charBuf.normalize(XMLString.SUPPRESS_TRAILING_WS | XMLString.COLLAPSE_WS);
                            } else {
                                // normalized = charBuf.normalize(XMLString.COLLAPSE_WS);
                                normalized = charBuf.normalize(normalize);
                            }
                        }
                    }
                }
        }
        if (normalized != null) {
            text.setData(normalized);
            text.setOwnerDocument(document);
            last.appendChildInternal(prevNode, text);
            if (!validate)
                storeText();
            setPrevious(text);
        }
        charBuf.reset();
    }
}
Also used : XMLString(org.exist.util.XMLString)

Example 7 with XMLString

use of org.exist.util.XMLString in project exist by eXist-db.

the class Indexer method storeElement.

private void storeElement(final ElementImpl node) {
    broker.storeNode(transaction, node, currentPath, indexSpec);
    if (indexListener != null) {
        indexListener.startElement(transaction, node, currentPath);
    }
    node.setChildCount(0);
    if (RangeIndexSpec.hasQNameOrValueIndex(node.getIndexType())) {
        final XMLString contentBuf = new XMLString();
        nodeContentStack.push(contentBuf);
    }
}
Also used : XMLString(org.exist.util.XMLString)

Aggregations

XMLString (org.exist.util.XMLString)7 ElementImpl (org.exist.dom.persistent.ElementImpl)2 CDATASectionImpl (org.exist.dom.persistent.CDATASectionImpl)1 NodeId (org.exist.numbering.NodeId)1