[libxml-devel] Announcing libxslt-ruby 0.7.0
Charlie Savage
cfis at savagexi.com
Thu Jul 10 19:10:48 EDT 2008
Hi everyone,
I've pushed out a libxslt 0.7.0 release to match yesterday's libxml
0.7.0 release.
Changes:
* Ability to reuse the same stylesheet multile times
* Simpler api
* Compatibility layer for pre-0.7.0 versions
* Major rewrite, resulting in significantly less code
* Updated RDocs.
To see the difference, here is the new API:
stylesheet_doc = XML::Document.file('stylesheet_file')
stylesheet = XSLT::Stylesheet.new(stylesheet_doc)
xml_doc = XML::Document.file('xml_file')
result_doc = stylesheet.apply(xml_doc)
And here is the old way:
xsl_file = File.expand_path('files/fuzface.xsl')
xslt = XML::XSLT.file(xsl_file)
xml_file = File.expand_path('files/fuzface.xml')
xslt.doc = XML::Document.file(xml_file)
stylesheet = xslt.parse
result_string = stylesheet.apply(xml_doc)
The old API had a number of issues:
* The XSLT namespace was nested in XML - that seems like a bad idea now
that libxslt is its own gem
* Stylesheets could only be opened from files
* A stylesheet could only be used once
* A needless parse call was required
* The result of the apply transformation was returned as a string
By having libxslt read and work with XML::Documents more naturally, I
was able to remove roughly 50% of the bindings code and at the same time
provide more functionality.
Note that for backwards compatibility, I added some Ruby code in the
bindings that mimics the old API (would be nice if it spit out
deprecation warnings, suppose we could borrow the code Rail's uses for
that).
So give it a try, and report any bugs.
Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://rubyforge.org/pipermail/libxml-devel/attachments/20080710/a9ad1d88/attachment.bin>
More information about the libxml-devel
mailing list