Re: [xslt] New dumb user request/questions



On Tue, Aug 06, 2002 at 03:34:01PM +0200, Bill Eldridge wrote:
> 
> After messing around with the Python bindings
> for libxslt/libxml2, it was hard to figure out
> how to get the results of a transform to a string,
> and nothing in the mailing list archives was
> any help. I finally figured it out from the
> extension example that
> I can do:
> 
> result=style.applyStylesheet(doc, None)
> root=result.children
> print root.getContent()

  Actually, there is a serialize() method associated to any DOM
node taking care of this in a better way. Look at the serialize.py
test case in libxml/python/tests directory, the API is quite better
since it allows to indent or save to a given encoding.

> (or
> 
>     print result.children.getContent()
> 
> if I want to be more obscure).
> 
> Anyway, it seems that this should be
> more obvious in the documentation for new users?

  Right, the serialize() extension was provided after I wrote
    http://xmlsoft.org/python.html

> Also, would a saveResultToStringIO
> make sense (allowing either StringIO or cStringIO
> objects)?

  Well, that's yet another part needing fixups at the bindings level,
first saveResultToXXX is better than calling serialize() on the document
resulting from the transformation since some of the attributes of the
transformations cannot be stored in the DOM tree (like indentation request).
Also the libxml2/libxslt I/O level doesn't work well with python I/Os at
the moment, a bit of glue with a python class providing direct access to the
Python I/O routines would help, but I hadn't time yet to do this.

> Lastly, is there some relation between
> Dave Kuhlman's libxsltmod and the one
> included with libxslt? (Doesn't seem to
> be).

  Dave's feedback and experience was integrated when developping the
"official" bindings, and I certainly had a look at his code especially
for the SAX mapping interfaces :-)

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]