[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: codepoints-to-string for new line

Subject: Re: codepoints-to-string for new line
From: Stefan Krause <stf@xxxxxxxx>
Date: Sun, 8 Sep 2013 10:54:35 +0200
Re:  codepoints-to-string for new line
A lot of my stylesheets start with entity declarations for cr (&#x0A; and in
some cases &#x0D;&#x0A;) and crt (<xsl:text>&cr;</xsl:text>), so I can write

<xsl:text>abc</xsl:text>&crt;

See for an example [1].

This also works with XSLT 1.0.

Note that &cr; will not work within attributes because of attribute-value
normalization, a step every XML parser has to  pass during parsing of the
stylesheet [2]. A workaround is a $newline variable as described by Liam.

Stefan


[1]
https://code.google.com/p/xslt-sb/source/browse/tags/xslt-sb/0.2/0.2.50/xslt-
sb/tools/google_code.xsl

[2] http://www.w3.org/TR/REC-xml/#AVNormalize


Am 08.09.2013 um 02:12 schrieb Liam R E Quin <liam@xxxxxx>:

> On Sun, 2013-09-08 at 01:04 +0200, Heiko Niemann wrote:
>
>> 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?
>
> It's part of XSLT 2 [1], which doesn't have as widespread use as XSLT 1.
>
> Using <xsl:value-of select="codepoints-to-string('10')" /> will indeed
> give you a newline in cases where using an XML editor on your stylesheet
> would turn &#10; into a literal newline which might then be reformatted
> as a space by buggy ill-behaved software you shouldn't use :-) :-)
>
> The right way for an editor to show indenting of XML documents is
> visually, not by changing the text of the document.
>
> Probably I'd have a global variable,
> <xsl:variable name="newline" select="codepoints-to-string('10')" />
> and document in a comment why you are using it.
>
> Then you can use concat("abc", $newline, "cde") to get something much
> more readable.
>
> Liam
>
> [1] http://www.w3.org/TR/xpath-functions/#func-codepoints-to-string
>
> --
> Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
> Pictures from old books: http://fromoldbooks.org/
> Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.