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

Re: why no indent here

Subject: Re: why no indent here
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Sun, 11 Dec 2011 21:36:51 -0000 (GMT)
Re:  why no indent here
On Sun, December 11, 2011 8:18 pm, Roelof Wobben wrote:
> But I get as output this :
> <!DOCTYPE head PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><head>
>  <title>http://test.tamarawobben.nl</title>
> </head>
> instead of this :
> <!DOCTYPE head PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <head>
>  <title>http://test.tamarawobben.nl</title>
> </head>

Whitespace-only text nodes in the stylesheet are stripped by default. 
>From http://www.w3.org/TR/xslt#strip:

   For stylesheets, the set of whitespace-preserving element
   names consists of just xsl:text.

So if you were expecting whitespace-only text nodes from your stylesheet
to be reflected in your result, you need to wrap them in xsl:text

All that XSLT 1.0 says about '<xsl:output indent="yes" />' is:

   indent specifies whether the XSLT processor may add
   additional whitespace when outputting the result tree;
   the value must be yes or no [1]

so you're not even guaranteed to get an indented result even when you use
'indent="yes"' (but it practice it is universally supported AFAICT).

The specification for outputting the DOCTYPE declaration in XML output is:

   If the doctype-system attribute is specified, the xml
   output method should output a document type declaration
   immediately before the first element.

which is what you got, since the start-tag of the first element
immediately follows the DOCTYPE declaration.  You could try:

<xsl:template match="/">
    <xsl:apply-templates select="data/params" />

but it would be possible for the XSLT 1.0 processor to follow the letter
of the spec and omit the line break added from content of the xsl:text, so


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming

[1] http://www.w3.org/TR/xslt#output

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.