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
Before
After
The example doesn't seem to apply but I can confirm the bug:
$ cat ws.xml
<doc
a="foo"/>
$ xml ed --ps --pf ws.xml
<?xml version="1.0"?>
<doc a="foo"/>
Fixing this will be tricky, I haven't quite figured out how whitespace is handled but patching libxml2 will likely be required.
So currently --pf and --ps are indentical and don't work entirely as advertised: they preserve whitespace nodes in the tree, which means whitespace inside a tag is lost. I'm currently leaning towards just changing the documentation to reflect this rather than trying to fix it.
I've changed the --help message to describe the actual behaviour in commit dee21ea7e1357835fc90394e604a946a168be079.
I'm moving this to feature requests.
I don't think there is a realistic prospect of ever implementing this, short of completely rewriting xmlstarlet.