Format and Indent Toggle
Posted: Wed Dec 28, 2011 2:05 am
(Jump in if there's a feature in oxygen that I've missed which does what I'm asking below)
I tried the xml:space attribute declaration thinking I would be able to basically use it as a toggle for pretty print. Eg., for an ant build file,
Such that the result of a "Format and Indent" would be...
Note that the "preserveExistingFormatting" target has not been mucked with, but the "reformat" target has. But, when I actually run a Format and Indent using the xml:space attribute, everything is reflowed. Am I not understanding what function xml:space is supposed to provide within oXygen?
It's also awkward that it appears as though xml:space must be declared for each element. Is that correct?
I use a couple of code formatters and each has an inline marker that allows one to enable or disable the formatter throughout a document. For example, Jindent uses "//j+" and "//j-" to toggle reformatting. Eclipse uses "// @formatter:on" and "// @formatter:off".
If xml:space isn't meant to provide what I'm looking for, could I suggest an inline comment to toggle formatting?
Eg., something similar to...
Justification:
I work on a lot of files that were originally written by others, and for whom any type of logical indenting was foreign.
I like my additions to be neat and tidy, but I can't touch the rest of the file as it is SCMd and the diff would freak people out.
I know I can individually format elements, but I would like a much coarser control, as I may be adding dozens of complex elements.
It would be great if I could just insert <!-- oXygenFormat=off --> after the <?xml> declaration, turn it on for my block, and then back off for the rest of the file. This ensures that I don't accidentally format the entire thing without noticing. Can you tell I've caused a diff freak-out before?
-David
I tried the xml:space attribute declaration thinking I would be able to basically use it as a toggle for pretty print. Eg., for an ant build file,
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE
project [
<!ATTLIST project xml:space (default|preserve) 'preserve'>
<!ATTLIST target xml:space (default|preserve) 'preserve'>
]>
<project name="OIM" default="startDomain" basedir=".">
<target name="preserveExistingFormatting">
<something/><something/>
</target>
<target name="reformat" xml:space="default">
<something/><something/>
</target>
</project>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE
project [
<!ATTLIST project xml:space (default|preserve) 'preserve'>
<!ATTLIST target xml:space (default|preserve) 'preserve'>
]>
<project name="OIM" default="startDomain" basedir=".">
<target name="preserveExistingFormatting">
<something/><something/>
</target>
<target name="reformat" xml:space="default">
<something/>
<something/>
</target>
</project>
It's also awkward that it appears as though xml:space must be declared for each element. Is that correct?
I use a couple of code formatters and each has an inline marker that allows one to enable or disable the formatter throughout a document. For example, Jindent uses "//j+" and "//j-" to toggle reformatting. Eclipse uses "// @formatter:on" and "// @formatter:off".
If xml:space isn't meant to provide what I'm looking for, could I suggest an inline comment to toggle formatting?
Eg., something similar to...
Code: Select all
<!-- oXygenFormat=on -->
<!-- oXygenFormat=off -->
I work on a lot of files that were originally written by others, and for whom any type of logical indenting was foreign.
I like my additions to be neat and tidy, but I can't touch the rest of the file as it is SCMd and the diff would freak people out.
I know I can individually format elements, but I would like a much coarser control, as I may be adding dozens of complex elements.
It would be great if I could just insert <!-- oXygenFormat=off --> after the <?xml> declaration, turn it on for my block, and then back off for the rest of the file. This ensures that I don't accidentally format the entire thing without noticing. Can you tell I've caused a diff freak-out before?
-David