throw new RuntimeException("'id' XPath expression '"+idXPath+"' does not return a text node: "+e);
throw new SAXException("'id' XPath expression '"+idXPath+"' does not return a text node: "+e, e);
    private Document addIds(Document doc, String elementXPath, String idXPath) throws SAXException {        getLogger().debug("## Using element XPath "+elementXPath);        NodeList sects = processor.selectNodeList(doc, elementXPath);        getLogger().debug("## .. got "+sects.getLength()+" sections");        for (int i=0; i<sects.getLength(); i++) {            Element sect = (Element)sects.item(i);            sect.normalize();            getLogger().debug("## Using id XPath "+idXPath);            String id = null;            try {              id = processor.evaluateAsString(sect, idXPath);            } catch (Exception e) {                throw new RuntimeException("'id' XPath expression '"+idXPath+"' does not return a text node: "+e);            }            getLogger().info("## Got id "+id);            if (!sect.hasAttribute(this.idAttr)) {                String newId = URLEncoder.encode(id);                newId = avoidConflicts(doc, sect, this.idAttr, newId);                // Upgrade to DOM 2 support                //sect.setAttribute(this.idAttr, newId);                sect.setAttributeNS(sect.getNamespaceURI(), this.idAttr, newId);            }        }        return doc;    }