greddin
asked on
XSL: Replace underscore with a space?
In an xsl stylesheet how would I go about replacing the underscores "_" with a space in the Title nodes of my xml file below?
<?xml version="1.0" encoding="utf-8" ?>
<Folder xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FolderID>466</FolderID>
<ParentID>416</ParentID>
<Title>Breast_Cancer</Titl e>
<Description />
<Folders>
<Folder>
<FolderID>470</FolderID>
<ParentID>466</ParentID>
<Title>Carcinoma_In_Situ</ Title>
<Description />
<Folders />
</Folder>
<Folder>
<FolderID>470</FolderID>
<ParentID>466</ParentID>
<Title>Complementary_Medic ine</Title >
<Description />
<Folders />
</Folder>
</Folders>
</Folder>
Thank you.
<?xml version="1.0" encoding="utf-8" ?>
<Folder xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FolderID>466</FolderID>
<ParentID>416</ParentID>
<Title>Breast_Cancer</Titl
<Description />
<Folders>
<Folder>
<FolderID>470</FolderID>
<ParentID>466</ParentID>
<Title>Carcinoma_In_Situ</
<Description />
<Folders />
</Folder>
<Folder>
<FolderID>470</FolderID>
<ParentID>466</ParentID>
<Title>Complementary_Medic
<Description />
<Folders />
</Folder>
</Folders>
</Folder>
Thank you.
ASKER
Thanks, I have this but it's not working:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ccs="CancerConsultan ts.Syndica tion" exclude-result-prefixes="c cs">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="FolderCountHalf" select="(count(/ccs:Folder /ccs:Folde rs/ccs:Fol der) + 1) div 2"/>
<xsl:template match="/ccs:Folder">
<html>
<body>
<table border="1">
<xsl:for-each select="ccs:Folders/ccs:Fo lder[posit ion() <= $FolderCountHalf]">
<tr>
<td><xsl:apply-templates select="."/><br/>
<xsl:value-of select="translate(Title,'_ ',' ')"/>
</td>
<td>
<xsl:choose>
<xsl:when test="following-sibling::c cs:Folder[ position() = $FolderCountHalf]">
<xsl:apply-templates select="following-sibling: :ccs:Folde r[position () = $FolderCountHalf]"/>
</xsl:when>
<xsl:otherwise> </xsl :otherwise >
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="ccs:Folder">
<a href="{ccs:FolderID}"><xsl :value-of select="ccs:Title"/></a>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ccs="CancerConsultan
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="FolderCountHalf" select="(count(/ccs:Folder
<xsl:template match="/ccs:Folder">
<html>
<body>
<table border="1">
<xsl:for-each select="ccs:Folders/ccs:Fo
<tr>
<td><xsl:apply-templates select="."/><br/>
<xsl:value-of select="translate(Title,'_
</td>
<td>
<xsl:choose>
<xsl:when test="following-sibling::c
<xsl:apply-templates select="following-sibling:
</xsl:when>
<xsl:otherwise> </xsl
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="ccs:Folder">
<a href="{ccs:FolderID}"><xsl
</xsl:template>
</xsl:stylesheet>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much again.
eg. <xsl:value-of select="translate(Title,'_