This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Splitting a String Request
- From: "Joerg Heinicke" <joerg dot heinicke at gmx dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 23 Jan 2002 00:41:27 +0100
- Subject: Re: [xsl] Splitting a String Request
- References: <20020122230952.29315.qmail@web10107.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Mike,
you can count the commas in a string and decide on this count:
<xsl:template match="PERSNAME">
<PERSNAME NORMAL="{.}">
<xsl:copy-of select="@*"/>
<xsl:variable name="count-of-commas" select="string-length(.) -
string-length(translate(. , ',' , ''))"/>
<xsl:choose>
<xsl:when test="$count-of-commas = 1">
<xsl:value-of select="substring-after(., ',')"/>
<xsl:value-of select="substring-before(., ',')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-before(substring-after(.,
','), ',')"/>
<xsl:value-of select="substring-before(., ',')"/>
<xsl:value-of select="substring-after(substring-after(.,
','), ',')"/>
</xsl:otherwise>
</xsl:choose>
</PERSNAME>
</xsl:template>
Hope this helps,
Joerg
----- Original Message -----
From: "Mike Ferrando" <mikeferrando@yahoo.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Wednesday, January 23, 2002 12:09 AM
Subject: [xsl] Splitting a String Request
> Dear Friends,
> Could someone give me the syntax for splitting a string?
>
> What I have presently is:
>
> <PERSNAME ENCODINGANALOG="100$a" ROLE="cmp">Abbott, Frank</PERSNAME>
>
> What I would like is:
> <PERSNAME ENCODINGANALOG="100$a" ROLE="cmp" NORMAL="Abbott,
> Frank">Frank Abbott</PERSNAME>
>
> It is possible that there might be an inverted title in these names:
> (Mrs.; Miss; Sir; Mme.; Lady)
>
> <PERSNAME ENCODINGANALOG="700$a" ROLE="lyr">Shacklock, C. L.,
> Mrs.</PERSNAME>
>
> What I would like would be:
> <PERSNAME ENCODINGANALOG="700$a" ROLE="lyr" NORMAL="Shacklock, C. L.,
> Mrs.">C. L. Shacklock, Mrs.</PERSNAME>
>
> The best thing to do might be to first search out all the names with
> titles and make a list. Run the xsl style sheet and then go back and
> edit or correct this small group of names. That might make the whole
> style sheet less complicated.
>
> I was thinking that it would be nice if I could retain the UTF-8
> coding (André instead of the usual output of é). Would it
> be a problem to use copy-of instead of value-of, since I am going to
> split a string?
>
> Thanks,
> Mike Ferrando
> Washington, DC
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list