Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 361708

Summary: "Preserve whitespace in tags with PCDATA content" doesn't seem to be working.
Product: [WebTools] WTP Source Editing Reporter: Missing name <alacqua>
Component: wst.xmlAssignee: wst.xml <wst.xml-inbox>
Status: RESOLVED INVALID QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Missing name CLA 2011-10-21 17:01:35 EDT
Build Identifier: 20110615-0604

Assuming I understand just what PCDATA content is, then the "Preserve whitespace in tags with PCDATA content" option in "Window->Preferences->XML->XML Files->Editor" doesn't seem to be stopping the xml formatter from inserting extra whitespace (e.g. line breaks) into tags with PCDATA content.

With that option checked, and with line width set to 5, I format the following xml (using Shift-Ctrl-F).

<?xml version="1.0" encoding="UTF-8"?>
<test><line1>This is a test of <i>the</i> emergency broadcasting system.</line1><line2>This is only a test.</line2></test>

I expect something like this...

<?xml version="1.0" encoding="UTF-8"?>
<test>
   <line1>This is a test of <i>the</i> emergency broadcasting system.</line1>
   <line2>This is only a test.</line2>
</test>

but what I get is this...

<?xml version="1.0" encoding="UTF-8"?>
<test>
   <line1>
      This
      is
      a
      test
      of
      <i>
         the
      </i>
      emergency
      broadcasting
      system.
   </line1>
   <line2>
      This
      is
      only
      a
      test.
   </line2>
</test>


Reproducible: Always

Steps to Reproduce:
1. Create an xml file with the above contents.
2. In XML editor settings, change line width to "5" and check "Preserve whitespace in tags with PCDATA content".
3. Open the file you created and format it by typing Shift-Ctrl-F.
Comment 1 Missing name CLA 2011-10-21 17:13:42 EDT
Comment formatting seems to have added a line break in the test case I put in the initial post. Before formatting, the xml file has only two line breaks, one before the <test> start tag and one after the </test> end tag which ends the document.
Comment 2 Nitin Dahyabhai CLA 2011-10-21 17:43:29 EDT
That feature requires you to reference a grammar that declares the element as having #PCDATA for content.  See http://en.wikipedia.org/wiki/Document_Type_Definition#Element_type_declarations .