Update tree dump references

I tweaked the printer so that the
modifiers are printed not as separate
attributes. Eventually I think this
is how it should be done: no separate
attributes, but instead a function
 in XPath
This commit is contained in:
Clément Fournier
2020-08-23 16:26:52 +02:00
parent e410c2e561
commit 58794b08af
20 changed files with 1084 additions and 1602 deletions

View File

@@ -38,19 +38,29 @@ open class RelevantAttributePrinter : BaseNodeAttributePrinter() {
*/
open class BaseNodeAttributePrinter : TextTreeRenderer(true, -1) {
data class AttributeInfo(val name: String, val value: String?)
protected open fun ignoreAttribute(node: Node, attribute: Attribute): Boolean = true
protected open fun getAttributes(node: Node): Iterable<AttributeInfo> =
node.xPathAttributesIterator
.asSequence()
.filterNot { ignoreAttribute(node, it) }
.map { AttributeInfo(it.name, it.value?.toString()) }
.asIterable()
override fun appendNodeInfoLn(out: Appendable, node: Node) {
out.append(node.xPathNodeName)
node.xPathAttributesIterator
.asSequence()
// sort to get deterministic results
.sortedBy { it.name }
.filterNot { ignoreAttribute(node, it) }
.joinTo(buffer = out, prefix = "[", postfix = "]") {
"@${it.name} = ${valueToString(it.value)}"
}
val attrs = getAttributes(node).toMutableList()
// sort to get deterministic results
attrs.sortBy { it.name }
attrs.joinTo(buffer = out, prefix = "[", postfix = "]") {
"@${it.name} = ${valueToString(it.value)}"
}
out.append("\n")
}