Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » XML editor autoformat
XML editor autoformat [message #230154] Wed, 08 April 2009 08:47 Go to next message
Michiel van Wezel is currently offline Michiel van WezelFriend
Messages: 8
Registered: July 2009
Junior Member
Dear all,

I'm using eclipse's (version 3.4.2) xml editor to edit a configuration xml
for my application. The configuration file is quite complex, so autoformat
comes in handy.

Some elements of my xml file contain script code. I want the autoformatter
to leave those elements alone and NOT format them like regular text.

Is there a way to achieve this? Any hint welcome.

(I know that i can set the XML editor preferences under
window->preferences, and that i can check `Preserve Whitespace in Tags
with PCDATA content'. But that doesn't help me, probably because my xml is
schema-based, and PCDATA is a DTD concept.)

Thanks, Mike
Re: XML editor autoformat [message #230162 is a reply to message #230154] Wed, 08 April 2009 09:32 Go to previous messageGo to next message
Michiel van Wezel is currently offline Michiel van WezelFriend
Messages: 8
Registered: July 2009
Junior Member
Strange, when i uncheck the `clear all blank lines' option, the XML
formatter does respond to the `preserve whitespace in PCDATA tags'
option... Could it be that the formatter is still slightly buggy?
Re: XML editor autoformat [message #230168 is a reply to message #230154] Wed, 08 April 2009 14:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Have you tried adding the xml:space="preserve" attribute to those
elements where you want to keep the formatting that you have specified?

Dave


Mike W wrote:
> Dear all,
>
> I'm using eclipse's (version 3.4.2) xml editor to edit a configuration
> xml for my application. The configuration file is quite complex, so
> autoformat comes in handy.
> Some elements of my xml file contain script code. I want the
> autoformatter to leave those elements alone and NOT format them like
> regular text.
> Is there a way to achieve this? Any hint welcome.
> (I know that i can set the XML editor preferences under
> window->preferences, and that i can check `Preserve Whitespace in Tags
> with PCDATA content'. But that doesn't help me, probably because my xml
> is schema-based, and PCDATA is a DTD concept.)
>
> Thanks, Mike
>
>
>
Re: XML editor autoformat [message #230174 is a reply to message #230162] Wed, 08 April 2009 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

Yes, there are several known bugs in the formatter. If you do a search
on "format" in the summary of the wst.xml component you'll find about 24
of them that have been opened.

We are aware of them, and hope to address them in the near future.

Dave

Mike W wrote:
> Strange, when i uncheck the `clear all blank lines' option, the XML
> formatter does respond to the `preserve whitespace in PCDATA tags'
> option... Could it be that the formatter is still slightly buggy?
>
>
Re: XML editor autoformat [message #230182 is a reply to message #230168] Wed, 08 April 2009 19:42 Go to previous messageGo to next message
Michiel van Wezel is currently offline Michiel van WezelFriend
Messages: 8
Registered: July 2009
Junior Member
Hello Dave,

Thanks for your reply! The autoformatter now works good enough, when not
discarding empty lines... If i run into trouble again i'll try the
xml:space="preserve" attribute.

Thanks! Mike
Re: XML editor autoformat [message #230198 is a reply to message #230168] Wed, 08 April 2009 21:08 Go to previous message
Michiel van Wezel is currently offline Michiel van WezelFriend
Messages: 8
Registered: July 2009
Junior Member
This worked, although i had to restart eclipse after changing the xsd.

The xsd for the script element now looks as follows:

<xs:element
name="scriptBlock"
minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension
base="xs:string">
<xs:attribute
ref="xml:space"
fixed="preserve" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

In the top of the xsd file, you must also import the xml namespace
and declare the namespace in the schema element

<xs:schema
targetNamespace="http://www.yourcompany.com"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns="http://www.yourcompany.com">

<xs:import
namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/xml.xsd" />

Hope this is useful for some.

Bye, Mike
Previous Topic:Start Server with Error Message
Next Topic:WTP project configuration is failing
Goto Forum:
  


Current Time: Thu Apr 18 15:07:18 GMT 2024

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

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

Back to the top