OmyGOD wrote:
Hi,
I am trying to transform XML code like
<text>
This is the first line<br />
This is the second line
</text>
and XSL
<xsl:value-of select="text" />
with XSLTProcessor.(which is provided by an extension of PHP5)
how can I keep the <br /> tag during transformation.
The value-of, on a node, will contantenate together all the text nodes
in the subtree rooted in the node, and return that...
Seems you just want to make an identical copy of everything? Or only of
the contents of a text element?
<?xml version='1.0' encoding='utf-8' ?>^M^M
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Don't copy text elements, but do copy their contents -->
<xsl:template match="text">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="text() | *"/>
</xsl:copy>
</xsl:template>
<xsl:template select="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
Soren