*/
public XmlStringBuilder renderRange(Point<N> start, Point<N> end) {
N nearestCommonAncestor =
DocHelper.nearestCommonAncestor(doc, start.getCanonicalNode(), end.getCanonicalNode());
Range inclusion = new Range(doc.getLocation(start), doc.getLocation(end));
XmlStringBuilder builder =
XmlStringBuilder.createEmptyWithCharConstraints(PermittedCharacters.BLIP_TEXT);
E asElement = doc.asElement(nearestCommonAncestor);
if (asElement != null) {
for (N child = doc.getFirstChild(asElement);
child != null; child = doc.getNextSibling(child)) {
builder.append(augmentBuilder(child, inclusion));
}
if (asElement != doc.getDocumentElement()
&& shouldInclude(inclusion, getNodeRange(asElement))) {
builder.wrap(doc.getTagName(asElement),
CollectionUtils.adaptStringMap(doc.getAttributes(asElement)));
}
} else {
T asText = doc.asText(nearestCommonAncestor);
int tStart = doc.getLocation(asText);
String substring =
doc.getData(asText).substring(inclusion.getStart() - tStart, inclusion.getEnd() - tStart);
builder.appendText(substring);
}
return builder;
}