Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327373 - Improve formatting of server.xml output.
Summary: Improve formatting of server.xml output.
Status: NEW
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: jst.server (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: Larry Isaacs CLA
QA Contact: Angel Vera CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 20:33 EDT by Scot Meyer CLA
Modified: 2011-07-21 17:45 EDT (History)
2 users (show)

See Also:


Attachments
Improve XML formatting (7.30 KB, patch)
2010-10-08 20:34 EDT, Scot Meyer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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