Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » XML, XHTML editing, indenting
XML, XHTML editing, indenting [message #183155] Thu, 23 November 2006 05:56 Go to next message
Eclipse User
Originally posted by: marilen.corciovei.nemesisit.ro

Hello,

I have recently migrated from Idea to Eclipse and I am trying to find some
of the functionalities I got so used to especially xml editing.
I need to edit xml, xhtml, and various other "xml" like documents. I edit
xhtml like files which contain specific tags (for tapestry templates for
example) but I cannot convince the editor (from wtp) to proper indent
files. It seems to hate <span..> and is very keen on respecting the dtd.
All I need is some proper indentation of line start without attribute
splitting on multiple lines or adding new lines. After days of trouble the
only solution I found was to write an external python script which does
what I like (http://len.is-a-geek.org/down/xmlIndent.py/) and call it as
an external tool.

Is there an xml editor with this kind of indenting for eclipse? Is there
an easy way to write a code indenter?

Thank you,
Len
http://len.is-a-geek.org
Re: XML, XHTML editing, indenting [message #183232 is a reply to message #183155] Fri, 24 November 2006 21:27 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse4.rizzoweb.com

Marilen Corciovei wrote:
> Hello,
>
> I have recently migrated from Idea to Eclipse and I am trying to find
> some of the functionalities I got so used to especially xml editing. I
> need to edit xml, xhtml, and various other "xml" like documents. I edit
> xhtml like files which contain specific tags (for tapestry templates for
> example) but I cannot convince the editor (from wtp) to proper indent
> files. It seems to hate <span..> and is very keen on respecting the dtd.
> All I need is some proper indentation of line start without attribute
> splitting on multiple lines or adding new lines.

Sounds like you are just running into the line-length setting, which is
easy to change: Preferences > Web and XML > XML Files > XML Source.

After setting up those preferences the way you want, also look at the
general text editor preferences under General > Editors > Text Editors -
some of those are inherited by the other editors (XML, HTML, JSP, etc.)

Hope this helps,
Eric
Re: XML, XHTML editing, indenting [message #183239 is a reply to message #183232] Sat, 25 November 2006 12:31 Go to previous messageGo to next message
Eclipse User
Originally posted by: marilen.corciovei.nemesisit.ro

Thank you but I was not meaning line wrapping, I have already changed that
value from 80 to something more reasonable (for 1600x1200 resolution) but
take this example for instance:

<table>
<tr><td><img src="green.gif" alt="green light" title="green light"/></td><tr>
</table>

when using the format document command it generates:

<table>
<tr>
<td><img src="green.gif" alt="green light"
title="green light" /></td>
<tr>
</table>

when all I wanted was:

<table>
<tr><td><img src="green.gif" alt="green light" title="green
light"/></td><tr>

Not to mention that the <img .../> then ruins all auto completion.
</table>
Re: XML, XHTML editing, indenting [message #183298 is a reply to message #183239] Mon, 27 November 2006 18:54 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse4.rizzoweb.com

Marilen Corciovei wrote:
> Thank you but I was not meaning line wrapping, I have already changed
> that value from 80 to something more reasonable (for 1600x1200
> resolution) but take this example for instance:
>
> <table>
> <tr><td><img src="green.gif" alt="green light" title="green
> light"/></td><tr>
> </table>
>
> when using the format document command it generates:
>
> <table>
> <tr>
> <td><img src="green.gif" alt="green light"
> title="green light" /></td>
> <tr>
> </table>
>
> when all I wanted was:
>
> <table>
> <tr><td><img src="green.gif" alt="green light" title="green
> light"/></td><tr>


When I format an HTML file with that content, I get exactly what I would
consider expected:

<table>
<tr>
<td><img src="green.gif" title="green light" /></td>
<tr>
</table>

Are you sure that you edited the HTML Source preference? My original
recommendation specified the XML Source preferences, but they are separate.

Hope this helps,
Eric
Re: XML, XHTML editing, indenting [message #183367 is a reply to message #183298] Tue, 28 November 2006 16:53 Go to previous messageGo to next message
Eclipse User
Originally posted by: marilen.corciovei.nemesisit.ro

Take another case I have seen today:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<table class="tableList">
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<xsl:for-each select="//Property">
<tr>
<td><xsl:value-of select="@Name" /></td>
<td><xsl:value-of select="@Value" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

This gets formated as:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<table class="tableList">
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<xsl:for-each select="//Property">
<tr>
<td>
<xsl:value-of select="@Name" />
</td>
<td>
<xsl:value-of select="@Value" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

All I want is:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<table class="tableList">
<tr>
<th>Name</th>
<th>Value</th>
</tr>
<xsl:for-each select="//Property">
<tr>
<td><xsl:value-of select="@Name" /></td>
<td><xsl:value-of select="@Value" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

How can I control these newlines entered. In fact I only want the amount
of empty space in front of a line to change not for new lines to be added
or removed. If I have a <td><xsl:value-of select="@Name" /></td> then I
just need for this to be aligned at his place and not to be split in
several lines. Is this possible?

Thank you, Len
Re: XML, XHTML editing, indenting [message #183407 is a reply to message #183367] Tue, 28 November 2006 19:04 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse4.rizzoweb.com

Marilen Corciovei wrote:
> Take another case I have seen today:
>
> <?xml version="1.0"?>
> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" />
> <xsl:template match="/">
> <table class="tableList">
> <tr>
> <th>Name</th>
> <th>Value</th>
> </tr>
> <xsl:for-each select="//Property">
> <tr>
> <td><xsl:value-of select="@Name" /></td>
> <td><xsl:value-of select="@Value" /></td>
> </tr>
> </xsl:for-each>
> </table>
> </xsl:template>
> </xsl:stylesheet>
>
> This gets formated as:
>
> <?xml version="1.0"?>
> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="html" />
> <xsl:template match="/">
> <table class="tableList">
> <tr>
> <th>Name</th>
> <th>Value</th>
> </tr>
> <xsl:for-each select="//Property">
> <tr>
> <td>
> <xsl:value-of select="@Name" />
> </td>
> <td>
> <xsl:value-of select="@Value" />
> </td>
> </tr>
> </xsl:for-each>
> </table>
> </xsl:template>
> </xsl:stylesheet>
[snip]
> How can I control these newlines entered. In fact I only want the amount
> of empty space in front of a line to change not for new lines to be
> added or removed. If I have a <td><xsl:value-of select="@Name" /></td>
> then I just need for this to be aligned at his place and not to be split
> in several lines. Is this possible?

The formatting applied depends on the editor you are using. If this is
in the XML editor, the format gives each child element its own line
(rightly so, according to "accepted" XML formatting convention). The
HTML editor, however, keeps each <td> and its content and closing </td>
on a single line as long as the total line length does not exceed the
configured maximum.
There is no preference for telling it not to add any new lines - I'm not
sure formatting is very useful without that, but you are free to file an
enhancement request to make it a configurable option:
http://bugs.eclipse.org

As a work-around, you can highlight a line or group of lines and alter
the indentation by hitting Tab and Shit+Tab. That might be better for
you than applying the entire formatting rules using Ctrl+F.

Hope this helps,
Eric
Re: XML, XHTML editing, indenting [message #183438 is a reply to message #183407] Wed, 29 November 2006 11:57 Go to previous messageGo to next message
Eclipse User
Originally posted by: marilen.corciovei.nemesisit.ro

How difficult is to write an indentation plugin? Is this possible and
where should I start from? I whould be willing to write one myself to
replicate IntelliJ Idea functionality. For the moment I wrote some python
code which does a simple job: http://www.len.ro/down/xmlIndent.py/ just to
indent the line start.
Re: XML, XHTML editing, indenting [message #183460 is a reply to message #183367] Wed, 29 November 2006 14:51 Go to previous messageGo to next message
David Williams is currently offline David Williams
Messages: 696
Registered: July 2009
Senior Member
On Tue, 28 Nov 2006 11:53:11 -0500, Marilen Corciovei
<marilen.corciovei@nemesisit.ro> wrote:

> Take another case I have seen today:
>
....

>
> How can I control these newlines entered.....

In general, you should use <xsl:text> to let XSLT know that
you want _it_ to honor your newlines and spaces.

But ... I think our editor still won't correctly recognize that
yet. But, then you'd at least have a problem you could manually
control ... without the xsl:text, you may be seeing two problems,
one from editors formatter, and one from XSLT changing your formatting.
Re: XML, XHTML editing, indenting [message #183468 is a reply to message #183438] Wed, 29 November 2006 17:15 Go to previous messageGo to next message
Eclipse User
Originally posted by: eclipse5.rizzoweb.com

Marilen Corciovei wrote:
> How difficult is to write an indentation plugin? Is this possible and
> where should I start from? I whould be willing to write one myself to
> replicate IntelliJ Idea functionality. For the moment I wrote some
> python code which does a simple job:
> http://www.len.ro/down/xmlIndent.py/ just to indent the line start.
>

Plug-in development is not a trivial task, especially because I think
you are talking about changing the behavior of an existing editor (IOW,
extending an editor with custom behavior). Sorry, but I am not a plug-in
development expert so can't help with that.

As I said, you can highlight a line or lines and change the indentation
quite easily via Tab and Shift+Tab.
How does your desired behavior differ from that?

Eric
Re: XML, XHTML editing, indenting [message #183603 is a reply to message #183460] Fri, 01 December 2006 16:17 Go to previous message
Eclipse User
Originally posted by: marilen.corciovei.nemesisit.ro

Thank you very much for all you help.

Len
Previous Topic:Geronimo deployement plan editor does not work!?!
Next Topic:How to run stable milestone S-2.0M3-200611170109
Goto Forum:
  


Current Time: Wed Oct 22 08:01:46 GMT 2014

Powered by FUDForum. Page generated in 0.01941 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software