|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Recognizing new line character in XSL
> Oh, I see you're using XSLT 1.0. That's tedious - in that case you need a recursive named template that uses substring-
> before to process the text before the first newline, and then calls itself passing substring-after(., '& #xa;') to process the text
> after the first newline.
Or just use the "str-split-to-words" template of FXSL like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common"
exclude-result-prefixes="ext">
<xsl:import href="strSplit-to-Words.xsl"/>
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="vwordNodes">
<xsl:call-template name="str-split-to-words">
<xsl:with-param name="pStr" select="/"/>
<xsl:with-param name="pDelimiters"
select="' '"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>
<xsl:template match="word">
<line><xsl:value-of select="."/></line>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following XML document:
<text>XSLT is the greatest thing
since bread and butter
but taking too much of it at once
is dangerous.
</text>
the result is:
<line>XSLT is the greatest thing</line>
<line>since bread and butter</line>
<line>but taking too much of it at once</line>
<line>is dangerous.</line>
<line/>
--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
|
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








