[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Using mode removes linebreaks/indents

Subject: Re: Using mode removes linebreaks/indents
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 19 Apr 2013 16:30:56 -0400
Re:  Using mode removes linebreaks/indents
At 2013-04-18 11:07 +0000, trond.huso@xxxxxx wrote:
For some reason when using mode the indentation and line breaks are all removed:

The specification states that white-space-only text nodes in the stylesheet are not included when stylesheet nodes are copied to the result tree. This includes those nodes used for indentation in the stylesheet.

This is the initiater:
<xsl:template match="/" mode="run2">

<nitf version="-//IPTC//DTD NITF 3.2//EN" change.date="October 10, 2003" change.time="19:30"
<!-- Call template header -->
<xsl:call-template name="header" />

                <xsl:call-template name="body3"/>

<?xml version="1.0" encoding="UTF-8"?><nitf xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ckbk="http://my.safaribooksonline.com/book/xml/0596009747/dates-and-times/" version="-//IPTC//DTD NITF 3.2//EN" change.date="October 10, 2003" change.time="19:30" baselang="no-NO"><head><title>Langoddstips uke 16</title><meta name="timestamp" content="2013.4.18 12:52:50"/>

That is showing the result with the text nodes of the stylesheet properly ignored.

I have this in the "global" area of xslt:
<xsl:output method="xml" indent="yes" encoding="ISO-8859-1" name="xml" />

That *should* have added some white-space to your result, but the processor is allowed to ignore indent="yes" and still be considered conformant. If your processor is not supporting indenting the result serialization, you would have to go through elaborate means to preserve the white-space nodes in your stylesheet.

Any suggestions?

Which processor are you using? Does that processor support indent="yes"?

Sometimes keeping stylesheet template indentation is as simple as adding xml:space="preserve" in the template rule, but often it isn't that simple.

Is there a reason why you want it preserved? It usually isn't important to the downstream processor. I advise my students that indent="yes" may be useful in development but it should be indent="no" in a production environment if you are unsure of what white-space is being added in all circumstances. For example, having indent="yes" has hurt me in production work with XSL-FO.

I hope this helps.

. . . . . . . . . Ken

Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.