-
Bug
-
Resolution: Fixed
-
P3
-
9, 11, 12, 13
-
b150
-
b05
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Confirmed in both 11.0.3 and 12.0.1
A DESCRIPTION OF THE PROBLEM :
When formatting an XML file using javax.xml.transform.Transformer with OutputKeys.INDENT set to yes, additional whitespace is added before and after CDATA tags.
REGRESSION : Last worked in version 8u212
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Format the XML below using javax.xml.transform.Transformer with OutputKeys.INDENT set to yes
<foo><bar><![CDATA[data]]></bar></foo>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
<foo>
<bar><![CDATA[data]]></bar>
</foo>
ACTUAL -
<foo>
<bar>
<![CDATA[data]]>
</bar>
</foo>
---------- BEGIN SOURCE ----------
@Test
public void test() throws TransformerException, ParserConfigurationException, IOException, SAXException
{
String data = "data";
StreamSource source = new StreamSource(new StringReader("<foo><bar><![CDATA[" + data + "]]></bar></foo>"));
StreamResult result = new StreamResult(new StringWriter());
Transformer tform = TransformerFactory.newInstance().newTransformer();
tform.setOutputProperty(OutputKeys.INDENT, "yes");
tform.transform(source, result);
String xml = result.getWriter().toString(); // This String contains the extra whitespace
Document document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(new InputSource(new StringReader(xml)));
String resultData = document.getElementsByTagName("bar")
.item(0)
.getTextContent();
assertEquals(data, resultData);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None currently known
FREQUENCY : always
Confirmed in both 11.0.3 and 12.0.1
A DESCRIPTION OF THE PROBLEM :
When formatting an XML file using javax.xml.transform.Transformer with OutputKeys.INDENT set to yes, additional whitespace is added before and after CDATA tags.
REGRESSION : Last worked in version 8u212
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Format the XML below using javax.xml.transform.Transformer with OutputKeys.INDENT set to yes
<foo><bar><![CDATA[data]]></bar></foo>
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
<foo>
<bar><![CDATA[data]]></bar>
</foo>
ACTUAL -
<foo>
<bar>
<![CDATA[data]]>
</bar>
</foo>
---------- BEGIN SOURCE ----------
@Test
public void test() throws TransformerException, ParserConfigurationException, IOException, SAXException
{
String data = "data";
StreamSource source = new StreamSource(new StringReader("<foo><bar><![CDATA[" + data + "]]></bar></foo>"));
StreamResult result = new StreamResult(new StringWriter());
Transformer tform = TransformerFactory.newInstance().newTransformer();
tform.setOutputProperty(OutputKeys.INDENT, "yes");
tform.transform(source, result);
String xml = result.getWriter().toString(); // This String contains the extra whitespace
Document document = DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
.parse(new InputSource(new StringReader(xml)));
String resultData = document.getElementsByTagName("bar")
.item(0)
.getTextContent();
assertEquals(data, resultData);
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None currently known
FREQUENCY : always
- relates to
-
JDK-8262285 XML Transform using indent creates empty (whitespaces) lines
- Closed