xsl-list
[Top] [All Lists]

RE: [xsl] why no indent here

2011-12-12 02:00:11

Thanks, 

 

But it don't work well. If I do the <xsl:text> then the sentence after that 
will be without the line-break.

I think I have to live with it.

 

Another question : 

 

When I have a xml piece of this :

 



<body>Naam : Tamara Wobben 
         Geboorte gewicht : 2000 gram 
         Geboorte lengte : 44 cm. 
         Geboortedatum : 1 september 2005

</body>

 

 

And I do <xsl:value-of select="body" or I do <xsl:copy-of select="body"> Then 
all the text will be displayed as this :

 

Tamara Wobben  Geboorte gewicht : 2000 gram Geboorte lengte : 44 cm  
Geboortedatum : 1 september 2005

 

And not as the text in the xml file. 

 

Can I display that text with a line break ?

 

Roelof

 

 

 

 

 

----------------------------------------
Date: Sun, 11 Dec 2011 21:36:51 +0000
From: tgraham(_at_)mentea(_dot_)net
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] 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
elements.

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:text>&#10;</xsl:text>
<xsl:apply-templates select="data/params" />
</xsl:template>

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
YMMV.

Regards,


Tony Graham tgraham(_at_)mentea(_dot_)net
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

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
                                        
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>