PDA

View Full Version : ECXML For Lazarus Alpha 1 released



jdarling
20-07-2006, 07:57 PM
In working on Project Phoenix I've been porting alot of my components and source to FPC/Lazarus. I've finally completed the re-build (porting wasn't an option) of my XML components to Lazarus. Well, not completed, but I have them ready for others to look at.

Planned enhancements:
Documentation
More Demos (duplicates of existing and more)

Known Issues:
You can't drop a TXMLSAXParser onto a from in the IDE, for some reason it crashes. If anyone knows why please let me know.
I can't figure out how to assign images to the components on the palette, again if anyone knows please detail it out for me.

A few things about the components:
They are now based upon a SAX scanning like system. This means that malformed XML will now result in a Warning or Error that can be marked as handled and will be ignored. Also non-closed elements can be automatically closed (WAHOO). Finally there is now a SAX like parser available that is event driven.

Of course this is done in complete Pascal source, so it should compile for all versions of Lazarus and be useable w/o changes. No 3rd party libraries are used, and the code is much cleaner then its Delphi predicessor, in fact I plan on making a Delphi package out of it as well.

Download from: http://www.eonclash.com/ECXML_Parser/lazarus_XML.zip

Legolas
20-07-2006, 11:00 PM
About component icon, it needs some work:

0. Make your icon in xpm format (gimp handles it very nicely)
1. Go to lazarus/tools and build lazres.lpi
3. Use lazres.exe in this way:


lazres your_res.lrs TYourCompName.xpm

4. Add your_res.lrs to your package
5. Add this code to your unit file:

Unit YourUnit;

{$mode objfpc}{$H+}

Interface

Uses
..., LResources; //Add LResources if not present

// Very very big snip

procedure Register;
begin
RegisterComponents('Additional',[TYourCompName]);
end;

initialization
{$i your_res.lrs}

end.


Build all and you icon *should* be right in place 8)

jdarling
20-07-2006, 11:04 PM
Ahh... I kept reading about XMP files, but had no idea what they were. I thought it was some type of compiled resource :). I'll have to download Gimp and give this a try. I'm guessing that since I have two components I would make two lrs files and include them, or can I tell lazres to put both resources in the same file?

WILL
20-07-2006, 11:14 PM
0. Make your icon in xpm format (gimp handles it very nicely)

Slightly Off Topic:

I've found one big problem with GIMP on WinXP (or Just Win32 in general?) though... it sucks. :?

I'm quite confident that the Linux port will run great, just not the Win32 one. I get crashes all the time whenever I try to resize or create a new image in it. And I've been using the latest version. :roll:

Does anyone else have these same issues? Esp. on an XP machine?


Back to the components:

Hey, I think it's cool that you are supporting the LCL now. I think the biggest thing to kill Kylix was that developers in general did not support the CLX (Much, much better than VCL anyway)...

How much of your original code is remaining 'as is'?

Legolas
20-07-2006, 11:44 PM
Ahh... I kept reading about XMP files, but had no idea what they were. I thought it was some type of compiled resource :). I'll have to download Gimp and give this a try. I'm guessing that since I have two components I would make two lrs files and include them, or can I tell lazres to put both resources in the same file?

Of course you can add two or more files in a single lazarus resource file:

lazres your_res.lrs TFirstComp.xpm TSecondComp.xpm ...
BTW, here (http://www.geocities.com/SiliconValley/Vista/2471/delphi.html) you can find a bmp->xpm converter, written in delphi and with sources :)


WILL: I use Gimp on WinXP and it works fine. Maybe your version is non-stable?

jdarling
21-07-2006, 01:09 PM
Hey, I think it's cool that you are supporting the LCL now. I think the biggest thing to kill Kylix was that developers in general did not support the CLX (Much, much better than VCL anyway)...
How much of your original code is remaining 'as is'?

Well, very little of the code that you see in the current package matches up with the code in the "current" Delphi packages. This is because I've been working on a complete re-write for Delphi over the past year. A new parser (SAXish) was developed, a new model around Interfaces, and a very selectable model was choosen. All of this leads to two things, first the components are a bit more difficult to work with (you have to type cast things) and second they are MUCH more powerful.

I'll give a quick example:
Before the following would not have loaded properly:

<Root>
<Level1>
Level 1 start text
<SpecialTag/>
More level 1 text
</Level1>
</Root>
Before this would have resulted in you getting a level1 tag with "Level 1 start text More level 1 text" and a special tag is a child of it. This wasn't a major problem, but it was a problem.

Now you will have 3 children under Level 1, a Text element, a Container with no children, and then another text element. This is proper to the XML specification.

The massive number of e-mails asking me for FPC support is quite amazing, and work with Phoenix (as I stated) along with a few other things made me want to convert the new model to FPC/Lazarus.

I haven't used the interface model in this conversion, simple reason, I don't know if interfaces work in all FPC compilers (or if they are supported at all). So I went with what I know will work, overloaded objects.

Another change is that I've surfaced the TXMLTokenizer (again SAXish) into a visual component (this is the one with problems, no idea why it has problems, but on some systems it crashes the IDE). This was due to the fact that ALOT of people have hacked out the old Tokenizer to use it. I figured if they wanted that level of access I'd give it up.

So long answer short; Yes its based on the Delphi code, just not the Delphi code that everyone can see. The Delphi version should be following up in a few months after testing is completed. Seeing as how I need some help finding (and fixing) the bugs in the FPC version I went ahead and released it to PGD (notice it isn't on the website yet) for review and testing (and hopefully a little help).

jdarling
21-07-2006, 05:08 PM
Thanks everyone for the tips. All issues have been resolved (Icons on the palette work great). The problem with the TXMLSAXParser ended up being a dumb mistake on my behalf. Its been fixed now, and the package is released as v1. Many updates to come, with new demos and other, but still let me know what you think.