Open jrutila opened 2 days ago
@jrutila Thanks for reporting. I implemented your unit test.
I tested your example in an online XSLT transformer and my results were a bit different:
<div>
<h2/>
<p/>
</div>
XML Input:
<root>
<test name="test1">This is <repl>text</repl> hello</test>
</root>
XSLT Input:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="repl">
<span>replaced <xsl:value-of select="." /></span>
</xsl:template>
<xsl:template match="/">
<div>
<h2><xsl:value-of select="test/@name" /></h2>
<p><xsl:apply-templates select="test/node()" /></p>
</div>
</xsl:template>
</xsl:stylesheet>
Hmm.. true. I think I tested this before but you are right. Following xslt works, though.
I had to add match="/root"
for some reason.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="repl">
<span>replaced <xsl:value-of select="." /></span>
</xsl:template>
<xsl:template match="/root">
<div>
<h2><xsl:value-of select="test/@name" /></h2>
<p><xsl:apply-templates select="test/node()" /></p>
</div>
</xsl:template>
</xsl:stylesheet>
The buggy case is presented in this unit test code.
Basically, the
<xsl:apply-templates>
works but results in following outputSo the beginning of the text ("This is") is lost somewhere, the "hello" comes first and then the, correctly templated, "replaced text". If you remove the " hello" from the end, it works correctly.