Saxon is indenting my attributes

  • MetinH

    MetinH - 2009-06-25

    Hello everyone. I'm having a problem with saxon indenting my attributes when transforming a document using XSLT. I'm using Java 6 and the Saxon 9 jars.

    Exhibited behavior:
    <oa:ItemID xmlns:oa="http://www.blah/9"

    Desired Behavior:
    <oa:ItemID xmlns:oa="http://www.blah/9" agencyRole="Number">

    I would like the opening tag to be on one line. Furthermore, the indenting is done using spaces and not tabs. All these spaces are bytes which, in turn, significantly bump up the size of my output xml file by roughly 20%. Normally, this would not be a big deal, however my output xml file is about 1 GB.

    When I run the same xslt through XML Spy, I don't have this problem.

    Does anyone have any suggestions on how to fix this? Thanks in advance for your help!

    • Michael Kay

      Michael Kay - 2009-06-25

      If you're worried about file size, don't use indenting.

      Indenting is only useful for files intended for a human reader. I find it hard to imagine a 1Gb output file being intended for a human reader.

      The reason attributes are indented like this is because it's not uncommon for an element to have 10 namespace declarations each about 60 characters long, and it's very hard to read a document containing a single line of 600 characters. The whole purpose of indent=yes is to make it easier for human readers to read the document.

      The reason for not using tabs is that it's completely unpredictable how tabs will be displayed.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks