Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XSL: tokenize

Posted on 2006-06-29
2
Medium Priority
?
736 Views
Last Modified: 2013-11-18
Hi Gertone,
is there a way to tokenize a given String, seperated by e.g. ';'???
If I have a XSL variable $output with content 'c:\test;d:\test2...', I want to loop each of these entries.
Ciao
0
Comment
Question by:go4java
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 17009581
Hi go4java,

You need to deal with this recursively
- pass the string to a template
- deal with the substring-before the ;
- pass the part behind the ; to the same template, until you are done

I ll draft you an example in a second

Cheers!
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 1500 total points
ID: 17009643
go4java,

put your string in a <test> element and use this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="test">
        <xsl:call-template name="handlePart">
            <xsl:with-param name="part" select="."/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="handlePart">
        <xsl:param name="part"/>
        <xsl:choose>
            <xsl:when test="contains($part, ';')">
                <xsl:value-of select="substring-before($part, ';')"/><!-- do something with the part here -->
                <xsl:call-template name="handlePart">
                    <xsl:with-param name="part" select="substring-after($part, ';')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$part"/><!-- do something with the part here -->
             </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question