Alexander
A Rack middleware to process XML through XSLT to generate HTML.
The process occur only:
- If the file served is a XML (
mime-type: "application/xml"
); - and the XML has a stylesheet processing instruction (
<?xml-stylesheet type="text/xsl" href="/teste.xsl"?>
); - and the browser (
HTTP_USER_AGENT
header) has no support for XSLT processing.
If any of these conditions is false, Alexander will do nothing.
Installation
Add this line to your application's Gemfile:
gem 'alexander'
And then execute:
$ bundle
Or install it yourself as:
$ gem install alexander
Usage
Add to your Rack stack:
use Alexander::XslProcessor
Browsers with XSLT processing support:
- Chrome >= 1.0
- Firefox >= 3.0
- Safari >= 3.0
- Internet Explorer >= 6.0
- Opera >= 9.0
TODO
- Better error handling:
- Invalid XML.
- Invalid XSL.
- XSL page not found.
- URL parameter to force XSLT processing.
- Config parameter to force XSLT processing.
Content-Type
control, make it able to produce things other than HTML.- Examples of use in README.
- Sinatra
- Rails
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request