« Return to Thread: minor XML question

Re: minor XML question

by Normen Mueller :: Rate this Message:

Reply to Author | View in Thread

Burak Emir wrote:
> no, nobody wants to send a patch that would parameterize the printing
> routines. I would suggest subclassing the PrettyPrinter class.
>
That's more or less what I did.  But, I sub-classed PrettyPrinter and wrote my own xml.Utility, so that:

protected def traverse(node: Node,pscope: NamespaceBinding,ind: Int): Unit =
[...]
case _ =>
        val test = {
          val sb = new StringBuilder()
          nrm.xml.Utility.toXML(node, pscope, sb, false)

nrm.xml.Utility.toXML takes care of the rest:

[...[
case _  =>
        sb.append('<')
        x.nameToString(sb)
        if (x.attributes ne null) x.attributes.toString(sb)
        x.scope.toString(sb, pscope)
        if(! x.child.isEmpty) {
          [...]
        } else sb.append("/>")

That's works quite well for me, but I don't know if this is the correct/ most elegant way.

Cheers,
  /nm

 « Return to Thread: minor XML question