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:
@@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user