newbie xsl / xslt question

D

dbahooker

Team;

I'm kindof a newbie around these parts :)
I'm trying to replace TAB characters ( ) with </TD><TD>.. so that I
can properly align this XML into multiple cells in a table.

yes-- right now it is living as XML, tab delimited data.. and I want to
push it into 5 different cells.

here is the result: it's displaying this in IE instead of under view
source:
0.1</td><td>29-Sep-2004</td><td>Draft</td><td>Dba
Hooker</td><td>Initial Draft0

under view / source; it's displaying a similiar thing but it shows up
as HTML tags; instead of as HTML source.


thanks SO much for your help guys!!


here is my template call
--------------------------------------------------------------------
<xsl:template match="Property[@name='CHistory']">
<xsl:call-template name="replace-string">
<xsl:with-param name="text"><xsl:copy-of select="."
/></xsl:with-param>
<xsl:with-param name="from"> </xsl:with-param>
<xsl:with-param name="to">&lt;/td&gt;&lt;td&gt;</xsl:with-param>
</xsl:call-template>
</xsl:template>

here is a replace-string function I've found
----------------------------------------------------------------------
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="from"/>
<xsl:param name="to"/>

<xsl:choose>
<xsl:when test="contains($text, $from)">

<xsl:variable name="before" select="substring-before($text, $from)"/>
<xsl:variable name="after" select="substring-after($text, $from)"/>
<xsl:variable name="prefix" select="concat($before, $to)"/>

<xsl:value-of select="$before"/>
<xsl:value-of select="$to"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="$after"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$to"/>
</xsl:call-template>
</xsl:when>
<xsl:eek:therwise>
<xsl:value-of select="$text"/>
</xsl:eek:therwise>
</xsl:choose>
</xsl:template>
 
D

dbahooker

I will _DEFINITELY_ look at that

but this is what solved it.. i brought the tr tags into the outerloop
after a little bit of tinkering


<xsl:template match="Property[@name='CHistory']">
<tr><xsl:call-template name="split" /></tr>
</xsl:template>
<xsl:template name="split">
<xsl:param name="text" select="." />
<xsl:param name="delim" select="' '" />

<xsl:choose>
<xsl:when test="contains($text,$delim)">
<td>
<xsl:value-of select="substring-before($text,$delim)" />
</td>
<xsl:call-template name="split">
<xsl:with-param name="text" select="substring-after($text,$delim)"
/>
<xsl:with-param name="delim" select="$delim" />
</xsl:call-template>
</xsl:when>
<xsl:eek:therwise>
<td>
<xsl:value-of select="$text" />
</td>
</xsl:eek:therwise>
</xsl:choose>

</xsl:template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top