Publishing HTML with line breaks and indents

Michael McGinnis's Avatar

Michael McGinnis

29 Jun, 2011 04:09 PM

How do I create my XSLT so that the published HTML is pretty-printed with indents and line breaks between divs? My XSLT includes this formatting, but it's stripped out when publishing. The intriguing thing is that not all formatting is stripped out. Some code that I pasted from a Mac user (Archives and Contact links) has preserved its indentation, but all the lines before and after it run together.

<div id="newsFeatures"><div id="featureFullWrapper"><div id="featureLinks"><a href="/subscribe/">Subscribe</a> | 
            <a href="/archives/">Archives</a> | 
            <a href="/contact/">Contact</a></div></div><div id="featureBlock"><h2 class="mainFeatureTitle">It's our time!</h2>

I thought it might be caused by Cascade not recognizing my Linux line endings, but cutting and pasting the Mac line endings didn't work, and editing the file with Windows Notepad didn't either.

  1. Support Staff 1 Posted by Tim on 11 Jul, 2011 07:03 PM

    Tim's Avatar

    You'll want to try using the <xsl:text> element to force line breaks in your XSLT. For example:

    <p>This text will be on line 1.</p><xsl:text>
    </xsl:text><p>This text will be on line 2.</p>

    To make the code a little easier to read in your XSLT Format, you could make a new template:

    <xsl:template name="newline">

    then call that template any time you need a new line:

    <p>This text will be on line 1.</p>
    <xsl:call-template name="newline"/> 
    <p>This text will be on line 2.</p>

    In general it's going to be difficult to get your indents just right in your Format since both the XSLT processor (Xalan) and the serializer in Cascade tend to ignore them.

    Hope this helps.

  2. 2 Posted by Michael McGinni... on 11 Jul, 2011 08:54 PM

    Michael McGinnis's Avatar

    Thanks, that solution works. Except, if I switched to a Mac, I wouldn't need to use it. Why can't it be just as easy with Windows or Linux?

  3. Support Staff 3 Posted by Tim on 12 Jul, 2011 03:40 PM

    Tim's Avatar

    Yea, it's a little frustratng because all 3 platforms terminate lines in slightly different ways. This causes all sorts of problems for many applications that process text. It will likely also depend on which XSL processor is in use. Cascade Server is uses the Xalan processor.

    Glad I was able to help out with the XSLT!

  4. Tim closed this discussion on 12 Jul, 2011 03:40 PM.

  5. Michael McGinnis re-opened this discussion on 14 Jul, 2015 11:02 PM

  6. 4 Posted by Michael McGinni... on 14 Jul, 2015 11:02 PM

    Michael McGinnis's Avatar

    I just discovered: you can add line feeds (blank lines) in templates by typing &#10;. For example, type </div>&#10;<div> and Cascade Server will publish it with a blank line between the divs. This greatly improve readability of your HTML code.

  7. Michael McGinnis closed this discussion on 14 Jul, 2015 11:03 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM