IonicWind Software

IWBasic => General Questions => Topic started by: LarryMc on March 31, 2007, 12:00:20 PM

Title: XML Parser
Post by: LarryMc on March 31, 2007, 12:00:20 PM
Anyone out there have a wrapper and dll for a SAX or DOM based XML parser?

Larry
Title: Re: XML Parser
Post by: Allan on April 03, 2007, 07:35:33 PM
I heard of Expat XML DLL which you could Google for having been used in IBP.
Title: Re: XML Parser
Post by: LarryMc on April 05, 2007, 08:41:42 AM
For those may be interested I have found a DLL for a non-validating XML parser.

It reads an existing xml file into memory, allows read,edit,delete portions of or all of the file then write the file back out.

It also allows you to create a xml from scratch in memory then write it out.

Seems like it will be an excellant way to store program configuration parameters without using the registry.

Anyway, it appears that I have successfully converted the declarations over to EBasic and have actually compiled and run a demo program to create a new xml file.

When I get the details worked out I will be sharing it.

NOTE: This is the first conversion from another lang to EBasic that I have ever accomplished BY MY SELF!!!!! ;D

Title: Re: XML Parser
Post by: Jerry Muelver on April 07, 2007, 11:15:10 AM
Larry, that's super! I can't wait to see what you've come up with.  ;D
Title: Re: XML Parser
Post by: peterpuk on April 07, 2007, 07:55:25 PM
XML is flexible and can be used for a lot of things, so it will be good to see how it can be used with EB.
Good work... :)
Title: Re: XML Parser
Post by: LarryMc on May 10, 2007, 05:09:59 PM
For those that are interested in xml:

I abandoned the use of the dll for xml lib mentioned above.
It took entirely too long to generate a new xml file after changes had been made.

Working on a new version from scratch.
Right now I can read a xml file, parse it, store the info in a linked list; read the linked list and reconstruct the xml file to a new file.
Much faster than before.(by a factor of 10x).  All based on dynamic memory allocation for nodes.

I can also goto first, last, next, prev nested nodes with or without using attributes and attribute values.
Node nesting is limited only by available memory.

Have begun work on methods to add, del, modify nodes.

Larry

Title: Re: XML Parser
Post by: LarryMc on May 21, 2007, 04:18:33 PM
UPDATE:

I've finished my first pass at all the methods for my xml class.
Have started working on examples and documentation (which is always slow).
Below is what the class looks like:
removed list of methods because some changed between this posting and initial release of library


For the few that are interested maybe it won't be much longer.


Larry
Title: Re: XML Parser
Post by: Dogge on May 22, 2007, 12:54:58 AM
Larry, this looks very promising, looking forward to se the real thing in action.
/Douglas

Quote from: Larry McCaughn on May 21, 2007, 04:18:33 PM
UPDATE:

I've finished my first pass at all the methods for my xml class.
Have started working on examples and documentation (which is always slow).
Below is what the class looks like:

......

For the few that are interested maybe it won't be much longer.


Larry
Title: Re: XML Parser
Post by: LarryMc on June 02, 2007, 03:41:36 PM
Done!
The attached zip contains the latest release of my xml library, CXmlLM v2.06.
The zip contains:
   CXmlLM.lib
   CXmlLM.inc
   A Help file with a xml  primer, limitations section, and example code for every public method.
   Example .eba source files.
   Example xml files
   A readme.txt file to tell you what to put where.

Be sure to read the license agreement and the warranty disclaimer before using.

I didn't put this in the OOP section because I didn't want to scare people away.
This library can be used with equal ease in console or GUI applications.
It also can be used in full fledged OOP applications or in what I call "regular ole basic" programs.

My library is not intended to replace MSxml4 for handling xml files.
I swapped ease of use and shortness of learning curve for all that extra functionality.
I feel my library will accomplish what 80%+ of EBasic users would want to do.

I hope it proves useful to someone.
I really did it to see if I could do it.  I hated pointers and you can't go 3 lines in the library's
source without seeing one or more pointers.
I have no idea how I could have written the library without pointers.

Anyway....
Give me some feedback.

Edit: 8/13/07 V2.06
Title: Re: XML Parser
Post by: Jerry Muelver on June 02, 2007, 07:39:25 PM
Thanks, Larry. This may be the tug I needed to get me back into programming.  ;)
Title: Re: XML Parser
Post by: Dogge on June 09, 2007, 04:10:01 PM
Very Impressive, I hope I can put it to good use in a project I'm working on. I'll look forward to study it in more detail.
Many thanks for sharing
/Douglas
Title: Re: XML Parser
Post by: LarryMc on June 09, 2007, 05:48:51 PM
Thanks for the feedback.
Title: Re: XML Parser
Post by: LarryMc on June 21, 2007, 11:00:46 PM
Not that there appears to be any real interest here is an update on what I'm doing to my CXmlLM.lib:

I'm currently working on increasing the max allowable string lengths from 254.
Tag names, atrribute names, and attribute values will be increased to 1024.
Comments and node values will be increased to 100K.

While I'm at it the comments and node values will be allowed to have embedded CRLF.

Also I am adding the "CDATA" type data node which allows nodes to contain embedded <, >,/,CRLF, and maintains all spacing(formating) on output.  This will allow having data which has such things as html coding and proper display of program source code examples.

I'm at the point where I have completely restructured my parser and switched from reading a line at a time from the xml file
to reading the whole file into memory and then parsing it. The last piece of the parser I have to do is the section that takes care of attributes.
Onced finished with that I start working on each of the methods to convert all my double linked lists to support variable length strings instead of fixed length as they are now.

Also have to add new method/s for for handling CDATA.

So... now is the time for the few of you who have given me feedback to put your 2 cents in for what else, in anything, you would like to see.

Larry
Title: Re: XML Parser
Post by: czoran on June 22, 2007, 03:54:32 AM
Dear Larry,

I have tried your parser and I think it is impressive. But still not good enough for my personal use. I am also in the middle of writing mine, and thinking to abandon it and buy commercial one if exist. I am little bit tired from experimenting with all these opensource parsers because what you get at the end is not worth the time invested. Main problem is when you have to parse somehow specific xml, make changes and save it back to another file. Resulting xml is very often different in structure from original and not readable in application which produced it originally.

So, here are some hints for you based on my experience with other parsers:
- take care of multiline comments and those which contain special characters (",? \, /, & ...).
- take care that comments can be all over xml, not only in the begining of file.
- dont' forget to include "DOCTYPE ..." line, even if your parser does not care for DTD.
- whole parsed structure have to be spit back to file, not only things which parser recognize.
- dont split lines or change their order. Especially attributes.
- don't limit number of characters per line. 254 is funny, 1000 is too small... (Sometimes, whole XML is in one line 98000 characters long)
- don't insist that node must follow rule of <node>blabla</node>. Why forbid <node blabla/> ?
- reading whole xml in memory for faster parsing is good only when you have really small xml file. Think about xml files of 660 MB. You need triple amount of memory to process it. Reading it line by line is faster.

I hear following sentence very often from XML parsers authors when complain for some bugs: "Please modify or write your XML files in a way that our parser can process them." How to do that when I have XML file with million lines? I want to modify that large file by using parser and not manually!

Regards,
Zoran
Title: Re: XML Parser
Post by: Mike Stefanik on June 22, 2007, 08:49:44 AM
...reading whole xml in memory for faster parsing is good only when you have really small xml file. Think about xml files of 660 MB. You need triple amount of memory to process it. Reading it line by line is faster.

I don't think you'd need triple the amount of memory, but you would need at least enough memory to store the XML document and the overhead for the node structure. Regardless, what you're asking for is a SAX parser, and it sounds like what he's written is a DOM parser. They both have their use. While SAX will allow you to handle arbitrarily large documents, it is an event-driven sequential single-pass parser. As soon as you have the requirement that you need to access the XML document elements more than one time or out of sequence, then you're going to need a DOM parser which loads the entire document into memory.

And in practical terms, you're going to find very few "real world" XML documents out there that are >500Mb in size. But for those that are, a SAX parser is the way to go.

Oh, Larry, as far as the issue of line length is concerned, if you can avoid any artificial limitations there you'll find fewer issues with documents. As czoran has noted, it's not uncommon for the entire XML document to be one or two lines long.
Title: Re: XML Parser
Post by: LarryMc on June 22, 2007, 08:56:37 AM

Quote- take care of multiline comments and those which contain special characters (",? \, /, & ...).
Already taken care of.

Quote- take care that comments can be all over xml, not only in the begining of file.
True in my original version

Quote- dont' forget to include "DOCTYPE ..." line, even if your parser does not care for DTD.
Already taken care of.

Quote- whole parsed structure have to be spit back to file, not only things which parser recognize.
Will be closer to be true in new version.

Quote- dont split lines or change their order. Especially attributes.
True in my original version

Quote- don't limit number of characters per line. 254 is funny, 1000 is too small... (Sometimes, whole XML is in one line 98000 characters long)
Read my previous post where I said I was changing that?

Quote- don't insist that node must follow rule of <node>blabla</node>. Why forbid <node blabla/> ?
Will be added.

Quote- reading whole xml in memory for faster parsing is good only when you have really small xml file. Think about xml files of 660 MB. You need triple amount of memory to process it. Reading it line by line is faster.
You say read the file line by line and it may be 660MB long. Above you say a whole xml file may be one line. 
I'm afraid I'm not smart enough to know how to input a one line file of 660MB into a variable for processing without loading the file into memory.

When it comes down to it I still stick to my statement I made when I posted my lib.
QuoteMy library is not intended to replace MSxml4 for handling xml files.
I swapped ease of use and shortness of learning curve for all that extra functionality.
I feel my library will accomplish what 80%+ of EBasic users would want to do.
I'm sorry that what you apparently want to do falls in the 20% that I'm not addressing.


Title: Re: XML Parser
Post by: LarryMc on June 22, 2007, 09:23:16 AM
Mike

QuoteAs czoran has noted, it's not uncommon for the entire XML document to be one or two lines long.
That is why I switched my parser from being line based input to reading the whole file into memory.

In general my new limitations will be:
what can be put between "<" and ">" will be 100K
a tagname can be 1K
an attr name can be 1K
an attr value can be 1K
Since a tagename and multiple attr name/value pairs can be in one set of brackets their sum cannot exceed the 100K limit.

Also, if my lib is used to read a xml file that basically has no CRLF; the file modified; and then saved.
My lib inserts the nesting indents and the appropriate CRLFs.
I guess it would be easy enough to pass a param to the save routine  to disable that formatting on output for people who want to pack the file like that.

Since I am an amatuer programming hack (with limited skills) I never intended to write a "commercial" library.
I apologize to those who wasted their time downloading my lib thinking they were getting something of that calibre.

Larry

Title: Re: XML Parser
Post by: Dogge on June 22, 2007, 10:06:40 AM
Quote from: Larry McCaughn on June 21, 2007, 11:00:46 PM
Not that there appears to be any real interest .....
Hi Larry,
unfortunately my project hasn't come to the point where I need to create XML-files but it will very soon. My intent is to use your XML lib is to create XML files for storing a special kind of logs that should be parsed by external programs, hence XML is a good format to use.
I will come with feedback as soon as I start.
Keep up the good work!
/Douglas


Title: Re: XML Parser
Post by: Steven Picard on June 22, 2007, 10:42:51 AM
Sorry, Larry,  I haven't been looking through the forum very thoroughly lately due to a busy schedule.  I am actually interested in this library and I see what you are doing.  I agree that there are many times when just a light XML parser is needed (which would be my needs most the time.)

Thanks for sharing!
Title: Re: XML Parser
Post by: LarryMc on June 22, 2007, 11:22:55 AM
thanks for the feedback :)
Title: Re: XML Parser
Post by: czoran on June 22, 2007, 01:28:36 PM
Dear Larry,

Please don't take it too strong. My intention was to point your attention to some weird things found in real world.
Many "commercial" libraries (not only for XML) fail when not taking in consideration line and file size,content, memory, speed, etc. So it is better to work on that right in the beginning. Otherwise, complete rethinking and rewriting is necessary. I wrote that your lib did not fill my needs, and that's all. And I know that I have some special needs too.
Sure that your lib is very useful for most needs of regular users and I wish to encourage you to continue working on it.

Regards.
Title: Re: XML Parser
Post by: LarryMc on June 22, 2007, 01:36:38 PM
czoran

thank you for ALL your comments

Larry
Title: Re: XML Parser
Post by: Dogge on June 24, 2007, 05:12:24 PM
Hi Larry, I did my first implementation with your XML lib, I must say that I am impressed, it works very well when I got the pieces together.
At this point it does what I need, and I haven't used it to its full capability yet.

Question removed after further testing

I will explore further

Thanks
/Douglas
Title: Re: XML Parser
Post by: tekrat on June 25, 2007, 02:48:38 PM
Has anyone gotten Mircosoft's XML DOM to work through COM?  I use it on a daily bases in VBS and it works fine for what I need.

FYI: If you have I would love to see your code so I could use in an Emergence BASIC project.
Title: Re: XML Parser
Post by: LarryMc on July 02, 2007, 08:36:13 PM

I have posted the new release of my xml library (CXmlLM V2.0) at http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670 (http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670)

Much more flexible than before and now has CDATA capabilities.

Appreciate any and all feedback.
Title: Re: XML Parser - how should this be accomplished
Post by: Dogge on July 11, 2007, 06:55:42 AM
Hi Larry,

I'm trying to use your CXmlLM functions for storing settings for my programs. My goal is to be able to modify settings with any texteditor or an XML editor like XML Marker and the reload the file in my program.
I can load the settings once but subsequent loads fail, with either "Current Node has no children" or a program termination, depending on if I comment out the FreeNodeMem call or not.

Here is my code

$use "CXmlLM.lib"
$include "windows.inc"
$include "CXmlLM.inc"

CONST BUTTON_1 = 1
CONST BUTTON_2 = 2
CONST LISTBOX_3 = 3
DIALOG d1

def MyParams as CXmlLM
string MyParamsFileName : MyParamsFileName=GetStartPath+"MyParams.xml"
int Delay1: Delay1=5000
int Delay2: Delay2=2000
int Delay3: Delay3=4000

CREATEDIALOG d1,0,0,270,202,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@SYSBUTTON,"Load the XML file",15,20,235,26,0x50000000,BUTTON_1
CONTROL d1,@SYSBUTTON,"Edit XML file with external editor",15,140,235,26,0x50000000,BUTTON_2
CONTROL d1,@LISTBOX,"ListBox1",15,50,235,85,0x50800140,LISTBOX_3

domodal d1

end

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
LoadMyParams()
ENDIF
CASE BUTTON_2
IF @NOTIFYCODE = 0
system "notepad.exe", getstartpath+"MyParams.xml"
ENDIF
CASE LISTBOX_3
/* respond to control notifications here */
ENDSELECT
ENDSELECT
RETURN
ENDSUB

sub LoadMyParams()
string _param
while (getstringcount(d1,LISTBOX_3)>0) : deletestring d1, LISTBOX_3, 0 : endwhile
if MyParams.FileLoad(MyParamsFileName)
MyParams.ErrMsg()
else
if MyParams.FindRoot()
MyParams.ErrMsg()
else
if MyParams.FindFirstChild("Delay1")=0
MyParams.GetDat(_param, Delay1) : Delay1=val(_param)
MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay1"+str$(Delay1)
else
MyParams.ErrMsg()
endif
if MyParams.FindFirstChild("Delay2")=0
MyParams.GetDat(_param, Delay2) : Delay2=val(_param)
MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay2"+str$(Delay2)
else
MyParams.ErrMsg()
endif
if MyParams.FindFirstChild("Delay3")=0
MyParams.GetDat(_param, Delay3) : Delay3=val(_param)
MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay3"+str$(Delay3)
else
MyParams.ErrMsg()
endif
endif
MyParams.FreeNodeMem()
endif

endsub


and my test data

<?xml version="1.0"?>
<XMLtest>
        <Delay1>5055</Delay1>
        <Delay2>2002</Delay2>
        <Delay3>4004</Delay3>
</XMLtest>

I appreciate your efforts with the library which I have found to be very useful for generating log-files in my program.

Should I be able to use the library the way I'm doing with loading and reloading the data?

Thanks
/Douglas
Title: Re: XML Parser
Post by: LarryMc on July 11, 2007, 08:03:53 AM
Douglas,
You're having the same problem I'm having with an application I'm working on.
The thing that are in common between our 2 programs are that we're both declaring our CXmlLM typr variable at a global level then calling the methods inside a dialog.

I've sent Paul a copy of my xml library source code to see if he can figure out why it is acting weird with the dialog.

In the mean time I'm going to try a couple of other ideas to see if there is a way to get it to work.

Sorry for the problem.  If you can, work on another part of your program while I try to figure out what's going on.

Don't give up on me yet.

Larry
Title: Re: XML Parser
Post by: LarryMc on July 11, 2007, 08:36:22 AM
Douglas,
This works.
I don't know if this is "THE" fix or just a work around.  I'll have to wait till I hear something from Paul.

Instead of MyParams being global it is now local to the subroutine; it is created dynamically and when the subroutine returns the system takes care of closing the instance of CXmlLM.

$use "CXmlLM.lib"
$include "windows.inc"
$include "CXmlLM.inc"

CONST BUTTON_1 = 1
CONST BUTTON_2 = 2
CONST LISTBOX_3 = 3
DIALOG d1

'def MyParams as CXmlLM
string MyParamsFileName : MyParamsFileName=GetStartPath+"MyParams.xml"
int Delay1: Delay1=5000
int Delay2: Delay2=2000
int Delay3: Delay3=4000

CREATEDIALOG d1,0,0,270,202,0x80C80080,0,"Caption",&d1_handler
CONTROL d1,@SYSBUTTON,"Load the XML file",15,20,235,26,0x50000000,BUTTON_1
CONTROL d1,@SYSBUTTON,"Edit XML file with external editor",15,140,235,26,0x50000000,BUTTON_2
CONTROL d1,@LISTBOX,"ListBox1",15,50,235,85,0x50800140,LISTBOX_3

domodal d1

end

SUB d1_handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDCONTROL
SELECT @CONTROLID
CASE BUTTON_1
IF @NOTIFYCODE = 0
LoadMyParams()
ENDIF
CASE BUTTON_2
IF @NOTIFYCODE = 0
system "notepad.exe", getstartpath+"MyParams.xml"
ENDIF
CASE LISTBOX_3
/* respond to control notifications here */
ENDSELECT
ENDSELECT
RETURN
ENDSUB

sub LoadMyParams()
POINTER MyParams
SETTYPE MyParams,CXmlLM
MyParams = NEW(CXmlLM,1)
string _param
while (getstringcount(d1,LISTBOX_3)>0) : deletestring d1, LISTBOX_3, 0 : endwhile
if #MyParams.FileLoad(MyParamsFileName)
#MyParams.ErrMsg()
else
if #MyParams.FindRoot()
#MyParams.ErrMsg()
else
if #MyParams.FindFirstChild("Delay1")=0
#MyParams.GetDat(_param, Delay1) : Delay1=val(_param)
#MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay1"+str$(Delay1)
else
#MyParams.ErrMsg()
endif
if #MyParams.FindFirstChild("Delay2")=0
#MyParams.GetDat(_param, Delay2) : Delay2=val(_param)
#MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay2"+str$(Delay2)
else
#MyParams.ErrMsg()
endif
if #MyParams.FindFirstChild("Delay3")=0
#MyParams.GetDat(_param, Delay3) : Delay3=val(_param)
#MyParams.FindParent()
addstring d1, LISTBOX_3, "Delay3"+str$(Delay3)
else
#MyParams.ErrMsg()
endif
endif
'

endif
#MyParams.FreeNodeMem()
endsub
Title: Re: XML Parser
Post by: Dogge on July 11, 2007, 12:32:09 PM
Hi Larry,

thanks for the workaround, it is perfectly useful for loading and reloading settings, however when I use it for logging purposes I need it to be global as I add to the log from several different routines in the program. In the logging case I never load a file from disk, I just do a FileSave and a FileNew when one log should be closed and another opened, and this works fine. I had to comment out the FreeNodeMem after the FileSave, otherwise the FileNew terminated the program.

I wont give up, I like the functionality and I think it is easy to work with.

/Douglas

Title: Re: XML Parser
Post by: LarryMc on July 11, 2007, 07:32:47 PM
Found flaw that was causing problem for Douglas and myself.

Posted revised CXmlLB class library with help file and examples at
http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670

[Douglas]
Your original program as you posted here works just fine now.

Larry
Title: Re: XML Parser
Post by: Dogge on July 12, 2007, 07:09:48 AM
Great, I tried it and it worked  ;D ;D with one exception :o. When I kept the FreeNodeMem call the program dumped on me when I closed the window.
I was thinking that maybe its not necessary to have it in the code, but it would be good to know if I should have that call there or should it not be there?

/Douglas


Title: Re: XML Parser
Post by: LarryMc on July 12, 2007, 08:20:01 AM
I've been running some test to see if there are memory leaks by leaving the FreeNodeMem out.

so far I haven't seen any.

So like the DR. says "If it hurts when you do that, then don't do that" ;)

I'll keep you posted if I find anything new.
Title: Re: XML Parser
Post by: Dogge on July 12, 2007, 09:41:08 AM
I'll leave it out for now, as it don't seem to cause any problems. Can you reproduce the error I have with the code I posted?
/Douglas
Title: Re: XML Parser
Post by: LarryMc on July 12, 2007, 10:10:59 AM
Not with your code but I'm pursuing issues with my application which can also have an impact on yours.
I'll let you know ASAP.

Larry
Title: Re: XML Parser
Post by: LarryMc on July 13, 2007, 04:34:22 AM
Fixed bugs that caused crashes.
Update version at:
http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670

[Douglas]
Put the FreeNodeMem() calls back in your program like the examples show.
Failure to do so will cause memory leaks.

Larry
Title: Re: XML Parser
Post by: Dogge on July 13, 2007, 09:30:49 AM
Great job Larry ;D
downloaded, tested and it works as expected.

I'm very pleased with the functionality, and I'll let you know if I find any problem or have some ideas for new and added functionality.

Thanks again!

/Douglas


Title: Re: XML Parser
Post by: LarryMc on July 13, 2007, 11:04:03 AM
Quote from: Dogge on July 13, 2007, 09:30:49 AM
and I'll let you know if I find any problem
As an ex-teacher turned chemical engineer once said at one of our Engineering Department meetings with Plant Operations,

"How do you expect me to ever finish my project if you keep finding things wrong."

:o :D
Title: Re: XML Parser
Post by: Dogge on July 13, 2007, 12:32:00 PM
Quote from: Larry McCaughn on July 13, 2007, 11:04:03 AM
"How do you expect me to ever finish my project if you keep finding things wrong."
:o :D
lol, the last bug will never ::) be found.
Title: Re: XML Parser
Post by: Dogge on July 18, 2007, 09:38:30 AM
Hi Larry,
I ran into some more problems. I'm attaching 4 different programs to describe the problem. The background for my issues is that I wanted to use your lib to create log-files and in one program I need to load the logfile and continue adding to it. These programs (in zip file) illustrate my problem:
XMLtest2.eba; works
XMLtest3.eba; same as "2" except line 50 where I added a numeric character to the tag name, get the error "Node Name contains illegal characters"
XMLtest4.eba; dumps, the difference here is that I'm adding my new node directly as a child node to the root node, whereas in "2" and "3" I did a find child node and added the node as a peernode
XMLtest5.eba; same as "4" but with an additional numeric character in the tag name and I get the same error as in test "2".

XML file for test is the same as previous

I'll appreciate if you could check if I'm doing something wrong or if I found some more bugs.

Thanks
/Douglas
Title: Re: XML Parser
Post by: REDEBOLT on July 18, 2007, 10:20:08 AM
Quote from: Dogge on July 13, 2007, 12:32:00 PM
Quote from: Larry McCaughn on July 13, 2007, 11:04:03 AM
"How do you expect me to ever finish my project if you keep finding things wrong."
:o :D
lol, the last bug will never ::) be found.

Each bug found increases the probability that one more bug will be found.
Title: Re: XML Parser
Post by: Rock Ridge Farm (Larry) on July 18, 2007, 10:22:43 AM
There not bugs - They are undocumented features. :)
Title: Re: XML Parser
Post by: LarryMc on July 18, 2007, 12:08:23 PM
Don't BUG me!

Today's my birthday!

Douglas,

I've got to take some limbs to the dump.
In a couple of hours I will look into your "discoveries"

Larry
Title: Re: XML Parser
Post by: Dogge on July 18, 2007, 12:33:31 PM
Congratulations!  ;D

No need to spend your birthday looking at my code, I have plenty of other things to work on.

/Douglas
Title: Re: XML Parser
Post by: LarryMc on July 18, 2007, 08:22:27 PM
New ver of CXmlLM posted at http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670 (http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670)

Douglas
Fixed your problems:
   Crash when adding Child off root node (due to structure change in last update)
   error when adding 0-9 to a tag name(due to operator precedence error)

Let me know if you find any more "undocumented training aids". ;)

Larry
Title: Re: XML Parser
Post by: LarryMc on July 19, 2007, 11:08:45 AM
Seems I took 2 problems out and put a new one in. ::)

A newer version will be forthcoming.

Larry
Title: Re: XML Parser
Post by: LarryMc on July 19, 2007, 12:04:27 PM
CXmlLM V2.04 posted at http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670 (http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670)

Fixed problem in FileNew method that would cause crash when trying to add childnodes.
(Root node end-tag creation had not been changed to support other revisions made in V2.03)

Larry
Title: Re: XML Parser
Post by: Dogge on July 19, 2007, 12:46:15 PM
Great work, thanks, I'll try it as soon as I can and let you know if I find anything else.
/Douglas
Title: Re: XML Parser
Post by: Dogge on July 25, 2007, 02:19:28 AM
Hi, it's me again  :)

When I tested my first program where I used CXmlLM with the new 2.04 version it dumped on me  :(.
I backed down  to 1.0 where it works.
Tested 2.0 - 2.03, none works, 2.04 lets me run my program a bit longer but then it dies with a memory error.
I have traced the problem to an AddChildNode call, same type of call is used earlier in the program with the same type of arguments.
As the same call works earlier in the program I haven't done a test program to reproduce the error.

I'm sorry to bug you and I'll appreciate if you could take a look at the problem when you have time, I'll stick to 1.0 for now.

/Douglas

Title: Re: XML Parser
Post by: LarryMc on July 25, 2007, 04:09:45 AM
Douglas

For me to see what's wrong I need to see your code.

My problem is that all my examples work fine; all YOUR examples with "myparams.xml" work fine.

I can't fix it unless I can see it broke.

Now, the a big difference between version 1 and the later versions is that ver 1 was limited to string values.

The newer versions use istring$ so it will handle string$ up to 100k on data.

You having to go back to version 1 at this time tells me there is something wrong with a string somewhere.

But like I said I don't know how to fix it unless I see it.

Sorry,

Larry
Title: Re: XML Parser
Post by: Dogge on July 25, 2007, 04:19:58 AM
I understand that you need to see the code, I have been working with software support and it's a nightmare with trying to chase bugs without seeing what people do. The code is part of a larger back-end package and I'll see what I can put together for you as a test case. It will take me a while so I'll stick with version 1 for the next couple of days.

/Douglas

Title: Re: XML Parser
Post by: LarryMc on July 25, 2007, 04:24:09 AM
I'll be glad to look at it whenever you can get me something.

Larry
Title: Re: XML Parser
Post by: LarryMc on July 25, 2007, 07:21:15 PM
CMxlLM V2.05 posted at http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670 (http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670)

Fixes Douglas' latest problem(I hope ;)).

Problem with AddChildNode after having previously worked correctly.

Larry

Title: Re: XML Parser
Post by: Dogge on July 26, 2007, 02:51:23 AM
Downloaded and tested, it works  ;D  ;D  ;D

Thanks for your help!!!

I'll let you know if i stumble upon something more

Thanks
/Douglas
Title: Re: XML Parser
Post by: LarryMc on August 13, 2007, 04:19:19 AM

CXmlLM V2.06 posted at
http://www.ionicwind.com/forums/index.php/topic,1603.msg15670.html#msg15670

Maint Release - fixed erratic problem when calling FileLoad and then immediately calling FileSave.

Larry

Title: Re: XML Parser
Post by: LarryMc on August 13, 2007, 09:12:04 AM
Just discovered a problem associated with CData (data that perserves formatting via my WYSIWYG editor in an application I'm working on).

Haven't located the exact cause yet but it only happens when things are done in a specific order.

Until I I get the problem resolved I would suggest not using the CData option.

Also, I'm uploading a revised version of 2.06. (I put an old problem back in it...duhh!)

Edit:
If you downloaded ver 2.06 before August 13, 2007, 10:14:09 AM Central Time then you need to download it again.
Title: Re: XML Parser
Post by: dalescott on February 22, 2009, 12:23:58 PM
First, thanks Larry for the CXmlLM library. I'm a newbie, both with Emergence BASIC and with XML, so your library is a gift!

1. regarding the library limitations, are the limitations imposed purely by your library, or are any essentially imposed by the XML or higher-level standards? (e.g. tab and attribute names are case sensitive, acceptable characters for tag and attribute names, use of single and double-quotes, etc.). Without even knowing how much I don't know about HTML, SGML, XLS, DOM, GXL (the XML file format I'm specifically interested in for transfer of GPS-type data), etc., a sentence or two about the big picture would be great.

2. regarding the CXmlLM help file, I'd rather see the help viewer window title changed from "Online Help" to "CXmlLM Users Guide". It would me see more quickly which help window I'm looking at when I have multiple help files open (I'm a newbie!).

3. regarding use of the help file, I highlighted FileLoad from a source file in the Emergence Editor (e.g. "FileLoad" from the zz.FileLoad command in xmlExample_1.eba) and pressed F1. The CXmlLM help file is opened but seems to hang up. After some seconds, a dialog appears saying "There is not enough memory available for this task. Quick one or more programs to increase avaialble memory and then try again." Clicking OK kills both the help window and the Emergence BASIC IDE. Could this be caused by an indexing problem in the help file?

4. regarding the license, would you consider releasing the source under an appropriate license? As a newbie, I would very much appreciate being able to study and learn from the source. The LGPL v2.1+  would seem to fit the intent expressed in the Help file license statement - including being able to take a future version of CXmlLM proprietary again.

5. I read a GPX-format XML file into CXmlLM and wrote it back out for comparison. The Windows command utility "fc" says they're not the same and WinDiff loses sync after the first line. However, the two files (the input and output files) look the same in a text editor (exactly the same, which I also don't completely understand - I expected to see at least some header differences).  I don't even see any differences in the first 16 bytes in a hex editor. Any idea what's going on?

Thanks again for contributing the library, and I'm sure I'll have more questions later (I haven't actually parsed any data from my GPX file yet).
Dale

P.S. FYI, I'm using MS Vista (UAC disabled) on an HP laptop with an AMD Turion X2 and 4G memory.
Title: Re: XML Parser
Post by: LarryMc on February 22, 2009, 01:16:25 PM
1. imposed strictly by my stripped down version; for the most part
   From the forum posting:
QuoteMy library is not intended to replace MSxml4 for handling xml files.
I swapped ease of use and shortness of learning curve for all that extra functionality.
I feel my library will accomplish what 80%+ of EBasic users would want to do.

2. I'll make a note about the window title if I ever go back and update the library

3. I didn't build in any keyword searching of a source file for my library.  Don't even know if I know how to do that.

4. No.  You'd be better served, in my opinion, to study the regular version of XML if you're wanting to learn xml.
  Besides, I personally don't like the LGPL as it has to do with source code.  It opens up the whole bucket of worms for policing what are derivative works.  I don't want to deal with it at all.

5. There is no warranty whatsoever that my library will read properly any xml file NOT created with my library.  So the same goes for it reading in an alien XML file and spitting the contents back out verbatium.  That's why I posted the big red warning at the bottom of the limitations page in the help file.  On the other hand I think other parsers should have little or no trouble reading xml files created with my library.  But if other parsers modify one of the xml files created with my lib then the xml becomes alien to my lib and may not be read properly by my lib.
Note, looking at two different xml files in a "text" edit is not the way to "see" if they are identical.  Hidden escape sequences don't show up.

The question really is whether or not the alien xml was "clean" enough for my lib to capture the salient information properly.
The 'apparently' identical files read with a text editor might be telling you it did.
Even if it did capture the info properly; the file you generated from the data with my lib won't neccessarily be able to be read by the program that created the original GPS file.

Hope that helps

Larry

Remember, my library is a Ford model T.
It provides adequate transportation for the majority of users at a resonable price.
If you want the Maserati in order to have the best of everything then pay the price for that; it's available out there. ;)
Title: Re: XML Parser
Post by: dalescott on February 22, 2009, 08:39:22 PM
Thanks Larry for the feedback. I'm going to spend more time with your library. Hopefully it will work for my basic 80/20 needs. If it gets crazy, I might try reading the GPX schema and compare it against the listed CXmlLM limitations. At least I'll know more about what's going on before looking further (should I have to).

Dale