From: Mark W. <mew...@un...> - 2000-05-26 15:42:01
|
Graham Barr wrote: > OK, I have been thinking about this some more. > > On Fri, May 26, 2000 at 08:58:20AM -0500, Mark Wilcox wrote: > > > I have not tried the code, but from looking at it I have one concern. > > > It seems that the whole DSML file must be read into memory in one go. > > > > I'll have to double-check this. I can't remember if XML::Parser's callback functions use > > streaming or load the whole file. > > It's not that XML::Parser reads the whole file at one. It is that you read all > the entries from teh XML file into @results. So you are loading them all into > memory. Yeah, I took the quick and dirty route ;). > > > I have been considering if we really need an API like LDIF where the user does > read_entry() to get the next in the file. > > From my reading of XML::Parser there is no way to do this. When you tell > it to parse it parses the whole file. > > So I was thinking that maybe XML::DSML should just use callbacks itself. > > For example have the user pass a sub reference which will be called > whenever an entry is read. > > This can be extended when we start to read the schema, and we can have a different > sub to call. Or we can just have the user check the type of object passed. > > I don't think this would be too much of a setback as I would think that most of > the time the current LDIF is used in a loop anyway. > > So what we could end up with is something like > > $dsml = Net::LDAP::DSML->new(); > > $dsml->process( $file, entry => \&process_entry, schema => \&process_schema ) > or die $dsml->error; > Ok. I see. I'll start to work on it. > > Now for writing we could do > > $dsml->open($file,"w"); > $dsml->write($entry); > $dsml->write($schema); > $dsml->close; Like this. > > The open would write the header and the close would write the footer. > > Thoughts ? This is probably much better than what I had originally. I'll see what I get turned up. Mark > > > Graham. |