This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: struck with space handling
- From: Antonio Fiol <fiol at w3ping dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 11 Jul 2002 13:00:05 +0200
- Subject: Re: [xsl] struck with space handling
- References: <9723092BA4DBD111816D0000F6B093610C27E9E5@imsuklndsx1.lnd.uk.imshealth.com> <00ba01c21dc1$c4e01a70$1802893e@ROSEBUD> <1026384816.3d2d63b0c4d75@www.boltblue.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
As someone (David C?) said,
ONLY white space nodes are removed from the stylesheet. If a node
contains something apart from whitespace, it is not removed (and the
whitespace it contains is not removed either).
So if you have
[...]<xsl:for-each select="centers/center">
"<xsl:value-of [...]
That really means "output a text node containing a newline character
followed by some spaces and then a " sign.
Antonio
subbu@boltblue.com wrote:
Hi,
I have yet another problem sorting out the whitespace issue(i do not know if i
can really call it as a whitespace issue )
The problem is as follows...
i want the ids to appear one below the other between the quots like.
"3100004"
"3100007"
"80000"
"3100012"
"3000900"
"80001"
So
I write the XSL code as below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet SYSTEM "D:\xsl-exp\characterEntities\entityref.dtd">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes"/>
<xsl:template match="/">
<!--line 1 --> <xsl:for-each select="centers/center"> "<xsl:value-of select="
@id"/>"
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
In the above code , where line 1 is,
1.If i write the
"<xsl:value-of select=" @id"/>"
below the for loop ( in the next line of the for-each)
i get the results as ( note the spaces before the id and the extra newline
after each ID
<----Spaces----
"3100004"
"3100007"
"80000"
"3100012"
"3000900"
"80001"
2. If i write "<xsl:value-of select=" @id"/>" in the same line as the for-each
and <xsl:text>
</xsl:text> in the next line,
then i get result as( note that the spaces before id is sorted but there is an
extra newline )
"3100004"
"3100007"
"80000"
"3100012"
"3000900"
"80001"
3. If however i write the "<xsl:value-of select=" @id"/>" and
<xsl:text>
</xsl:text> in the same line as xsl:for-each , i get the result
what i wanted.. eg., if xsl code is
<xsl:for-each select="schedule/timeslot">"<xsl:value-of
select="@id"/>"<xsl:text>
</xsl:text> ( in the same line)
Then the result is as desired.. like below( note that there are no spaces and
no extra newlines)
"3100004"
"3100007"
"80000"
"3100012"
"3000900"
"80001"
I am not really sure how the XSLT processor outputs the space.I am really
concerned because output is depending upon the XSL structure..if i use the tidy
option in xselerator, then it arrainges the loops etc in a proper indented way,
which will then not get what i want. I am concerned as to how the structure of
the XSL coding can impact the output?? is there any way to get around this?
Thanks Very Much
Subbu
--------------------------------------------------------------
Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
http://www.boltblue.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list