xsl-list
[Top] [All Lists]

Re: Substrings

2005-05-30 13:49:28
On 5/31/05, Karl Stubsjoen <kstubs(_at_)gmail(_dot_)com> wrote:
To "tokenize" is that to say I am going to split the string up by
spaces, or other delimiters?  So then, I could recursively call a
template which returns a value of nothing but passes back the
substring value of supplied string after each space until which time I
find an @ at this point I stop recursing and pass back the value.  (i
think that makes sense, and I think I can write that!)

I am using XSLT 1 with microsoft's msxml parser so exslt is not available to 
me.

Using FXSL (for MSXML), one would write something like this:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:vendor="urn:schemas-microsoft-com:xslt"
 exclude-result-prefixes="vendor"

 
 <xsl:import href="strSplit-to-Words.xsl"/>
 
 <!-- To be applied on: testSplitToWords10.xml -->
 <xsl:output omit-xml-declaration="yes" />
  
  <xsl:template match="/">
    <xsl:variable name="vrtfWords">
      <xsl:call-template name="str-split-to-words">
        <xsl:with-param name="pStr" select="/*"/>
        <xsl:with-param name="pDelimiters" select="' ,.;&#9;&#10;'"/>
      </xsl:call-template>
    </xsl:variable>
    
    <xsl:copy-of select=
    "vendor:node-set($vrtfWords)/word
              [contains(., '@')]"/>
  </xsl:template>

</xsl:stylesheet>

When this transformation is applied on this source.xml:

<t>
   Mr. Joseph Smith Jr. III jsmithjr(_at_)juno(_dot_)com "J Jr."
</t>


the wanted result is produced:

    <word>jsmithjr(_at_)juno</word>


Hope this helped.


Cheers,
Dimitre Novatchev

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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