otrdiena, 2012. gada 18. septembris

Delphi, xml and parse/format doc with two space ident

Today I got to solve xml format problem with Delphi. It appears that by default delphi uses tab for xml element indent. I had to find some hacks to work it properly and I think it's worth to share.

So before processing I did:


    Doc := TXMLDocument.Create(nil);
    Doc.ParseOptions := Doc.ParseOptions + [poPreserveWhiteSpace];

That seems to remove default behaviour of indenting with tabs. But now when I insert new node I get it without indents at all. So I have to "reparse" doc before save:

    Doc.XML.Text := xmlDoc.FormatXMLData(Doc.XML.Text);
    Doc.Active := true;

I did not experiment with - Doc.NodeIndentStr := '  '; because two spaces is used by default.

Happy hacking!

Edit:
I found that FormatXMLData loose my utf-8 encoding. So I had to do:


    Encoding := Doc.Encoding;
    Doc.XML.Text := xmlDoc.FormatXMLData(Doc.XML.Text);
    Doc.Active := true;
    Doc.Encoding := Encoding;


sestdiena, 2012. gada 1. septembris

GWT Designer with Eclipse Juno

Eclipse Juno is newest Eclipse version. Today I got it working with GWT and would like to share some discoverings.

  • You need latest GWT version to work with Eclipse Juno. Use this link for install - http://dl.google.com/eclipse/plugin/4.2
  • I used latest SDK 2.5.0 witch is downloadable not by link but in google download page https://developers.google.com/web-toolkit/download
  • When create project do not unchek "Generate project sample code". If you do you get error while creating project - Creation of element failed. Resource ... web.xml already exists
  • GWT GUI on first start gives error "GWT Designer tried to parse .../web.xml file, but can not because it is invalid.". I got away from it with switching project SDK from 2.5.0 rc1 to 2.4.0 and then back.
  • Sadly I could not create layout with authorized panes like this - http://layout.jquery-dev.net/demos/accordion.html