in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/XMLUtil.java [253:318]
public static String theSomethingElement(Element elem, boolean capFirst) {
String id = getAttribute(elem, "id");
if (id == null) {
id = getAttribute(elem, "xml:id");
}
if (id != null && (id.startsWith(Transform.AUTO_ID_PREFIX)
|| id.startsWith(Transform.DOCGEN_ID_PREFIX))) {
id = null;
}
StringBuilder sb = new StringBuilder();
if (id != null || elem.getParentNode() instanceof Document) {
sb.append("the \"");
} else {
sb.append("a(n) \"");
}
sb.append(elem.getLocalName());
sb.append("\" element");
if (id != null) {
sb.append(" with xml:id=\"").append(id).append("\"");
}
Location loc = (Location) elem.getUserData(
ValidatingDOMBuilderWithLocations.KEY_LOCATION);
if (loc != null) {
sb.append(" (location: ");
boolean empty = true;
String sysId = loc.getSystemId();
if (sysId != null) {
// Since it goes into the middle of other error messages,
// keep only the file name and the containing directory name:
int slashIdx = sysId.lastIndexOf("/");
if (slashIdx != -1) {
slashIdx = sysId.lastIndexOf("/", slashIdx - 1);
if (slashIdx > 0) {
sysId = "[...]" + sysId.substring(slashIdx);
}
}
sb.append(sysId);
empty = false;
}
if (loc.getLine() > 0) {
if (!empty) {
sb.append(':');
}
sb.append(loc.getLine());
empty = false;
}
if (loc.getColumn() > 0) {
if (!empty) {
sb.append(':');
}
sb.append(loc.getColumn());
}
sb.append(")");
}
if (capFirst) {
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
}
return sb.toString();
}