XML APIs (Java): how do I know if a document wants to be prettyprinted?

Discussion in 'XML' started by Simon Brooke, Feb 11, 2006.

  1. Simon Brooke

    Simon Brooke Guest

    This relates to my earlier questions about namespaces...

    When I use

    javax.xml.transformer.Transformer.transform(
    javax.xml.transform.Source, javax.xml.transform.Result)

    then, if I pass a DOMResult object as the second argument, there's
    nothing that I can see which I can get back from the DOMResult that
    tells me that it wants the document to be pretty-printed. I can get back
    the node which is the result of the transformation, and that node will
    will in practice be either a document node or an element node. But I
    can't see anything in either the DOM2 or DOM3 specifications for
    Document, Element or Node which says whether they want to be pretty
    printed - and, indeed, nor should there be, because a document is just a
    bit of data and should be agnostic about its representation.

    But the xsl:eek:utput directive takes 'indent="yes"' as a possible
    attribute-value pair. An XSL transform has to be able to tell me that it
    wants to be pretty printed, and it would seem it has to pass that back
    to me in the Result or DOMResult specifications. I just don't see it.

    Am I being stupid?

    --
    (Simon Brooke) http://www.jasmine.org.uk/~simon/


    ... a mild, inoffensive sadist...
     
    Simon Brooke, Feb 11, 2006
    #1
    1. Advertising

  2. Simon Brooke wrote:
    > then, if I pass a DOMResult object as the second argument, there's
    > nothing that I can see which I can get back from the DOMResult that
    > tells me that it wants the document to be pretty-printed.


    Pretty-printing is the serializer's responsibiltiy. If you do a
    transform to SAX or DOM rather than through the serializer, indent will
    generally be ignored, because you're bypassing that portion of the
    processor.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Feb 11, 2006
    #2
    1. Advertising

  3. (More generally: Most of the features of the xsl:eek:utput directive are
    implemented by the serializer and apply only when outputting as a text
    stream... or at most become annotations on the internal XML form, which
    the serializer later acts upon. And the form of those annotations may or
    may not be publicly exposed; check your particular XSLT processor's
    documentation. For example: In some cases, Xalan used to pass hints to
    its own serializers via a processing instruction which the serializer
    acted on and discarded; I haven't checked whether that's still true or
    whether those PIs are suppressed when outputting as DOM or SAX.)

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Feb 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Prichard
    Replies:
    0
    Views:
    772
    Tony Prichard
    Dec 12, 2003
  2. Doug Mitchell
    Replies:
    6
    Views:
    424
  3. Tim Rau

    Doesn't know what it wants

    Tim Rau, Jan 26, 2008, in forum: Python
    Replies:
    11
    Views:
    517
    Tim Rau
    Jan 26, 2008
  4. dave
    Replies:
    2
    Views:
    97
    Gene Tani
    Jun 2, 2006
  5. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    262
    Gregory Toomey
    Apr 23, 2004
Loading...

Share This Page