Re: [xslt] [BUG] Win32, xsltproc, libxml, libxslt, <xsl:include/>



On Mon, May 13, 2002 at 07:29:57PM +0200, Igor Zlatkovic wrote:
> > > I have one question: Is xsltParseStylesheetProcess() planned to be able
> to
> > > return a valid stylesheet pointer different to NULL and thus
> invalidating
> > > the one it received as a parameter? The current code does not do this,
> but
> > > the comments and the type of the return value suggest that this at least
> was
> > > the intention.
> >
> >   yes sounds fine. This function is mostly internal so doing this should
> > not break code,
> 
> Eh? :-) My point was missed, I'll try again:
> 
> I wondered if you have planned reallocating the stylesheet within this
> function anytime in the future. I mean, the function returns a pointer to a
> stylesheet and the comment at the top states that it could return a
> stylesheet different to the one passed to it. The code, however, does not
> produce a new stylesheet anywhere, it just modifies the original. Which is
> now to follow? The code, or the comment?

  "yes sounds fine" was applying to this, yes you can return a different
pointer (assuming you make sure the places where it's called internally
check that the returned value is used from that point which IIRc your initial
patch took care of, right ?).

> If xsltParseStylesheetProcess() is allowed to reallocate the stylesheet and
> invalidate its parameter, then all functions which call it (except the one
> which allocates the stylesheet) must also return the pointer to a
> stylesheet, not an int. Not passing the return value of this function all
> the way up would be fatal.

  yes agreed,

> Well, if the stylesheet were an array, then things would be different. It
> being a structure, I am puzzled why would someone move it to another address
> at any processing level.

  and the structures actually describes a tree (for the inclusions).

> So, my proposal is:
>  * Lets hold that xsltParseStylesheetProcess() cannot make a new stylesheet,
> it can only modify the contents of the one which was passed to it as a
> parameter. If it succeeds, it returns the pointer to the same stylesheet it
> received after modifying its contents. If it fails, it returns NULL. The

   okay, that's another way of doing it, fine by me, your pick.

> function does not free the stylesheet in any case. If the function allocates
> memory and stores the addresses in various members of the stylesheet, that
> memory remains there. It will be freed by the next call to
> xsltFreeStylesheet(), which is the responsibility of the party who called
> xsltNewStylesheet().
>  * We modify the top-level call which allocated the stylesheet (that is
> xsltParseStylesheetDoc()) to free that stylesheet incase there was an error.
>  * We modify all functions which call xsltParseStylesheetProcess() and
> return void to return an int indicating success or failure.
>  * We modify all calls to any of these to actually check this return value.
> 
> What do you think?

   that it's a fine way to proceed too, feel free to apply this :-)

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]