The options --pf (preserve original formatting) and --ps (preserve non-significant spaces) only work partially.
Any tag which has line breaks between attributes is collapsed on a single line.
See example before and after.
xmlstarlet ed --pf --ps -u "/server/mbean/@code" -v org.mobicents.servlet.sip.startup.jboss.JBossSip before.xml >after.xml.
2009-09-14 11:11:58 UTC in XMLStarlet command line XML toolkit