Search in sources :

Example 1 with Characters

use of org.exist.util.sax.event.contenthandler.Characters in project exist by eXist-db.

the class ConfigurationDocumentTrigger method findName.

/**
 * Attempts to find and extract the text value
 * of the name element from the deferred elements
 *
 * @return The text value of the name element, or null otherwise
 */
private String findName() {
    boolean inName = false;
    final StringBuilder name = new StringBuilder();
    for (final SAXEvent event : deferred) {
        if (event instanceof Element) {
            final Element element = (Element) event;
            if (element.namespaceURI != null && element.namespaceURI.equals(Configuration.NS) && element.localName.equals("name")) {
                inName = !inName;
            }
        }
        if (inName && event instanceof Characters) {
            name.append(((Characters) event).ch);
        }
    }
    if (name.length() > 0) {
        return name.toString().trim();
    } else {
        return null;
    }
}
Also used : SAXEvent(org.exist.util.sax.event.SAXEvent) EndElement(org.exist.util.sax.event.contenthandler.EndElement) StartElement(org.exist.util.sax.event.contenthandler.StartElement) Element(org.exist.util.sax.event.contenthandler.Element) Characters(org.exist.util.sax.event.contenthandler.Characters)

Aggregations

SAXEvent (org.exist.util.sax.event.SAXEvent)1 Characters (org.exist.util.sax.event.contenthandler.Characters)1 Element (org.exist.util.sax.event.contenthandler.Element)1 EndElement (org.exist.util.sax.event.contenthandler.EndElement)1 StartElement (org.exist.util.sax.event.contenthandler.StartElement)1