This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Re: Problem with XML PrettyPrinter and Node toString in general

1 reply
normen.mueller
Joined: 2008-10-31,
User offline. Last seen 3 years 8 weeks ago.

Geoffrey Alan Washburn-4 wrote:
>
> Ronald Steinhau wrote:
>> A node is converted to by both toString and the
>> PrettyPrinter. I think this is wrong and in an eclipse plugin.xml file
>> it may even cause trouble (an extension point is sometimes not
>> recognized when not using the short form - although I think this should
>> be seen as an eclipse bug).Anyway, for the PrettyPrinter I changed line
>> 175-177 (final 2.7.2 sources) to
>> if (childrenAreLeaves(node) && fits(test)) {
>> makeBox(ind, leafTag(node))
>> } else {
>> and than it worked for me. If the resp. committer thinks this is
>> correct, I hope it will find its way into the source. And even better,
>> toString should be corrected in the same manner.
>

Sorry for possibly sending this message twice, but my mail client crashed
and I don't know if the previous one got through.

I incorporated your change, namespace declarations are lost, though. For
example:

var xml = ()
println(new MyPrettyPrinter(220,2).format(xml))

The output is

Do you have any suggestions?

Cheers,

normen.mueller
Joined: 2008-10-31,
User offline. Last seen 3 years 8 weeks ago.
Re: Re: Problem with XML PrettyPrinter and Node toString in ge

In addition to Ronald's changes I have done the following:

protected def leafTag(n: Node, pscope: NamespaceBinding) = {
val sb = new StringBuilder("<")
n.nameToString(sb)
//Utility.appendPrefixedName( n.prefix, n.label, pmap, sb );
n.attributes.toString(sb)
n.scope.toString(sb, pscope)
//Utility.attr2xml( n.scope, n.attributes, pmap, sb );
sb.append("/>")
sb.toString()
}

That is, I have added the additional "pscope" parameter to "leafTag" and
added the line "n.scope.toString(sb, pscope)". Now it works for me.

Normen Mueller wrote:
>
>
>
> Geoffrey Alan Washburn-4 wrote:
>>
>> Ronald Steinhau wrote:
>>> A node is converted to by both toString and the
>>> PrettyPrinter. I think this is wrong and in an eclipse plugin.xml file
>>> it may even cause trouble (an extension point is sometimes not
>>> recognized when not using the short form - although I think this should
>>> be seen as an eclipse bug).Anyway, for the PrettyPrinter I changed line
>>> 175-177 (final 2.7.2 sources) to
>>> if (childrenAreLeaves(node) && fits(test)) {
>>> makeBox(ind, leafTag(node))
>>> } else {
>>> and than it worked for me. If the resp. committer thinks this is
>>> correct, I hope it will find its way into the source. And even better,
>>> toString should be corrected in the same manner.
>>
>
> Sorry for possibly sending this message twice, but my mail client crashed
> and I don't know if the previous one got through.
>
> I incorporated your change, namespace declarations are lost, though. For
> example:
>
> var xml = ( />)
> println(new MyPrettyPrinter(220,2).format(xml))
>
> The output is
>
>
>
> Do you have any suggestions?
>
> Cheers,

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland