Problems with whitespace in output document

Discussion in 'XML' started by Michael Kragh Pedersen, Mar 14, 2005.

  1. I have made an XSLT document, looking like this.

    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput indent="yes" method="text"/>
    <xsl:template match="/">
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <xsl:apply-templates/>
    </BODY>
    </HTML>
    </xsl:template>
    <xsl:template match="*">
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>

    Nothing fancy about that, just writing out the elements. So I get this
    output, when I see it in the browser (Mozilla on Linux).

    A
    B
    E
    F

    C
    D

    But I want for it to be flattened, so all of the elements are aligned
    left. I feel like, I have tried everything, with xsl:eek:utput and
    normalize-string(), and I have no idea, how to remove the whitespace.

    I also tried removing all the whitespace from my XML document, that
    didn't help either.

    Anybody with some good ideas?

    Michael K. P.
    Michael Kragh Pedersen, Mar 14, 2005
    #1
    1. Advertising

  2. Michael Kragh Pedersen <> writes:

    > I have made an XSLT document, looking like this.
    >
    > <xsl:stylesheet version="2.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    > <xsl:eek:utput indent="yes" method="text"/>


    If you use the text output method, there is no indentation possible also
    all element nodes in the result tree will be discarded, so you could
    drop HTML etc from the code below and get the same result.

    > <xsl:template match="/">
    > <HTML>
    > <HEAD>
    > <TITLE></TITLE>
    > </HEAD>
    > <BODY>
    > <xsl:apply-templates/>


    Note this also applies templates to text nodes so will copy any
    indentation and other white space to the output.

    > </BODY>
    > </HTML>
    > </xsl:template>
    > <xsl:template match="*">
    > <xsl:apply-templates/>

    similarly this.
    > </xsl:template>
    > </xsl:stylesheet>



    Perhaps you want to add <xsl:strip-space elements="*"/> so that white
    space nodes in the input are ignored, but if you output using the html
    output method then unless you use <pre> or equivalent css then newlines
    in the result won't render as newlines anyway si teh result should not
    look like the result you show below when rendered in the browser.

    > Nothing fancy about that, just writing out the elements. So I get this
    > output, when I see it in the browser (Mozilla on Linux).
    >
    > A
    > B
    > E
    > F
    >
    > C
    > D
    >
    > But I want for it to be flattened, so all of the elements are aligned
    > left. I feel like, I have tried everything, with xsl:eek:utput and
    > normalize-string(), and I have no idea, how to remove the whitespace.
    >
    > I also tried removing all the whitespace from my XML document, that
    > didn't help either.
    >
    > Anybody with some good ideas?
    >
    > Michael K. P.


    David
    David Carlisle, Mar 14, 2005
    #2
    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. Oli Filth
    Replies:
    9
    Views:
    3,323
    Uncle Pirate
    Jan 17, 2005
  2. Andy Fish
    Replies:
    2
    Views:
    509
    Andy Fish
    Jun 15, 2004
  3. Replies:
    10
    Views:
    738
    Eric Brunel
    Dec 16, 2008
  4. MRAB
    Replies:
    3
    Views:
    383
  5. Ralph Amissah
    Replies:
    0
    Views:
    182
    Ralph Amissah
    Nov 20, 2005
Loading...

Share This Page