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

Bug 327373

Summary: Improve formatting of server.xml output.
Product: [WebTools] WTP ServerTools Reporter: Scot Meyer <meyer_scot>
Component: jst.serverAssignee: Larry Isaacs <larryisaacs>
Status: NEW --- QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3 CC: ccc, eyuen7
Version: 3.1   
Target Milestone: Future   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
Improve XML formatting none

Description Scot Meyer CLA 2010-10-08 20:33:11 EDT
In org.eclipse.jst.server.tomcat.core.internal.xml.Factory.java it was requested to improve the xml formatting.

53: // TODO Try to improve formating, maybe dup an appropriate text node

Initially an attempt was made to use a TransformerFactory within javax.xml.transform however it didn't always honor the current indentation of the existing XML.  On occasion it also wouldn't indent correctly even though it should have.  Therefore code was written to do a better job honoring existing indentation as well as remove extraneous indentation that may have been added by prior indentation requests.  This patch attempts to determine the most common indentation level for a Node and then copy it to the node being inserted.  When an indented node is removed the extra space is removed.  If there was no indentation, such as server.xml files prior to this implementation it will leave the existing node.

server.xml prior to patch: (Note Context right next to end of Valve)
...
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." resolveHosts="false" suffix=".txt"/><Context docBase="WebApplication1" path="/WebApplication1" reloadable="true" source="org.eclipse.jst.jee.server:WebApplication1"/>

      </Host>
...

Would now have Context on its own line with the correct indentation
...
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." resolveHosts="false" suffix=".txt"/>
        <Context docBase="WebApplication1" path="/WebApplication1" reloadable="true" source="org.eclipse.jst.jee.server:WebApplication1"/>

      </Host>
...
Comment 1 Scot Meyer CLA 2010-10-08 20:34:05 EDT
Created attachment 180533 [details]
Improve XML formatting