This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 188941

Summary: regression in XML formatting
Product: xml Reporter: David Konecny <dkonecny>
Component: Text-EditAssignee: Svata Dedic <sdedic>
Status: VERIFIED FIXED    
Severity: normal CC: mfukala, mmirilovic, pjiricka
Priority: P2    
Version: -S1S-   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: screen shot 1
screen shot 2
screenhost

Description David Konecny 2010-07-25 22:50:22 UTC
I reformatted XML document (it had no indent) and this is the result:

<?xml version="1.0" encoding="UTF-8"?>
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping http://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd"
xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
    <bean 
class="" 
ignore-annotations="">
    </bean>
</constraint-mappings>

Notice that tag attributes have wrong indent. Filing as P2 as it looks like regression. Feel free to downgrade if impact of problem is limited.

  Product Version         = NetBeans IDE Dev (Build 100726-3807de0e15c5) (#3807de0e15c5)
  Operating System        = Linux version 2.6.32-23-generic running on i386
  Java; VM; Vendor        = 1.6.0_20; Java HotSpot(TM) Client VM 16.3-b01; Sun Microsystems Inc.
  Runtime                 = Java(TM) SE Runtime Environment 1.6.0_20-b02
Comment 1 Sergey Lunegov 2010-07-26 06:36:40 UTC
Alex, please take a look.
Comment 2 _ alexpetrov 2011-03-10 12:40:09 UTC
Please, provide the scenario to reproduce this bug.
I've tried to reproduce the bug on trunk
Product Version: NetBeans IDE Dev (Build 110309-cd836e06a728)
Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16
System: Linux version 2.6.18-8.el5 running on i386; UTF-8; en_US (nb)

My steps were:
1. Create a new .xml file with the following content (xml text is placed in one line, see the attached "screenshot_xml_formatting-1.png"):
<?xml version="1.0" encoding="UTF-8"?><constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mappinghttp://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd" xmlns="http://jboss.org/xml/ns/javax/validation/mapping"><bean class="" ignore-annotations=""></bean></constraint-mappings>

2. Click the right mouse button and select the menu item "Format" or press "Alt+Shift+F"

Result:
xml content has been formatted (see the attached "screenshot_xml_formatting-2.png"):
<?xml version="1.0" encoding="UTF-8"?>
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mappinghttp://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd" xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
    <bean class="" ignore-annotations=""></bean>
</constraint-mappings>
Comment 3 _ alexpetrov 2011-03-10 12:42:05 UTC
Created attachment 106875 [details]
screen shot 1
Comment 4 _ alexpetrov 2011-03-10 12:43:03 UTC
Created attachment 106876 [details]
screen shot 2
Comment 5 David Konecny 2011-03-10 18:21:44 UTC
Product Version: NetBeans IDE Dev (Build 110308-042ec1205e88)
Java: 1.6.0_24; Java HotSpot(TM) 64-Bit Server VM 19.1-b02
System: Linux version 2.6.35-27-generic running on amd64; UTF-8; en_NZ (nb)
Userdir: /home/david/.netbeans/_UD4

If I reformat following XML document:

  <?xml version="1.0" encoding="UTF-8"?>
  <constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping
  http://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd"
  xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
  <bean 
  class="" 
  ignore-annotations="">
  </bean>
  <default-package>
  xxxxxx    
  </default-package>
  </constraint-mappings>


the result I got is 

  <?xml version="1.0" encoding="UTF-8"?>
  <constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping
  http://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd"
  xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
      <bean 
  class="" 
  ignore-annotations="">
      </bean>
      <default-package>
  xxxxxx    
      </default-package>
  </constraint-mappings>


I do not knot if this is regression or if it never worked but I would expect following indentation:

  <?xml version="1.0" encoding="UTF-8"?>
  <constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping
          http://jboss.org/xml/ns/javax/validation/mapping/validation-mapping-1.0.xsd"
      xmlns="http://jboss.org/xml/ns/javax/validation/mapping">
      <bean 
          class="" 
          ignore-annotations="">
      </bean>
      <default-package>
          xxxxxx    
      </default-package>
  </constraint-mappings>
Comment 6 _ alexpetrov 2011-03-11 12:02:56 UTC
Please, explain what does it mean "reformat"?
Which menu item or key combination do you use for reformatting of xml document?
Please, describe your scenario (step by step) - I'd like to reproduce this bug.
Comment 7 David Konecny 2011-03-13 19:12:49 UTC
Created attachment 106957 [details]
screenhost

I do not understand what's so complicated in reproducing this issue. #1) create a new XML Document; #2) copy and paste XML from this issue; #3) ALT+SHIFT+F. Do you want me to attach screenshots?? Here it is. Screenshot was taken after XML document was reformatted and I'm arguing that we should do better job than that - tag attributes are not indented properly, tag value is not properly indented and tag's attribute value which span two lines is not indented either.
Comment 8 Sergey Petrov 2011-03-14 17:06:22 UTC
all lines not started with < are unaffected by format, it may have sense in case if it's CDATA/text node but if line start with attribute name it's good to align  this line to corresponding tag indent.
Comment 9 Sergey Petrov 2011-03-14 17:18:42 UTC
will try to fix, or release "lock" after a day or two.
Comment 10 David Konecny 2011-03-14 17:47:40 UTC
If it always worked like this then I would downgrade to P3. But if it is a recent regression then it would be good to investigate what caused the regression and what impact it has, eg. it is limited to formatting case discussed in this issue or ...
Comment 11 Sergey Petrov 2011-03-15 13:19:24 UTC
ok, made small investigation and it works in 6.8 so it's a regression but unfortunately quite old regression now.
Comment 12 Sergey Petrov 2011-03-15 13:20:58 UTC
6.8 also move 'xxxxxx' from sample above, wonder if it was some fix to prevent text nodes reformatting or just plain no-reason regression.
Comment 13 Sergey Petrov 2011-03-15 16:41:04 UTC
I don't see any changes can be considered as related in "xml.text" between 20100404 (6.8) and report date, it may be something in root classes but there are deprecated classes usage in some places.
Comment 14 David Konecny 2011-03-15 20:14:40 UTC
So it has not worked for a while and nobody notice this issue earlier. Means it is not a stopper. It would be nice to improve it if possible but my own experience with indentation/formatting is that it is far from trivial and likelihood of regression pretty high. Let's fix this in next release.
Comment 15 Petr Jiricka 2011-03-16 09:04:58 UTC
Ok, requesting a waiver for NB 7.0.
Comment 16 Petr Jiricka 2011-03-21 09:48:51 UTC
Waiver approved.
Comment 17 Petr Jiricka 2011-05-04 12:51:11 UTC
Requesting a waiver for NetBeans 7.0.1.
Comment 18 Petr Jiricka 2011-05-06 14:52:09 UTC
Approved.
Comment 19 Svata Dedic 2011-10-07 16:17:08 UTC
Fixed in jet-main #1d211f79d539
Comment 20 Quality Engineering 2011-10-10 12:27:12 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/1d211f79d539
User: Svata Dedic <sdedic@netbeans.org>
Log: #188941: implemented formatting XML attributes, end braces and processing instructions.