Bug 214516 - XML formatter should respect xml:space attribute
Summary: XML formatter should respect xml:space attribute
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 2.0.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-01-07 13:10 EST by David Carver CLA
Modified: 2008-04-24 00:43 EDT (History)
1 user (show)

See Also:


Attachments
Sample with Preserve space that doesn't format as expected (3.61 KB, text/xml)
2008-01-08 23:09 EST, David Carver CLA
no flags Details
Patch for Bug 214516 (2.26 KB, patch)
2008-01-22 16:19 EST, Nick Sandonato CLA
no flags Details | Diff
org.eclipse.wst.xml.core.tests.patch (6.89 KB, patch)
2008-01-23 16:14 EST, Amy Wu CLA
no flags Details | Diff
Patch to DefaultXMLPartitionFormatter and expected test result (2.17 KB, patch)
2008-01-24 15:25 EST, Nick Sandonato CLA
no flags Details | Diff
Patch for Bug 214516 as patch and not zip (5.62 KB, patch)
2008-01-24 15:33 EST, Nick Sandonato CLA
bjorn.freeman-benson: iplog+
Details | Diff
xml-space-preserve-standalone-newfmt.xml.patch (1.15 KB, patch)
2008-01-29 19:36 EST, Amy Wu CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2008-01-07 13:10:06 EST
Version: 3.3.1.1
Build id: M20071023-1652
WTP 2.0.1

The XML specificate allows for the attribute xml:space to be specified on an element.   This signifies whether spacing is significant or not.

http://www.simonstl.com/xmlprim/xmlupdate/atts.html

"Section 2.10 of the XML Recommendation defines a new attribute that allows elements to declare to an application whether their white space is 'significant'. This will probably receive extensive use in combination with XSL or perhaps the CSS white-space property to display documents correctly. Validating processors already must pass all non-markup characters to the application, and inform them of the element in which they appeared. This attribute acts as a flag, telling the application whether or not it should pay attention to the white space characters."

If the XML formatter currently doesn't check for this, it should as it allows a simple standard way for a user to control whether a particular element should be reformatted or not.
Comment 1 Amy Wu CLA 2008-01-08 18:47:33 EST
This should already be working. It was fixed in bug 111674.
please feel free to reopen if you find a specific scenario where this is not working.

*** This bug has been marked as a duplicate of bug 111674 ***
Comment 2 David Carver CLA 2008-01-08 22:59:33 EST
Re-Openning as it isn't behaving exactly as expected.  Sample to be attached to be used for testing.
Comment 3 David Carver CLA 2008-01-08 23:09:46 EST
Created attachment 86439 [details]
Sample with Preserve space that doesn't format as expected

The second programminglisting element after the first programmlisting element is not formatting as expected.  The sibling elements do not not contain an xml:space preserve element.   xml:space is supposed to affect the parent element and any child elements.  It doesn't affect siblings or ancestor elements.
Comment 4 David Carver CLA 2008-01-08 23:10:41 EST
changed to normal priority since this feature was already implemented in prior bug, just needs some tweaking for this use case.
Comment 5 Nitin Dahyabhai CLA 2008-01-22 15:58:53 EST
Reassigning to Nick
Comment 6 Nick Sandonato CLA 2008-01-22 16:19:12 EST
Created attachment 87566 [details]
Patch for Bug 214516

This patch addresses Bug 214516 by formatting elements with the xml:space="preserve" attribute.
Comment 7 Amy Wu CLA 2008-01-23 16:14:30 EST
Created attachment 87699 [details]
org.eclipse.wst.xml.core.tests.patch

Hi Nick,

I tested your patch, and I think there's still a lingering issue with child tags not respecting the parent's xml:space attribute.  The unit tests didn't have the correct results, so I think if you ran them, everything would've looked okay when it really wasn't.  I've attached a patch so that the unit tests had a more correct result.
Comment 8 Nick Sandonato CLA 2008-01-24 15:25:47 EST
Created attachment 87800 [details]
Patch to DefaultXMLPartitionFormatter and expected test result

Should resolve the problems related to children disregarding inherited space preservation.  Also updated the expected results of the xml-space-preserve-dtd-newfmt.xml.

This patch also contains a modification related to Bug 195264. It should have no impact on this bug.
Comment 9 Nick Sandonato CLA 2008-01-24 15:33:00 EST
Created attachment 87803 [details]
Patch for Bug 214516 as patch and not zip

Accidentally attached the patch in a zip file.  This is the correct patch.
Comment 10 Amy Wu CLA 2008-01-29 19:36:50 EST
Created attachment 88227 [details]
xml-space-preserve-standalone-newfmt.xml.patch

I made some changes to xml.core.tests for bug 198297 that overlapped with the changes for this bug.  So here's an updated patch on just one file.  So to fix this bug, you just need to apply this patch as well as Nick's.
Comment 11 Amy Wu CLA 2008-01-30 19:22:42 EST
Released Nick's fix for this week's WTP 3.0 M5 ibuild.
Comment 12 Nick Sandonato CLA 2008-02-11 17:09:46 EST
verified in wtp 3.0 m5 20080211073521
Comment 13 David Williams CLA 2008-04-24 00:43:43 EDT
mass change to add 'contributed' keyword based on bugzilla query, please correct if that's not accurate (by marking patches as obsolete and removing the 'contributed' keyword.