xsl-list
[Top] [All Lists]

Re: [xsl] Re: Wrong indentation with javax.xml.transform.Transformer

2011-09-20 10:17:06
At 2011-09-20 16:29 +0200, you wrote:
On 9/20/2011 1:30 PM, Andrew Welch wrote:
That's correct... you will probably want to strip whitespace only text
nodes from the input (which is fine provided you don't have any 'mixed
content' elements).

If the pretty printer honors the existing whitespace and adds its own
indentation

Why would "pretty print" add its own indentation to something that is already "pretty"?

then repeated application, i.e., in -> pp(in) -> pp(pp(in))
etc, should increase indentation but it doesn't: in and pp(in) may be
different but after that it's a no-op. Why?

Because it is already "pretty" and doesn't need anything more.

Clearly I don't have a good mental model of how the transformer works.

The *only* guideline in the specifications is that the end result be easier to read. XSLT says nothing about *how* to do indentation, and in fact what XSLT 1 says is:

   "may output whitespace in addition to the whitespace in
    the result tree (possibly based on whitespace stripped
    from either the source document or the stylesheet) in
    order to indent the result nicely"

... and what XSLT 2 says is:

   "MAY output whitespace in addition to the whitespace in the
    instance of the data model in order to indent the result
    so that a person will find it easier to read"

If the transformer did nothing, it would be conformant.

And "pretty" (which fits well with the XSLT 1 use of the technical term "nicely") is in the eye of the beholder.

I don't think there can be "wrong" indentation in this case, as implied by your subject line. There is no implication in the specification that indentation is a repetitive and cumulative action.

I hope this helps.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--