Return-Path: Delivered-To: apmail-xerces-commits-archive@www.apache.org Received: (qmail 70225 invoked from network); 16 Sep 2008 13:16:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Sep 2008 13:16:18 -0000 Received: (qmail 93475 invoked by uid 500); 16 Sep 2008 13:16:15 -0000 Delivered-To: apmail-xerces-commits-archive@xerces.apache.org Received: (qmail 93451 invoked by uid 500); 16 Sep 2008 13:16:15 -0000 Mailing-List: contact commits-help@xerces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@xerces.apache.org Received: (qmail 93442 invoked by uid 99); 16 Sep 2008 13:16:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 06:16:15 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 13:15:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 162E6238896F; Tue, 16 Sep 2008 06:15:28 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r695864 - /xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Date: Tue, 16 Sep 2008 13:15:26 -0000 To: commits@xerces.apache.org From: borisk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080916131528.162E6238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: borisk Date: Tue Sep 16 06:15:25 2008 New Revision: 695864 URL: http://svn.apache.org/viewvc?rev=695864&view=rev Log: Avoid pretty-printing comments only in text-only nodes. Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp?rev=695864&r1=695863&r2=695864&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp (original) +++ xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Tue Sep 16 06:15:25 2008 @@ -1145,6 +1145,47 @@ if (checkFilter(nodeToWrite) != DOMNodeFilter::FILTER_ACCEPT) break; + // Figure out if we want pretty-printing for this comment. + // If this comment node does not have any element siblings + // (i.e., it is a text node) then we don't want to add any + // whitespaces since that might be significant to the + // application. Otherwise we want pretty-printing. + // + + bool pretty = (level == 0); // Document-level comments. + + if (!pretty) + { + // See if we have any element siblings. + // + const DOMNode* s = nodeToWrite->getNextSibling (); + + while (s != 0 && s->getNodeType () != DOMNode::ELEMENT_NODE) + s = s->getNextSibling (); + + if (s != 0) + pretty = true; + else + { + s = nodeToWrite->getPreviousSibling (); + + while (s != 0 && s->getNodeType () != DOMNode::ELEMENT_NODE) + s = s->getPreviousSibling (); + + if (s != 0) + pretty = true; + } + } + + if (pretty) + { + if(level == 1 && getFeature(FORMAT_PRETTY_PRINT_1ST_LEVEL_ID)) + printNewLine(); + + printNewLine(); + printIndent(level); + } + TRY_CATCH_THROW ( *fFormatter << XMLFormatter::NoEscapes << gStartComment --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org For additional commands, e-mail: commits-help@xerces.apache.org