Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.6
    • 2.7
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • None
    • Operating System: Solaris
      Platform: Sun
    • 30622

    Description

      I'm converting an input XML file into an output XML file using 'java
      org.apache.xalan.xslt.Process". Some of the input XML elements are output as
      is, some are modified, and some new ones are introduced via the XSL style sheet
      using xml:element. All elements which are pased through as is or are modified
      appear to be indented as expected. However, elements created via xsl:element do
      not appear to be indented correctly: the opening tag appears to always be
      indented, but all subelements created after that and the closing tag are not
      indented at all.

      This is not inducing any errors downstream; it only makes the file more
      difficult for people to read.

      Attachments

        Activity

          keshlam@us.ibm.com Joe Kesselman added a comment -

          Probably working as designed.

          Copied stuff is undoubtedly including whitespace from the source document rather
          than being indented by Xalan.

          Xalan-generated indentation defaults to line-break only. To actually indent, you
          need to specify how much indentation should occur per level, by adding the
          attribute xalan:indent-amount="5" (or however much) to your <xsl:output> directive.

          (Yes, there have been extensive arguments about whether 0 is the best default.
          No, I don't think it is. We can bring it up on the mailing list again and see if
          anyone has changed their minds...)

          This really should be added to our FAQ page!

          keshlam@us.ibm.com Joe Kesselman added a comment - Probably working as designed. Copied stuff is undoubtedly including whitespace from the source document rather than being indented by Xalan. Xalan-generated indentation defaults to line-break only. To actually indent, you need to specify how much indentation should occur per level, by adding the attribute xalan:indent-amount="5" (or however much) to your <xsl:output> directive. (Yes, there have been extensive arguments about whether 0 is the best default. No, I don't think it is. We can bring it up on the mailing list again and see if anyone has changed their minds...) This really should be added to our FAQ page!
          ed.knoll@cosd.fedex.com Ed Knoll added a comment -

          Tried to update the output statement; did not effect my indentation. Here's my
          invocation sequence for the translator:

          java org.apache.xalan.xslt.Process -xml -in <infile> -xsl <xslfile> ...

          Here's the output statement I'm using in the xsl file:

          <xsl:output method="xml" encoding="UTF-8" standalone="yes"
          indent="yes" xalan:indent-amount="3" />

          Here's some extracts from the output file (hopefully w/ whitespace perserved):

          <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          <Results xmlns="http://fedex.com/gnsl">
          <QueryString>
          <INLINE>true</INLINE>
          </QueryString>
          <package-possession-enhancement>
          <acceptance-date-time>
          <raw>20040727232400Z-0600</raw>
          <formatted formatType="date-time">20040727232400Z-0600</formatted>
          </acceptance-date-time>
          <packaging-type>01</packaging-type>

          ed.knoll@cosd.fedex.com Ed Knoll added a comment - Tried to update the output statement; did not effect my indentation. Here's my invocation sequence for the translator: java org.apache.xalan.xslt.Process -xml -in <infile> -xsl <xslfile> ... Here's the output statement I'm using in the xsl file: <xsl:output method="xml" encoding="UTF-8" standalone="yes" indent="yes" xalan:indent-amount="3" /> Here's some extracts from the output file (hopefully w/ whitespace perserved): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Results xmlns="http://fedex.com/gnsl"> <QueryString> <INLINE>true</INLINE> </QueryString> <package-possession-enhancement> <acceptance-date-time> <raw>20040727232400Z-0600</raw> <formatted formatType="date-time">20040727232400Z-0600</formatted> </acceptance-date-time> <packaging-type>01</packaging-type>
          keshlam@us.ibm.com Joe Kesselman added a comment -

          Sanity checks:

          1) You did remember to declare the xalan: namespace, right?
          xmlns:xalan="http://xml.apache.org/xalan"

          2) Note that indent currently applies only when you're running through our
          serializer. If you're outputting to a DOM, or to a SAX stream, it will probably
          have no effect. There was some recent debate about whether it should affect
          these representations or not, which as far as I know came to no clear
          conclusion; it really isn't clear from the spec whether this directive is
          supposed to alter the result tree or only the serialized form thereof, and
          whether a DOM (for example) represents the former or the latter.

          keshlam@us.ibm.com Joe Kesselman added a comment - Sanity checks: 1) You did remember to declare the xalan: namespace, right? xmlns:xalan="http://xml.apache.org/xalan" 2) Note that indent currently applies only when you're running through our serializer. If you're outputting to a DOM, or to a SAX stream, it will probably have no effect. There was some recent debate about whether it should affect these representations or not, which as far as I know came to no clear conclusion; it really isn't clear from the spec whether this directive is supposed to alter the result tree or only the serialized form thereof, and whether a DOM (for example) represents the former or the latter.
          ed.knoll@cosd.fedex.com Ed Knoll added a comment -

          Yes, but which one? Turns out there are two different ones I've come across in
          the Xalan online documentation (and the one you've listed is the wrong one):

          xmlns:xalan="http://xml.apache.org/xalan" – used for nodeset

          xmlns:xalan="http://xml.apache.org/xslt" – used for xalan:ident-amount

          I renamed the second one to 'xslt' and used 'xslt:indent-amount'. This fixed my
          indent problem.

          I might suggest that someone should change the online documentation to not have
          two different definitions for the 'xalan:' namespace.

          ed.knoll@cosd.fedex.com Ed Knoll added a comment - Yes, but which one? Turns out there are two different ones I've come across in the Xalan online documentation (and the one you've listed is the wrong one): xmlns:xalan="http://xml.apache.org/xalan" – used for nodeset xmlns:xalan="http://xml.apache.org/xslt" – used for xalan:ident-amount I renamed the second one to 'xslt' and used 'xslt:indent-amount'. This fixed my indent problem. I might suggest that someone should change the online documentation to not have two different definitions for the 'xalan:' namespace.
          keshlam@us.ibm.com Joe Kesselman added a comment -

          Sorry about the error, and good catch. Yes, we should either unify those two
          namespaces or document the distinction between them more clearly.

          At least we've got you back on the air...

          keshlam@us.ibm.com Joe Kesselman added a comment - Sorry about the error, and good catch. Yes, we should either unify those two namespaces or document the distinction between them more clearly. At least we've got you back on the air...

          People

            Unassigned Unassigned
            ed.knoll@cosd.fedex.com Ed Knoll
            Votes:
            0 Vote for this issue
            Watchers:
            Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment