xsl-list
[Top] [All Lists]

Re: [xsl] Where did my tabs go? Trying to understand xsl:value-of, tabs and the separator attribute

2006-10-16 11:54:20
David Carlisle wrote:

(no tabs) <xsl:value-of select="somenode" separator="{&tab;}" />

That one's an error: the &tab; is expanded before xslt starts so it is an
AVT where the expression in {} is just a tab character which isn't a
legal xpath expression.

Ouch, that hurts! Cut 'n' paste typo and I thought to have checked them all. Well, I meant "{'&tab;'}" ;-)

<!DOCTYPE x [
<!ENTITY tab "&#x09;" >
<!ENTITY tab2 "&#38;#x09;" >
]>

This is where I fell asleep during the lesson last year ;-)
I'm sure I saw this before. Thanks! Now it works as I expect it to. I can even use the character map, so as to prevent the tabs to be re-interpreted when I micro-pipeline some data, or use a normalize-space somewhere too often.


isn't white space fun??

Haha. Nightmarish fun, yes. Some day in ancient history, I thought I had it all figured out. But recently we started redesigning some of the xslt libraries and we messed up big time in these corner areas of whitespace handling.

I am sure this issue also has to do with the way I am mistreating newline characters.

One more question that I still don't get. If XML parses these entities before it gets to XSLT, and if XML has predefined entities &amp; &lt; &gt &apos; and &quot; why can't I use the following to the same success?

<!DOCTYPE x [
   <!ENTITY tab "&#x09;" >
   <!ENTITY tab2 "&amp;#x09;" >
]>

It will produce '&#x09;' where you previously got '   ' (tab).

Hmm, thinking out loud here: if I get rid of that character map, and I stick to the lovely &tab; (defined as your &tab2;), do I risk loosing the tab characters in the output stream when I tossle and hossle them hence and forth through my templates during a single pass? Meaning, can normalize-space, strip-space, xsl:value-of, xsl:variable + pipelining, xsl:function etc be a spoil-sport for me? (if so, character maps are safer, if not, I can as well get rid of them)

Cheers and thanks!
-- Abel Braaksma
   http://www.nuntia.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>
--~--