Hi all, (thanks in advance!)
I am trying to generate an xhtml page that includes text with line numbers. The line numbers align with the left-hand margin, and are separated from the text by whitespacing. To generate this formatting I have written some XSL code like this:
This code works. (Note that in this code code I represent the spaces using the whitespace entity ' AmpersandPounsign160; '. These whitespace characters vanish on the Javaranch page.) It produces the desired whitespace padding between the line number and the text.
But then, if I revisit the page or even another page generated with this same stylesheet, the whitespacing collapses. This is true, unpredictably, if I clear the browser cache.
I also feed this xhtml into a
java applet, where I display it in a textPane using HTMLDocument. The result is the same is that on the plain xhtml page: sometimes the whitespacing collapses. In fact, if the collapse of whitespacing occurs in the xhtml page, it always occurs in the applet, and vice versa.
including an xsl:preserve-space directive has not worked.
This led me to wonder, might the whitespacing collapse with XSLT stylesheet compilation? That's the only think I can think of.
So, some questions:
(1) how can I fix this problem?
(2) if it is indeed an XSL compilation problem, how can I insure my whitespacing does not collapse during (re-?) compilation.
(3) should I represent my 8 whitespaces using some kind of loop? ('print a single whitespace 8 times?)
(4) perhaps insure that the compiled stylesheet is not cached?