By turning the pretty-printing flag on, you gave the system permission to inject whitespace to indent the elements nicely. If that isn't what you wanted, don't request it....
______________________________________ "... Three things see no end: A loop with exit code done wrong, A semaphore untested, And the change that comes along. ..." -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish ( http://www.ovff.org/pegasus/songs/threes-rev-11.html) From: "Kahmyong Moon (JIRA)" <xalan-dev@xml.apache.org> To: xalan-dev@xml.apache.org Date: 10/01/2010 01:14 PM Subject: [jira] Created: (XALANJ-2523) Element containing only empty text serialized as element with whitespace when using DOM3 LS format-pretty-print Element containing only empty text serialized as element with whitespace when using DOM3 LS format-pretty-print --------------------------------------------------------------------------------------------------------------- Key: XALANJ-2523 URL: https://issues.apache.org/jira/browse/XALANJ-2523 Project: XalanJ2 Issue Type: Bug Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.) Components: Serialization Affects Versions: 2.7.1 Environment: Serializing through DOM 3 LS API from included Xerces-J (2.9.0). Reporter: Kahmyong Moon Priority: Minor I'm using DOM 3 LS to serialize a Document to an OutputStream with the format-pretty-print option. When I try to serialize an element containing only an empty text node, it serializes like this: <Element> </Element> When I load the XML later, the element content ends up "\n ", instead of "". I'm expecting the element to serialize like this: <Element /> Or at least like this: <Element></Element> Text nodes containing only whitespace and containing non-whitespace do serialize as expected: <Element> </Element> <Element>text</Element> I created the element like this: Document document; Element element; String text = ""; Text textNode = document.createTextNode(text); element.appendChild(textNode); As a workaround, if I check in my own code that the text is empty, and don't add a text node to the element, it serializes as expected: <Element /> It also works correctly if I normalize the document/element first (which removes the extraneous text node). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: xalan-dev-unsubscr...@xml.apache.org For additional commands, e-mail: xalan-dev-h...@xml.apache.org