Altova Mailing List Archives

RE: [xsl] breaking string into substrings or arrays (XSLT 1.0 solution) tokenize

From: "Pawson, David" <David.Pawson@----------->
Date: 4/20/2005 7:29:00 AM
Following up on a converstation I had with Jarno and Dimitre.
This is a New York version of tokenize. (So good we did it twice)

General purpose tokenize, for known delimiters.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

  <xsl:import href="/sgml/fxsl/strSplit-to-Words.xsl"/>
<xsl:output method="xml"
encoding="UTF-8" indent="yes"/>

<xsl:template match="/vs">
 <xsl:value-of select="system-property('xsl:product-version')" />

  <xsl:apply-templates />

<xsl:variable name="xxx" select="//fld[1]"/>

  <xsl:template match="line">
    <xsl:call-template name="tokens">
        <xsl:with-param name="str" select="@event"/>
        <xsl:with-param name="splitString" select="' '"/>
And using fxsl
       <xsl:call-template name="str-split-to-words">
        <xsl:with-param name="pStr" select="@event"/>
        <xsl:with-param name="pDelimiters" select="' '"/>

<xsl:template name="tokens">
  <xsl:param name="str" select="."/>
  <xsl:param name="splitString" select="' '"/>
    <xsl:when test="contains($str,$splitString)">
      <xsl:value-of select="substring-before($str,$splitString)"/>
    <xsl:call-template name="tokens">
      <xsl:with-param name="str"
      <xsl:with-param name="splitString" select="$splitString"/>
    <token><xsl:value-of select="$str"/></token>

<xsl:template match="vs">



<?xml version="1.0" ?>
    <line event="x y x">



c:\sgml>type op.xml
<?xml version="1.0" encoding="UTF-8"?>

And using fxsl



NOTICE: The information contained in this email and any attachments is
confidential and may be privileged.  If you are not the intended
recipient you should not use, disclose, distribute or copy any of the
content of it or of any attachment; you are requested to notify the
sender immediately of your receipt of the email and then to delete it
and any attachments from your system.

RNIB endeavours to ensure that emails and any attachments generated by
its staff are free from viruses or other contaminants.  However, it
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email and
any attachments are those of the author and do not necessarily represent
those of RNIB.

RNIB Registered Charity Number: 226227



These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.