saxon-xslt 0.0.1-universal-java-1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rbenv-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/lib/saxon-xslt.rb +1 -0
- data/lib/saxon/xslt.rb +36 -0
- data/lib/saxon/xslt/version.rb +5 -0
- data/saxon-xslt.gemspec +21 -0
- data/vendor/saxonica/saxon9-unpack.jar +0 -0
- data/vendor/saxonica/saxon9he.jar +0 -0
- metadata +61 -0
data/.gitignore
ADDED
data/.rbenv-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-1.7.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Matt Patterson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Saxon::Xslt
|
2
|
+
|
3
|
+
Wraps the Saxon 9 HE XSLT processor Java API so it's easy to use from your JRuby project
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
require 'saxon-xslt'
|
7
|
+
transformer = Saxon::Xslt.new('/path/to/your.xsl')
|
8
|
+
output = transformer.transform('/path/to/your.xml')
|
9
|
+
```
|
10
|
+
|
11
|
+
This is a super-minimal first cut, it doesn't do many, many, things that it should and it is entirely untested. You probably shouldn't be using in production systems.
|
12
|
+
|
13
|
+
It only runs under JRuby.
|
14
|
+
|
15
|
+
You can find Saxon HE at http://sourceforge.net/projects/saxon/ and Saxonica at http://www.saxonica.com/
|
16
|
+
|
17
|
+
Saxon HE is (c) Michael H. Kay and released under the Mozilla MPL 1.0 (http://www.mozilla.org/MPL/1.0/)
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
gem 'saxon-xslt'
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install saxon-xslt
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
TODO: Write usage instructions here
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/saxon-xslt.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'saxon/xslt'
|
data/lib/saxon/xslt.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'saxon/xslt/version'
|
2
|
+
require 'java'
|
3
|
+
$CLASSPATH << File.expand_path('../../../vendor/saxonica/saxon9he.jar', __FILE__)
|
4
|
+
$CLASSPATH << File.expand_path('../../../vendor/saxonica/saxon9-unpack.jar', __FILE__)
|
5
|
+
|
6
|
+
java_import javax.xml.transform.stream.StreamSource
|
7
|
+
|
8
|
+
module Saxon
|
9
|
+
module S9API
|
10
|
+
java_import 'net.sf.saxon.s9api.Processor'
|
11
|
+
end
|
12
|
+
|
13
|
+
class Xslt
|
14
|
+
def self.compile(xslt_path)
|
15
|
+
new(xslt_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(xslt_path)
|
19
|
+
@processor = S9API::Processor.new(false)
|
20
|
+
@compiler = @processor.newXsltCompiler()
|
21
|
+
@xslt = @compiler.compile(StreamSource.new(java.io.File.new(xslt_path)))
|
22
|
+
end
|
23
|
+
|
24
|
+
def transform(xml_path)
|
25
|
+
serializer = @processor.newSerializer()
|
26
|
+
output = java.io.StringWriter.new()
|
27
|
+
serializer.setOutputWriter(output)
|
28
|
+
xml = @processor.newDocumentBuilder().build(StreamSource.new(java.io.File.new(xml_path)))
|
29
|
+
transformer = @xslt.load
|
30
|
+
transformer.setInitialContextNode(xml)
|
31
|
+
transformer.setDestination(serializer)
|
32
|
+
transformer.transform
|
33
|
+
output.toString
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/saxon-xslt.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'saxon/xslt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "saxon-xslt"
|
8
|
+
gem.version = Saxon::Xslt::VERSION
|
9
|
+
gem.authors = ["Matt Patterson"]
|
10
|
+
gem.email = ["matt@reprocessed.org"]
|
11
|
+
gem.description = %q{Wraps the Saxon 9.4 HE XSLT 2.0 processor so that you can transform XSLT 2 stylesheets in JRuby}
|
12
|
+
gem.summary = %q{Saxon 9.4 HE XSLT 2.0 for JRuby}
|
13
|
+
gem.homepage = "https://github.com/fidothe/saxon-xslt"
|
14
|
+
gem.licenses = ["MIT", "MPL-1.0"]
|
15
|
+
gem.platform = Gem::Platform.local
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
end
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: saxon-xslt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: universal-java-1.6
|
7
|
+
authors:
|
8
|
+
- Matt Patterson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Wraps the Saxon 9.4 HE XSLT 2.0 processor so that you can transform XSLT 2 stylesheets in JRuby
|
15
|
+
email:
|
16
|
+
- matt@reprocessed.org
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- .rbenv-version
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE.txt
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- lib/saxon-xslt.rb
|
28
|
+
- lib/saxon/xslt.rb
|
29
|
+
- lib/saxon/xslt/version.rb
|
30
|
+
- saxon-xslt.gemspec
|
31
|
+
- vendor/saxonica/saxon9-unpack.jar
|
32
|
+
- vendor/saxonica/saxon9he.jar
|
33
|
+
homepage: https://github.com/fidothe/saxon-xslt
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
- MPL-1.0
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: !binary |-
|
46
|
+
MA==
|
47
|
+
none: false
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: !binary |-
|
53
|
+
MA==
|
54
|
+
none: false
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.8.24
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Saxon 9.4 HE XSLT 2.0 for JRuby
|
61
|
+
test_files: []
|