Text node content escaped by Xalan extension

tessunitu

New Member
I have a Xalan Java extension which returns a DocumentFragment.In my XSLT, I invoke it with something like:\[code\]<xsl:copy-of select="java:org.foo.myMethod($a, $b)" /> \[/code\]The problem is that where the document fragment contains a text node containing an entity, for example " ", this is being inserted as &#160;Note that I do need to return a DocumentFragment, not a string, because that text node is just part of a tree of XML being returned.I'm working around this issue as follows:In the Java code:\[code\]Element amp = document.createElement("amp");xhtmlBlock.appendChild(amp);Text t = document.createTextNode("#160;");amp.appendChild(t);\[/code\]In the XSLT:\[code\]<xsl:apply-templates select="java:org.foo.myMethod($a, $b)" mode="amp-workaround" /> <xsl:template match="@*|node()" mode="amp-workaround"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="amp-workaround" /> </xsl:copy></xsl:template><xsl:template match="amp" mode="amp-workaround"> <xsl:text disable-output-escaping="yes">&</xsl:text><xsl:value-of select="."/></xsl:template>\[/code\]Beware: this workaround only works in certain cases, which I'm still trying to pin down.Is this a known issue in Xalan 2.7.1?Is there a better approach (still using Java extensions which return DocumentFragment)?
 
Back
Top