xsl-list
[Top] [All Lists]

Re: [xsl] Algorithm for splitting a string at a space

2015-11-23 13:17:51
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template name="m">
  <xsl:analyze-string select="'This is a long line that I want to
split at a space. '"
              regex=".{{0,30}}( )">
   <xsl:matching-substring>
    <x><xsl:value-of select="replace(.,' $','')"/></x>
   </xsl:matching-substring>
   <xsl:non-matching-substring>
    <y><xsl:value-of select="."/></y>
   </xsl:non-matching-substring>
  </xsl:analyze-string>
 </xsl:template>
</xsl:stylesheet>


produces

<x>This is a long line that I</x>
<x>want to split at a space.</x>

David
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>