Re: [xsl] codepoints-to-string for new line

Subject: Re: [xsl] codepoints-to-string for new line
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 07 Sep 2013 20:01:25 -0400
At 2013-09-08 01:04 +0200, Heiko Niemann wrote:
whenever I searched for a way to insert a line break using the output text
method I basically just found samples either with & #10; or a line break
inside a xsl:text element. Those work as long as you don't do pretty print
or your editor at some point transforms & #10; to space. Anyhow while
flipping thru a well known XSLT/XPath reference codepoints-to-string()
crossed my way - and solved the problem.

Solved what problem? Expressing a line feed in a way that your editor doesn't corrupt it? Isn't that a problem with your editor or editing environment and not your stylesheet?

So that makes me wonder:

a) Is there a good reason/scenario why/when not to use this function for a
line break?

Because that isn't what it is meant to be used for? Or, at least, it isn't something I would expect it to be used for.

I'm just guessing that you are using...

<xsl:value-of select="codepoints-to-string(10)"/>

... in place of the two cases you cite of either:


... or


Have I understood you correctly?

b) Are there just no (top-rated) samples around because
codepoints-to-string() belongs to an extended set of functions that people
(like me) rarely/never use?

I don't use it often, but I use it when it makes sense to use it. And I don't think it makes sense to use it merely to express a linefeed in your stylesheet. I'm sure a maintainer of your stylesheet would be confounded at such an expression.

Of course literal number values can be used as arguments to codepoints-to-string, but I've typically used calculated values or a range of values or a converted value from a data point of some kind. I've never thought to use literal number values since an XML numeric character reference achieves the same objective without taking the time to invoke an XPath function (noting, of course, that a processor may choose to rewrite the function call into a static expression).

I acknowledge that it is doing what you want it to do, but it just seems out of place to me and I would criticize its use in a stylesheet in this manner.

Perhaps others will not have any problems with it.

I hope this is considered helpful and constructive feedback.

. . . . . . . . . Ken

Public XSLT, XSL-FO, and UBL classes in the Netherlands     Oct 2013 |
Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: |
Crane Softwrights Ltd.   |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: |
Legal business disclaimers: |

Current Thread