How to disable special character escaping of a java Node

java, xml, xslt

Solution

The problem is that you're using `setTextContent` but then providing the escaped version - you should let the API do the escaping. You're currently trying to set the text content of the node to literally `"•"` - not a bullet. You probably just want:

result.setTextContent("\u2022");

to specify that the content should just be U+2022 (bullet) which is code point 8226 in decimal.

Problem

I have a function in which I create a Node and set it textContent to a special character for example a bullet (•). This function is called in an xsl:apply-templates. However, the output escape the special caracter and instead of seeing a bullet, • appears on my result. After doing some research I haven't found any way to disable escaping from my node. My thesis is that the Node created is a CDATA section, but how can I revert that ? Here is the code that I used to create the node : ``` DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); result = doc.createElement("doesntmatter"); result.setTextContent("•"); ``` Thanks for your help :) Edit : Something like disable-output-escaping in xslt but for java Element/node should do the trick

Original source