saxon-rb 0.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +62 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +20 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/net/sf/saxon/Saxon-HE/9.9.1-5/Saxon-HE-9.9.1-5.jar +0 -0
- data/lib/saxon.rb +6 -0
- data/lib/saxon/axis_iterator.rb +31 -0
- data/lib/saxon/configuration.rb +116 -0
- data/lib/saxon/document_builder.rb +28 -0
- data/lib/saxon/item_type.rb +290 -0
- data/lib/saxon/item_type/lexical_string_conversion.rb +383 -0
- data/lib/saxon/item_type/value_to_ruby.rb +78 -0
- data/lib/saxon/jaxp.rb +8 -0
- data/lib/saxon/loader.rb +93 -0
- data/lib/saxon/occurrence_indicator.rb +33 -0
- data/lib/saxon/parse_options.rb +127 -0
- data/lib/saxon/processor.rb +102 -0
- data/lib/saxon/qname.rb +153 -0
- data/lib/saxon/s9api.rb +34 -0
- data/lib/saxon/serializer.rb +143 -0
- data/lib/saxon/source.rb +187 -0
- data/lib/saxon/version.rb +3 -0
- data/lib/saxon/xdm.rb +35 -0
- data/lib/saxon/xdm/array.rb +77 -0
- data/lib/saxon/xdm/atomic_value.rb +173 -0
- data/lib/saxon/xdm/empty_sequence.rb +37 -0
- data/lib/saxon/xdm/external_object.rb +21 -0
- data/lib/saxon/xdm/function_item.rb +21 -0
- data/lib/saxon/xdm/item.rb +32 -0
- data/lib/saxon/xdm/map.rb +77 -0
- data/lib/saxon/xdm/node.rb +71 -0
- data/lib/saxon/xdm/sequence_like.rb +30 -0
- data/lib/saxon/xdm/value.rb +145 -0
- data/lib/saxon/xpath.rb +8 -0
- data/lib/saxon/xpath/compiler.rb +69 -0
- data/lib/saxon/xpath/executable.rb +58 -0
- data/lib/saxon/xpath/static_context.rb +161 -0
- data/lib/saxon/xpath/variable_declaration.rb +68 -0
- data/lib/saxon/xslt.rb +8 -0
- data/lib/saxon/xslt/compiler.rb +70 -0
- data/lib/saxon/xslt/evaluation_context.rb +165 -0
- data/lib/saxon/xslt/executable.rb +156 -0
- data/lib/saxon_jars.rb +10 -0
- data/saxon-rb.gemspec +39 -0
- data/saxon.gemspec +30 -0
- metadata +240 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 438d4b8ef09160fb03c5e6d4d03ef3577ab31052c26bd73d74826fda6ac26132
|
4
|
+
data.tar.gz: c3ca6f0bea6dd55f650074e02b7d81f9821a1677d45fe53c919f5d7163e47534
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ebc091905a83b8733e9a1959970721b378160edabe6013043dd1f815393b3674781df53162b7d2e09f2140f6f7c8e258352ab15a114dbda17e1ca5e954425145
|
7
|
+
data.tar.gz: 0acc6ecd8b6e48bbe45da3b1405e13fde93db3eb62c4a191b4462ab493e31013bdf3ea3d0c48119422b49e906ec76891f44ee6dc631774109ea1cdada07196fa
|
@@ -0,0 +1,62 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
test_vendored_saxon:
|
4
|
+
environment:
|
5
|
+
BUNDLE_JOBS: 3
|
6
|
+
BUNDLE_RETRY: 3
|
7
|
+
BUNDLE_PATH: vendor/bundle
|
8
|
+
JRUBY_OPTS: "--dev --debug"
|
9
|
+
docker:
|
10
|
+
- image: circleci/jruby:9.2.8.0-jdk
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
- run:
|
14
|
+
name: Bundle Install
|
15
|
+
command: bundle check || bundle install
|
16
|
+
- run:
|
17
|
+
command: |
|
18
|
+
mkdir /tmp/test-results
|
19
|
+
bundle exec rspec spec --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
|
20
|
+
- store_test_results:
|
21
|
+
path: /tmp/test-results
|
22
|
+
- store_artifacts:
|
23
|
+
path: /tmp/test-results
|
24
|
+
destination: test-results
|
25
|
+
test_saxon_98:
|
26
|
+
environment:
|
27
|
+
BUNDLE_JOBS: 3
|
28
|
+
BUNDLE_RETRY: 3
|
29
|
+
BUNDLE_PATH: vendor/bundle
|
30
|
+
ALTERNATE_SAXON_HOME: /tmp/saxon
|
31
|
+
JRUBY_OPTS: "--dev --debug"
|
32
|
+
docker:
|
33
|
+
- image: circleci/jruby:9.2.8.0-jdk
|
34
|
+
steps:
|
35
|
+
- checkout
|
36
|
+
- run:
|
37
|
+
name: Download Saxon 9.8
|
38
|
+
command: |
|
39
|
+
mkdir /tmp/saxon
|
40
|
+
cd /tmp/saxon
|
41
|
+
curl -L -O https://sourceforge.net/projects/saxon/files/Saxon-HE/9.8/SaxonHE9-8-0-15J.zip
|
42
|
+
unzip SaxonHE9-8-0-15J.zip
|
43
|
+
rm -f SaxonHE9-8-0-15J.zip
|
44
|
+
- run:
|
45
|
+
name: Bundle Install
|
46
|
+
command: bundle check || bundle install
|
47
|
+
- run:
|
48
|
+
command: |
|
49
|
+
mkdir /tmp/test-results
|
50
|
+
bundle exec rspec spec --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
|
51
|
+
- store_test_results:
|
52
|
+
path: /tmp/test-results
|
53
|
+
- store_artifacts:
|
54
|
+
path: /tmp/test-results
|
55
|
+
destination: test-results
|
56
|
+
|
57
|
+
workflows:
|
58
|
+
version: 2
|
59
|
+
build_and_test:
|
60
|
+
jobs:
|
61
|
+
- test_vendored_saxon
|
62
|
+
- test_saxon_98
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-9.2.6.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at matt@reprocessed.org. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Matt Patterson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Saxon
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/saxon`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'saxon'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install saxon
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/saxon. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Saxon project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/saxon/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#require 'bundler/gem_tasks'
|
2
|
+
require 'bundler/gem_helper'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'jars/installer'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
desc "Install JAR dependencies"
|
11
|
+
task :install_jars do
|
12
|
+
Jars::Installer.vendor_jars!
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :new_saxon do
|
16
|
+
Bundler::GemHelper.install_tasks(name: 'saxon-rb')
|
17
|
+
end
|
18
|
+
namespace :old_saxon do
|
19
|
+
Bundler::GemHelper.install_tasks(name: 'saxon')
|
20
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "saxon"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
Binary file
|
data/lib/saxon.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 's9api'
|
2
|
+
|
3
|
+
module Saxon
|
4
|
+
# An XPath Data Model Node object, representing an XML document, or an element or one of the other node chunks in the XDM.
|
5
|
+
class AxisIterator
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
attr_reader :s9_xdm_node, :s9_axis
|
9
|
+
private :s9_xdm_node, :s9_axis
|
10
|
+
|
11
|
+
def initialize(xdm_node, axis)
|
12
|
+
@s9_xdm_node = xdm_node.to_java
|
13
|
+
@s9_axis = Saxon::S9API::Axis.const_get(axis.to_s.upcase.to_sym)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Saxon::S9API::XdmSequenceIterator] A new Saxon Java XDM sequence iterator.
|
17
|
+
def to_java
|
18
|
+
s9_sequence_iterator
|
19
|
+
end
|
20
|
+
|
21
|
+
def each(&block)
|
22
|
+
s9_sequence_iterator.lazy.map { |s9_xdm_node| Saxon::XDM::Node.new(s9_xdm_node) }.each(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def s9_sequence_iterator
|
28
|
+
s9_xdm_node.axisIterator(s9_axis)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'saxon/s9api'
|
2
|
+
require 'saxon/parse_options'
|
3
|
+
|
4
|
+
module Saxon
|
5
|
+
# Wraps the <tt>net.saxon.Configuration</tt> class. See
|
6
|
+
# http://saxonica.com/documentation9.5/javadoc/net/sf/saxon/Configuration.html
|
7
|
+
# for details of what configuration options are available and what values
|
8
|
+
# they accept. See
|
9
|
+
# http://saxonica.com/documentation9.5/javadoc/net/sf/saxon/lib/FeatureKeys.html
|
10
|
+
# for details of the constant names used to access the values
|
11
|
+
class Configuration
|
12
|
+
DEFAULT_SEMAPHORE = Mutex.new
|
13
|
+
|
14
|
+
# Provides a processor with default configuration. Essentially a singleton
|
15
|
+
# instance
|
16
|
+
# @return [Saxon::Configuration]
|
17
|
+
def self.default
|
18
|
+
DEFAULT_SEMAPHORE.synchronize do
|
19
|
+
@config ||= create
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param processor [Saxon::Processor] a Saxon::Processor instance
|
24
|
+
# @return [Saxon::Configuration]
|
25
|
+
def self.create(processor = nil)
|
26
|
+
Saxon::Loader.load!
|
27
|
+
if processor
|
28
|
+
config = processor.to_java.underlying_configuration
|
29
|
+
else
|
30
|
+
config = Saxon::S9API::Configuration.new
|
31
|
+
end
|
32
|
+
new(config)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param license_path [String] the absolute path to a Saxon PE or EE
|
36
|
+
# license file
|
37
|
+
# @return [Saxon::Configuration]
|
38
|
+
def self.create_licensed(license_path)
|
39
|
+
Saxon::Loader.load!
|
40
|
+
java_config = Saxon::S9API::Configuration.makeLicensedConfiguration(nil, nil)
|
41
|
+
config = new(java_config)
|
42
|
+
config[:LICENSE_FILE_LOCATION] = license_path
|
43
|
+
config
|
44
|
+
end
|
45
|
+
|
46
|
+
# Set a already-created Licensed Configuration object as the default
|
47
|
+
# configuration
|
48
|
+
def self.set_licensed_default!(licensed_configuration)
|
49
|
+
DEFAULT_SEMAPHORE.synchronize do
|
50
|
+
@config = licensed_configuration
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# @api private
|
55
|
+
# @param config [net.sf.saxon.Configuration] The Saxon Configuration
|
56
|
+
# instance to wrap
|
57
|
+
def initialize(config)
|
58
|
+
@config = config
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get a configuration option value
|
62
|
+
# See https://www.saxonica.com/html/documentation/javadoc/net/sf/saxon/lib/FeatureKeys.html
|
63
|
+
# for details of the available options. Use the constant name as a string
|
64
|
+
# or symbol as the option
|
65
|
+
#
|
66
|
+
# @param option [String, Symbol]
|
67
|
+
# @return [Object] the value of the configuration option
|
68
|
+
# @raise [NameError] if the option name does not exist
|
69
|
+
def [](option)
|
70
|
+
@config.getConfigurationProperty(option_url(option))
|
71
|
+
end
|
72
|
+
|
73
|
+
# Get a configuration option value
|
74
|
+
# See http://saxonica.com/documentation9.5/javadoc/net/sf/saxon/lib/FeatureKeys.html
|
75
|
+
# for details of the available options. Use the constant name as a string
|
76
|
+
# or symbol as the option
|
77
|
+
#
|
78
|
+
# @param option [String, Symbol]
|
79
|
+
# @param value [Object] the value of the configuration option
|
80
|
+
# @return [Object] the value you passed in
|
81
|
+
# @raise [NameError] if the option name does not exist
|
82
|
+
def []=(option, value)
|
83
|
+
url = option_url(option)
|
84
|
+
@config.setConfigurationProperty(url, value)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return the current ParseOptions object
|
88
|
+
# See https://www.saxonica.com/documentation/index.html#!javadoc/net.sf.saxon.lib/ParseOptions
|
89
|
+
# for details. This allows you to set JAXP features and properties to be
|
90
|
+
# passed to the parser
|
91
|
+
#
|
92
|
+
# @return [Saxon::ParseOptions] the ParseOptions object
|
93
|
+
def parse_options
|
94
|
+
ParseOptions.new(@config.getParseOptions)
|
95
|
+
end
|
96
|
+
|
97
|
+
# @return [net.sf.saxon.Configuration] The underlying Saxon Configuration
|
98
|
+
def to_java
|
99
|
+
@config
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def feature_keys
|
105
|
+
@feature_keys ||= Saxon::S9API::FeatureKeys.java_class
|
106
|
+
end
|
107
|
+
|
108
|
+
def option_url(option)
|
109
|
+
feature_keys.field(normalize_option_name(option)).static_value
|
110
|
+
end
|
111
|
+
|
112
|
+
def normalize_option_name(option)
|
113
|
+
option.to_s.upcase
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|