Subject: Re: [xsl] Needed String Split with children From: Mitch Amiano <mitch.amiano@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 27 Oct 2002 17:23:00 -0500 |
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/Books"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template>
<xsl:template match="FLD"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:for-each select="node()|text()"> <xsl:choose> <xsl:when test="node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:when> <xsl:when test="position() != last()"> <xsl:value-of select="."/> </xsl:when> <xsl:when test="string-length(normalize-space()) > 5"> <xsl:variable name="laststring" select="normalize-space()"/> <xsl:variable name="yearstring" select="substring( $laststring, string-length($laststring)-4, 4)"/> <xsl:choose> <xsl:when test="translate( $yearstring, '0123456789', '0123456789') = $yearstring"> <xsl:message>Translate worked: '<xsl:value-of select="$yearstring"/>'</xsl:message> <xsl:value-of select="substring( $laststring, 1, string-length($laststring)-5)"/> <UNITDATE> <xsl:value-of select="$yearstring"/> </UNITDATE> <xsl:text>.</xsl:text> </xsl:when> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:copy> </xsl:template>
Friends, I have been holding off on this question, but I find myself confronting it more and more. I have not really figured out how to get around it. So I have instead tagged the string I wanted to split when the string is in a node with children.
What I would like is to split a string, but then be able to either replace the children as nodes, or to replace the coded string that I split off.
I have created a template to capture the last part of each string and render it. However, I cannot figure out how to rebuild the rest of the string with its original children, nor how to replace the string I have now captured and coded.
XML:
Calvin, John. /The Bondage and Liberation of the Will/. Baker Books, Inc., 1996. Deissmann, Adolf. /Light from the Ancient East/. George A. Doran, Co., 1927. Lightfoot, J. B. /Notes on the 1^st four Epistles of Saint Paul./ Hendrikson Publishers, Inc., 1995.
My output:
Calvin, John. The Bondage and Liberation of the Will. Baker Books, Inc., 1996. Deissmann, Adolf. Light from the Ancient East. George A. Doran, Co., 1927. Lightfoot, J. B. Notes on the 1st four Epistles of Saint Paul. Hendrikson Publishers, Inc., 1995.
This example is rather simplified, but the need is still the same.
Thanks, Mike Ferrando Washington, DC
__________________________________________________ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Needed String Split with chil, Mike Ferrando | Thread | Re: [xsl] Needed String Split with , Mike Ferrando |
[xsl] Needed String Split with chil, Mike Ferrando | Date | [xsl] Role of XSLT?, Roger L. Costello |
Month |