|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: New Line using XSLT
Using separator=" & # x a ; " (without the spaces) should work in theory, but
it's a bit vulnerable to corruption if there's a complex pipeline processing
the XSLT code: the entity reference can get turned into a real newline, which
then gets turned into a single space by the process of attribute value
normalization next time the XML is parsed.
So codepoints-to-string(10) is probably more robust. Or if you prefer, use a
variable
<xsl:variable name="NL" select="codepoints-to-string(10)"/>
<xsl:value-of select="..." separator="{$NL}"/>
Michael Kay
Saxonica
> On 2 Mar 2016, at 10:27, Heiko Niemann kontakt@xxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi,
>
> when outputting text with new line(s) I favor using a value-of element
> plus seperator with any number of nested sequence elements. For 'new line'
> as seperator I prefer using codepoints-to-string(10), which worked for me
> as the most reliable way. I bet there are pros and cons, but at the moment
> this works best for me and seems to be the most flexible.
>
> Sample:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="2.0">
> <xsl:output method="text"/>
> <xsl:template match="/">
> <xsl:value-of separator="{codepoints-to-string(10)}">
> <xsl:for-each select="1 to 10">
> <xsl:sequence select="."/>
> </xsl:for-each>
> </xsl:value-of>
> </xsl:template>
> </xsl:stylesheet>
>
> One con would be that this reqires XSLT 2.0/XPath 2.0.
>
>
> Heiko
>
>
>
>
>> Hi,
>>
>> I want to generate a "text" file in which every row should be in separate
>> line.
>> I have use "
,
" and <xsl:text>
>> </xsl:text>
>>
>> But all the above seems not to work.
>>
>> Please suggest.
>>
>> --
>> Vishnu Singh | http://marklogicgd.blogspot.in/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








