[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
On Tuesday, April 15, 2003, at 05:37 PM, Bill Chmura wrote:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="text">
<xsl:call-template name="makeElements">
<xsl:with-param name="string"><xsl:value-of select="text()"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="makeElements">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string,'<')">
<xsl:value-of select="substring-before($string,'<')"/>
<xsl:call-template name="makeElement">
<xsl:with-param name="string">
<xsl:value-of select="substring-after($string,'<')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="makeElement">
<xsl:param name="string"/>
<xsl:element name="{substring-before($string,'>')}">
<xsl:value-of select="substring-before(substring-after($string,'>'),'<')"/>
</xsl:element>
<xsl:call-template name="makeElements">
<xsl:with-param name="string">
<xsl:value-of select="substring-after(substring-after($string,'>'),'>')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] How can I do a string substitution for turning entities into html tags
Subject: Re: [xsl] How can I do a string substitution for turning entities into html tags From: Jim Hart <jhart@xxxxxxxxx> Date: Wed, 16 Apr 2003 08:28:32 -0400 |
On Tuesday, April 15, 2003, at 05:37 PM, Bill Chmura wrote:
This turns the tags into elements so you can do other things with them if you want to. Note that the elements must have open and close tags.
Here is an example of my xml data
<text> <p>Sometext here. Followed by more text</p> <p>More text.</p> <li>For more info see </li> </text>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="text">
<xsl:call-template name="makeElements">
<xsl:with-param name="string"><xsl:value-of select="text()"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="makeElements">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string,'<')">
<xsl:value-of select="substring-before($string,'<')"/>
<xsl:call-template name="makeElement">
<xsl:with-param name="string">
<xsl:value-of select="substring-after($string,'<')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="makeElement">
<xsl:param name="string"/>
<xsl:element name="{substring-before($string,'>')}">
<xsl:value-of select="substring-before(substring-after($string,'>'),'<')"/>
</xsl:element>
<xsl:call-template name="makeElements">
<xsl:with-param name="string">
<xsl:value-of select="substring-after(substring-after($string,'>'),'>')"/>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Jim Hart, Project Manager Academic Technology Services Library and Information Services Bates College Lewiston, Maine, USA
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How can I do a string sub, Michael Kay | Thread | RE: [xsl] How can I do a string sub, Bill Chmura |
Antw: Re: [xsl] saxon, Elke Naraschewski | Date | [xsl] tokenize(), Simon Kelly |
Month |
Keywords