XML/XSLT Indent options - more tags in one line.

Are you missing a feature? Request its implementation here.
ripos
Posts: 5
Joined: Mon Jan 22, 2007 4:20 pm
Contact:

XML/XSLT Indent options - more tags in one line.

Post by ripos »

I'm writing XSLT transformations to the XML of the specified structure,
so most of the code looks like this:

Code: Select all

<LineOne>
<xsl:value-of select="$bill-to/ADDRESS1"/>
</LineOne>
<LineTwo>
<xsl:value-of select="$bill-to/ADDRESS2"/>
</LineTwo>
This is after autoformatting of the code.

I'm not sure, but looks like it is not possible to tell oXygen to preserve line non-breaks if possible.
I'm writing strings, that are far from the line width, but still they are reformatted.
The code became much longer and much less readable.

I want to preserve next string after autoformat:

Code: Select all

<LineOne><xsl:value-of select="$bill-to/ADDRESS1"/></LineOne>
<LineTwo><xsl:value-of select="$bill-to/ADDRESS2"/></LineTwo>
What should I set in the options?.. or if it is not possible when there will be release where can I see this?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

Hello,

If LineOne and LineTwo do not contain text child elements then oXygen assumes they have element only content model so it places each child element on a new line indented with the size defined in Preferences -> Editor -> Format -> Indent size. The result is considered generally more readable than placing the child elements on the same line with the parent, in your case LineOne or LineTwo. If you want to preserve child elements on the same line with the parent you have to add the element names of LineOne and LineTwo in the Preserve space elements list available in Preferences -> Editor -> Format -> XML.


Regards,
Sorin
ripos
Posts: 5
Joined: Mon Jan 22, 2007 4:20 pm
Contact:

Post by ripos »

Thanks for such quick and good reply.

But I did not find these options:
I go to Options/Editor/Format/XML.

Here are the options:
[ ] Format and indent document on the open
[ ] Expand empty elements
[ ] Add space before slash in empty elements
[ ] Sort attributes
[x] Preserve empty lines
[x] Preserve text as it is
[ ] Preserve line breaks in attributes
[x] Break ling attributes
[ ] Break line before attribute's name

I'm using oXygen 8.0 build 2006112715
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

The Preserve space elements list is located under

[ ] Break line before attribute's name

To edit the list use the Add and Remove buttons located inside the panel with the title "Preserve space elements (XPath)". Press F1 to read in the User Manual about using these options.

The Indent size option is available in Preferences -> Editor -> Format.


Regards,
Sorin
ripos
Posts: 5
Joined: Mon Jan 22, 2007 4:20 pm
Contact:

Post by ripos »

Sorry for the inconvinience, but I still do not understand.

I should exlude from cutting the spaces in all tags, that have only only tag xsl:value-of inside.

I have tried to add into the preserve list:

Code: Select all

*[xsl:value]
But it does not help.

Could you please help me with the correct XPath that I should insert?
[/code]
ripos
Posts: 5
Joined: Mon Jan 22, 2007 4:20 pm
Contact:

Post by ripos »

Oups. I mistyped.

Code: Select all

*[xsl:value-of]
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

ripos wrote:

Code: Select all

*[xsl:value-of]
This form of XPath expression is not supported in the Preserve space elements list. Press F1 when the Editor / Format / XML preferences page is displayed to read about the supported forms:

- author
- //listing
- /chapter/abstract/title
- //xs:documentation

You have to add the name of the parent element of xsl:value-of in the list, that is LineOne, LineTwo.


Regards,
Sorin
ripos
Posts: 5
Joined: Mon Jan 22, 2007 4:20 pm
Contact:

Post by ripos »

Thanks a lot for the reply!

This does not solve my problem at all.

So this thread is a true feature request.

I want to more tweaks to autoformatting mechanism.

For example I want to apply next rules:
1) if tag opening and ending are on the same line, then do not reformat them.
2) If the tag is longer then one line, then there could not be any other tags on these lines (except comments)

I do not request to make it fast. Just as a suggestion for the improvment.
You may also look for the IntelliJ IDEA development IDE. They have pretty much autoformatting tweaks. =) And good system of their managment.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache »

ripos wrote:I want to more tweaks to autoformatting mechanism.

For example I want to apply next rules:
1) if tag opening and ending are on the same line, then do not reformat them.
2) If the tag is longer then one line, then there could not be any other tags on these lines (except comments)
We will analyze these formatting options.

Thank you,
Sorin
Post Reply