It looks like JAXP allows assigning any value to a document node, including <, >, and & and others. Playing with XML reserved characters and XSLT raises a question. Consider the following code:
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
...
Element field = doc.createElement("col");
field.setTextContent( "<p>&]]" );
row.appendChild( field );
...
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource(new File("templateName.xsl"));
Transformer transformer = factory.newTransformer(xslt);
transformer.transform( new DOMSource(doc), new StreamResult(printer) );
Now, if we have
<xsl:value-of select="col" disable-output-escaping="yes"/>
in "templateName.xsl", the output will look like
"<p>&]]"
and if we have this
<xsl:value-of select="col"/>
the output will be
<p>&]]
so basically my question is, what kind of internal data representation JAXP uses such that this
"<p>&]]"
is OK? It cannot be a text node, and cannot be a CDATA node, too. What is it? There must be a valid XML document supplied for a transformation, I believe. On the other hand, disable-output-escaping attribute indicates that special characters should be output as-is, does it mean our "col" node is kept as in the code? How come the XML document is valid then?