Page 1 of 1

Customizable code formatting

Posted: Thu Jul 24, 2008 4:33 pm
by Zearin
Currently the control over code formatting isn't as tweakable as I'd like in Oxygen. I was working on a project the other day when I suddenly had an epiphany: rule-based formatting!

Duh! It makes perfect sense. When I found myself wishing for a way to automate formatting of my code, I initially thought to myself, "Well, it will be boring and a diversion from my current projects, but I could write an XSL stylesheet to format code…" That way I would get all the control I need.

But then I realized that the control is coming from XPath. So, I would like to put in a request for XPath-based rules for code formatting. You've already got great XPath support built-in, so if I could just specify rules like, "Normalize all space within the text of <p> elements", then I could just type in "p/text()" and check a box that says "normalize".

Re: Customizable code formatting

Posted: Thu Jul 24, 2008 4:43 pm
by sorin_ristache
Hello,

Thank you for your request. We will consider it for a future version but the implementation of formatting of an XML document based on XPath rules seems very hard. You should create your own XSLT stylesheet for your tweaked XML formatting until we implement this type of XML formatting.


Regards,
Sorin

Re: Customizable code formatting

Posted: Fri Jul 25, 2008 12:58 am
by Zearin
Awww. :(

Well, dare to dream, I spose.

Thanks for the quick response!

Re: Customizable code formatting

Posted: Fri Jul 25, 2008 11:49 am
by sorin_ristache
If you want only the normalization of some elements specified by an XPath expression you can use the Strip space elements list available in Preferences -> Editor -> Format -> XML. In this list you can add XPath expressions for elements for which the Format and Indent action normalizes the whitespaces.


Regards,
Sorin