Re: [xsl] text output with some significant white space

Subject: Re: [xsl] text output with some significant white space
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 19 Apr 2001 19:32:04 +0100
> when do you use method="text"?

when you are writing text not XML.

in text output < comes out as < in XML it comes out as &gt;.

> Doe's this mean <tag>content</tag> causes
> "content" to go to the output?

yes, but it's better not to make element nodes at all if you've
specified text output.

> In my opinion, the method is so
> propped up with defaults up xml/html output it is very difficult to figure 
> out formatting for other purposes

which method is propped up with what?

> Also, it might help getting a better narrative on what <xsl:text/>
> does.

<xsl:text>foo</xsl:text>

puts "foo" into the output, the important point that it does this even
if "foo" is just white space.

<xsl:text/> is a trick which is best not to use if you find it
confusing.


in 

<xsl:tempate match=...>
<xsl:value-of .../>
xyz
<xsl:apply-templates/>
</xsl:template>

then the child nodes of xsl:template are

text (newline)
element (xsl:value-of)
text (newline xyz newline)
element (xsl:apply-templates)
text (newline)

Now white spave nodes are stripped so th eeffective nodes are

element (xsl:value-of)
text (newline xyz newline)
element (xsl:apply-templates)

note that the newline either side of xyz goes to the output.

If instead you do


<xsl:tempate match=...>
<xsl:value-of .../>
<xsl:text>xyz</xsl:text>
<xsl:apply-templates/>
</xsl:template>


or

<xsl:tempate match=...>
<xsl:value-of .../>
<xsl:text/>xyz<xsl:text/>
<xsl:apply-templates/>
</xsl:template>

Then the newlines appear in white space nodes so are stripped.
In the latter case the xsl:text elements are empty so they don't really
output their content but they do cause the newlines to be in their own
text nodes, and so stripped.

David


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread