Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » XML formatting
XML formatting [message #213800] Wed, 14 May 2008 09:49 Go to next message
Eclipse UserFriend
Originally posted by: adam.hardy.no.spam.cyberspaceroad.spam

I'm writing XDoc documentation and I'm using the XML editor.

My problem is that I have code extracts in my documentation, and I don't want
the XML editor to reformat the code blocks (which will remove the CRLFs and
destroy the code readability).

Is there a tag I can wrap them in which the XML editor format operation will
ignore?

Sorry if this is the wrong forum - it seems the most suitable on the list of
newsgroups. If not, which would be the right place?

Thanks
Adam
Re: XML formatting [message #213832 is a reply to message #213800] Wed, 14 May 2008 13:44 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick SandonatoFriend
Messages: 126
Registered: July 2009
Senior Member
Adam,

Try putting the code in a CDATA section:

<code>
<![CDATA[
function doSomething() {
return;
}
]]>
</code>

The formatter should skip over this section.

--Nick

adam hardy wrote:
> I'm writing XDoc documentation and I'm using the XML editor.
>
> My problem is that I have code extracts in my documentation, and I don't
> want the XML editor to reformat the code blocks (which will remove the
> CRLFs and destroy the code readability).
>
> Is there a tag I can wrap them in which the XML editor format operation
> will ignore?
>
> Sorry if this is the wrong forum - it seems the most suitable on the
> list of newsgroups. If not, which would be the right place?
>
> Thanks
> Adam
Re: XML formatting [message #213871 is a reply to message #213800] Wed, 14 May 2008 17:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

adam hardy wrote:
> I'm writing XDoc documentation and I'm using the XML editor.
>
> My problem is that I have code extracts in my documentation, and I don't
> want the XML editor to reformat the code blocks (which will remove the
> CRLFs and destroy the code readability).
>
> Is there a tag I can wrap them in which the XML editor format operation
> will ignore?
>
> Sorry if this is the wrong forum - it seems the most suitable on the
> list of newsgroups. If not, which would be the right place?

Nick mentioned using CDATA sections, which is one way, the other way to
do this is to add the xml:space="perserve" attribute to to your element
that contains the code that you don't want to format.


Dave
Re: XML formatting [message #213894 is a reply to message #213871] Thu, 15 May 2008 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam.hardy.no.spam.cyberspaceroad.spam

David Carver on 14/05/08 18:24, wrote:
> adam hardy wrote:
>> I'm writing XDoc documentation and I'm using the XML editor.
>>
>> My problem is that I have code extracts in my documentation, and I
>> don't want the XML editor to reformat the code blocks (which will
>> remove the CRLFs and destroy the code readability).
>>
>> Is there a tag I can wrap them in which the XML editor format
>> operation will ignore?
>>
>> Sorry if this is the wrong forum - it seems the most suitable on the
>> list of newsgroups. If not, which would be the right place?
>
> Nick mentioned using CDATA sections, which is one way, the other way to
> do this is to add the xml:space="perserve" attribute to to your element
> that contains the code that you don't want to format.

The CDATA works well, but the xml:space didn't work until I spotted the typo!
That's a very interesting attribute and it makes me wonder how many more useful
attributes there are like that - can you recommend a good xml documentation website?

Thanks,
Adam
Re: XML formatting [message #213915 is a reply to message #213894] Thu, 15 May 2008 19:05 Go to previous message
Eclipse UserFriend
Originally posted by: dcarver.starstandard.org

adam hardy wrote:

> The CDATA works well, but the xml:space didn't work until I spotted the
> typo! That's a very interesting attribute and it makes me wonder how
> many more useful attributes there are like that - can you recommend a
> good xml documentation website?

Yeah, it should be 'preserve'. You can get some more information on
various features of XML that may not be well known in the following article.

http://xml.com/pub/a/98/10/guide0.html?page=1

Dave


>
> Thanks,
> Adam
Previous Topic:Refactoring support for XML files
Next Topic:reuse the project facets framework for other wizards
Goto Forum:
  


Current Time: Thu Dec 18 10:32:39 GMT 2014

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

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