Basic problem is that I had to resort to the always infamous
disable-output-escaping to substitute a <br /> for a marker character(s)
in a text() node string. Did I happen upon an actual valid use of
d-o-e, or am I missing better way to do this?
During the transformation all text() nodes are checked for one or more
linebreak markers using the following template:
======================================================
<xsl:template match="text()">
<!-- use a variable to allow additional substring substitions
not shown to simplify -->
<xsl:variable name="t1">
<xsl:call-template name="insert_breaks">
<xsl:with-param name="source_string" select="."/>
<xsl:with-param name="marker" select="'!br;'"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of disable-output-escaping="yes" select="$t1"/>
</xsl:template>
======================================================
The insert_breaks template simply substitutes a "<br />" for the defined
linebreak marker passed as a parameter:
======================================================
<xsl:template name="insert_breaks">
<xsl:param name="source_string" select="."/>
<xsl:param name="marker"/>
<!-- If $marker is in the $source_string -->
<xsl:if test="contains($source_string,$marker)">
<!-- then replace it with "<br />" and look for another -->
<xsl:call-template name="insert_breaks">
<xsl:with-param name="source_string">
<!-- make the substitution by taking everything before the
marker, insert the br element, and finish with everything
after the break marker -->
<xsl:value-of select="substring-before( $source_string,
$marker )"/>
<xsl:text><br /></xsl:text>
<xsl:value-of select="substring-after( $source_string,
$marker )"/>
</xsl:with-param>
<xsl:with-param name="marker" select="$marker"/>
</xsl:call-template>
</xsl:if>
<!-- terminating case where the $marker is not found in the
source string -->
<xsl:if test="not(contains($source_string,$marker))">
<xsl:value-of select="$source_string"/>
</xsl:if>
</xsl:template>
======================================================
Without the d-o-e in the text() template, I get the the actual "<br
/>" in the resulting XHTML and rather than a line break in the
browser output, I see the actual "<br />" characters on the screen --
not what I want. Bottom line question: Is outputing the results of a
string manipulation that inserts an element a (the?) valid use case for
d-o-e?
Other minor details that someone else may decide are major:
MSXSL V4
output method="xml"
testing in XML Spy V4.3
Thanks.
--
Steve Rosenberry
Sr. Partner
Electronic Solutions Company -- For the Home of Integration
http://ElectronicSolutionsCo.com
(610) 670-1710
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list