libxml-jruby-modified 1.0.1-jruby

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +91 -0
  4. data/README.txt +50 -0
  5. data/Rakefile +20 -0
  6. data/lib/libxml-jruby/xml/attr.rb +46 -0
  7. data/lib/libxml-jruby/xml/attributes.rb +68 -0
  8. data/lib/libxml-jruby/xml/document.rb +48 -0
  9. data/lib/libxml-jruby/xml/dtd.rb +25 -0
  10. data/lib/libxml-jruby/xml/node.rb +285 -0
  11. data/lib/libxml-jruby/xml/ns.rb +19 -0
  12. data/lib/libxml-jruby/xml/parser.rb +121 -0
  13. data/lib/libxml-jruby/xml/xpath.rb +98 -0
  14. data/lib/libxml-jruby/xml.rb +1 -0
  15. data/lib/libxml-jruby.rb +82 -0
  16. data/lib/libxml.rb +1 -0
  17. data/lib/xml/libxml.rb +8 -0
  18. data/lib/xml.rb +13 -0
  19. data/libxml-jruby-1.0.1-java.gem +0 -0
  20. data/libxml-jruby.gemspec +15 -0
  21. data/script/benchmark/depixelate.rb +633 -0
  22. data/script/benchmark/hamlet.xml +9055 -0
  23. data/script/benchmark/sock_entries.xml +507 -0
  24. data/script/benchmark/throughput.rb +40 -0
  25. data/script/benchmark/xml_benchmarks.rb +228 -0
  26. data/script/test +6 -0
  27. data/tasks/ann.rake +81 -0
  28. data/tasks/bones.rake +21 -0
  29. data/tasks/gem.rake +126 -0
  30. data/tasks/git.rake +41 -0
  31. data/tasks/manifest.rake +49 -0
  32. data/tasks/notes.rake +28 -0
  33. data/tasks/post_load.rake +39 -0
  34. data/tasks/rdoc.rake +51 -0
  35. data/tasks/rubyforge.rake +57 -0
  36. data/tasks/setup.rb +268 -0
  37. data/tasks/spec.rake +55 -0
  38. data/tasks/svn.rake +48 -0
  39. data/tasks/test.rake +38 -0
  40. data/test/etc_doc_to_s.rb +19 -0
  41. data/test/ets_copy_bug.rb +21 -0
  42. data/test/ets_copy_bug3.rb +38 -0
  43. data/test/ets_doc_file.rb +15 -0
  44. data/test/ets_doc_to_s.rb +21 -0
  45. data/test/ets_gpx.rb +26 -0
  46. data/test/ets_node_gc.rb +21 -0
  47. data/test/ets_test.xml +2 -0
  48. data/test/ets_tsr.rb +9 -0
  49. data/test/model/books.xml +147 -0
  50. data/test/model/default_validation_bug.rb +0 -0
  51. data/test/model/merge_bug_data.xml +58 -0
  52. data/test/model/rubynet.xml +78 -0
  53. data/test/model/rubynet_project +1 -0
  54. data/test/model/saxtest.xml +5 -0
  55. data/test/model/shiporder.rnc +28 -0
  56. data/test/model/shiporder.rng +86 -0
  57. data/test/model/shiporder.xml +23 -0
  58. data/test/model/shiporder.xsd +31 -0
  59. data/test/model/simple.xml +7 -0
  60. data/test/model/soap.xml +27 -0
  61. data/test/model/xinclude.xml +5 -0
  62. data/test/tc_attributes.rb +110 -0
  63. data/test/tc_deprecated_require.rb +13 -0
  64. data/test/tc_document.rb +97 -0
  65. data/test/tc_document_write.rb +139 -0
  66. data/test/tc_dtd.rb +70 -0
  67. data/test/tc_html_parser.rb +63 -0
  68. data/test/tc_node.rb +108 -0
  69. data/test/tc_node_attr.rb +176 -0
  70. data/test/tc_node_cdata.rb +51 -0
  71. data/test/tc_node_comment.rb +32 -0
  72. data/test/tc_node_copy.rb +40 -0
  73. data/test/tc_node_edit.rb +98 -0
  74. data/test/tc_node_set.rb +24 -0
  75. data/test/tc_node_set2.rb +37 -0
  76. data/test/tc_node_text.rb +17 -0
  77. data/test/tc_node_xlink.rb +28 -0
  78. data/test/tc_ns.rb +18 -0
  79. data/test/tc_parser.rb +308 -0
  80. data/test/tc_parser_context.rb +126 -0
  81. data/test/tc_properties.rb +37 -0
  82. data/test/tc_reader.rb +112 -0
  83. data/test/tc_relaxng.rb +39 -0
  84. data/test/tc_sax_parser.rb +113 -0
  85. data/test/tc_schema.rb +39 -0
  86. data/test/tc_traversal.rb +220 -0
  87. data/test/tc_well_formed.rb +11 -0
  88. data/test/tc_xinclude.rb +26 -0
  89. data/test/tc_xpath.rb +130 -0
  90. data/test/tc_xpath_context.rb +72 -0
  91. data/test/tc_xpointer.rb +78 -0
  92. data/test/test_libxml-jruby.rb +0 -0
  93. data/test/test_suite.rb +31 -0
  94. data/test/ts_working.rb +31 -0
  95. metadata +135 -0
@@ -0,0 +1,121 @@
1
+ class LibXMLJRuby::XML::Parser
2
+ class ParseError < RuntimeError; end
3
+
4
+ VERNUM = 0
5
+ VERSION = '0'
6
+
7
+ @default_tree_indent_string = ' '
8
+ @check_lib_versions = ''
9
+ @features = []
10
+
11
+ class << self
12
+ attr_accessor :debug_entities, :default_compression,
13
+ :default_keep_blanks, :default_line_numbers,
14
+ :default_substitute_entities,
15
+ :default_tree_indent_string,
16
+ :default_validity_checking, :default_warnings,
17
+ :features, :indent_tree_output,
18
+ :check_lib_versions
19
+
20
+ def register_error_handler(handler = nil, &block)
21
+
22
+ end
23
+
24
+ def file(filename)
25
+ p = new
26
+ p.filename = filename
27
+ p
28
+ end
29
+
30
+ def string(string)
31
+ p = new
32
+ p.string = string
33
+ p
34
+ end
35
+
36
+ def io(io)
37
+ p = new
38
+ p.io = io
39
+ p
40
+ end
41
+ end
42
+
43
+ def initialize
44
+ @source_type = nil
45
+ @parsed = false
46
+ end
47
+
48
+ attr_reader :string, :filename, :io
49
+
50
+ def string=(string = nil)
51
+ raise TypeError if string.nil?
52
+ @parsed = false
53
+ @source_type = String
54
+ @string = string
55
+ end
56
+
57
+ def filename=(filename)
58
+ @source_type = File
59
+ @filename = filename
60
+ end
61
+
62
+ def io=(io)
63
+ raise TypeError if StringIO === io
64
+ @io = io
65
+ self.string = @io.read
66
+ end
67
+
68
+ def parse
69
+ raise ParseError, "You cannot parse twice" if @parsed
70
+ raise ParseError, "No input specified, please specify an input" unless @source_type
71
+ doc = send("parse_#{@source_type.to_s.downcase}")
72
+ @parsed = true
73
+ doc
74
+ end
75
+
76
+ def document_builder_factory
77
+ @dbf ||= DocumentBuilderFactory.new_instance
78
+ end
79
+
80
+ def document_builder
81
+ document_builder_factory.namespace_aware = true
82
+ document_builder_factory.new_document_builder
83
+ end
84
+
85
+ def string_reader
86
+ StringReader.new(@string)
87
+ end
88
+
89
+ def input_source
90
+ InputSource.new(string_reader)
91
+ end
92
+
93
+ def parse_string
94
+ raise ParseError if @string.empty?
95
+ builder = document_builder
96
+
97
+ begin
98
+ jdoc = builder.parse(input_source)
99
+ rescue NativeException
100
+ raise ParseError
101
+ end
102
+
103
+ XML::Document.from_java(jdoc)
104
+ end
105
+
106
+ def parse_file
107
+ builder = document_builder
108
+
109
+ begin
110
+ jdoc = builder.parse(@filename)
111
+ rescue
112
+ raise ParseError
113
+ end
114
+
115
+ XML::Document.from_java(jdoc)
116
+ end
117
+
118
+ def parse_io
119
+ parse_string
120
+ end
121
+ end
@@ -0,0 +1,98 @@
1
+ module LibXMLJRuby
2
+ module XML
3
+ module XPath
4
+ NODESET = nil
5
+
6
+ class Object
7
+ include Enumerable
8
+
9
+ def initialize(expr, document, nslist = nil)
10
+ @expr, @document = expr, document
11
+ @nslist = nslist
12
+ end
13
+
14
+ def each(&block)
15
+ set.each(&block)
16
+ end
17
+
18
+ def length
19
+ set.length
20
+ end
21
+
22
+ def first
23
+ set.first
24
+ end
25
+
26
+ def xpath_type
27
+ XML::XPath::NODESET
28
+ end
29
+
30
+ def set
31
+ @set ||= XML::Node::Set.from_java(evaluate_expression)
32
+ end
33
+
34
+ def [](index)
35
+ set[index]
36
+ end
37
+
38
+ private
39
+ def xpath_factory
40
+ @xpath_factory ||= XPathFactory.new_instance
41
+ end
42
+
43
+ def xpath
44
+ @xpath ||= xpath_factory.newXPath
45
+ end
46
+
47
+ def resolver
48
+ PrefixResolverDefault.new(doc_element)
49
+ end
50
+
51
+ def doc_element
52
+ if document.respond_to?(:getDocumentElement)
53
+ document.getDocumentElement
54
+ elsif document.respond_to?(:getOwnerDocument)
55
+ document.getOwnerDocument
56
+ else
57
+ nil
58
+ end
59
+ end
60
+
61
+ def namespace_context
62
+ CustomNamespaceContext.new(resolver)
63
+ end
64
+
65
+ def evaluate_expression
66
+ xpath.setNamespaceContext(namespace_context)
67
+ xpath.evaluate(@expr, document, XPathConstants::NODESET)
68
+ end
69
+
70
+ def document
71
+ @document.respond_to?(:java_obj) ? @document.java_obj : @document
72
+ end
73
+
74
+ class CustomNamespaceContext
75
+ include NamespaceContext
76
+
77
+ attr_reader :resolver
78
+
79
+ def initialize(resolver)
80
+ @resolver = resolver
81
+ end
82
+
83
+ def getNamespaceURI(prefix)
84
+ resolver.getNamespaceForPrefix(prefix)
85
+ end
86
+
87
+ def getPrefixes(val)
88
+ nil
89
+ end
90
+
91
+ def getPrefix(uri)
92
+ nil
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + '/xml/node'
@@ -0,0 +1,82 @@
1
+ # $Id$
2
+
3
+ # Equivalent to a header guard in C/C++
4
+ # Used to prevent the class/module from being loaded more than once
5
+ unless defined? LibXMLJRuby
6
+
7
+ module LibXMLJRuby
8
+
9
+ # :stopdoc:
10
+ VERSION = '1.0.0'
11
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
12
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
13
+ # :startdoc:
14
+
15
+ # Returns the version string for the library.
16
+ #
17
+ def self.version
18
+ VERSION
19
+ end
20
+
21
+ # Returns the library path for the module. If any arguments are given,
22
+ # they will be joined to the end of the libray path using
23
+ # <tt>File.join</tt>.
24
+ #
25
+ def self.libpath( *args )
26
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
27
+ end
28
+
29
+ # Returns the lpath for the module. If any arguments are given,
30
+ # they will be joined to the end of the path using
31
+ # <tt>File.join</tt>.
32
+ #
33
+ def self.path( *args )
34
+ args.empty? ? PATH : ::File.join(PATH, *args)
35
+ end
36
+
37
+ # Utility method used to rquire all files ending in .rb that lie in the
38
+ # directory below this file that has the same name as the filename passed
39
+ # in. Optionally, a specific _directory_ name can be passed in such that
40
+ # the _filename_ does not have to be equivalent to the directory.
41
+ #
42
+ def self.require_all_libs_relative_to( fname, dir = nil )
43
+ dir ||= ::File.basename(fname, '.*')
44
+ search_me = ::File.expand_path(
45
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
46
+
47
+ Dir.glob(search_me).sort.each {|rb| require rb}
48
+ end
49
+
50
+ end # module LibXMLJRuby
51
+
52
+ require 'java'
53
+ require 'stringio'
54
+ import javax.xml.parsers.DocumentBuilder
55
+ import javax.xml.parsers.DocumentBuilderFactory
56
+ import javax.xml.xpath.XPath
57
+ import javax.xml.xpath.XPathFactory
58
+ import javax.xml.xpath.XPathConstants
59
+ import javax.xml.namespace.NamespaceContext
60
+ import java.io.StringReader
61
+ import java.io.StringWriter
62
+ import javax.xml.validation.Schema
63
+ import javax.xml.validation.SchemaFactory
64
+ import java.io.ByteArrayInputStream
65
+ import javax.xml.transform.stream.StreamSource
66
+ import javax.xml.transform.stream.StreamResult
67
+ import javax.xml.transform.TransformerFactory
68
+ import javax.xml.transform.dom.DOMSource
69
+
70
+ # these use include_class to avoid conflicts with Rake's top-level
71
+ # import method, the issue doesn't seem to occur when not using a
72
+ # string.
73
+ include_class 'com.sun.org.apache.xml.internal.utils.PrefixResolver'
74
+ include_class 'com.sun.org.apache.xml.internal.utils.PrefixResolverDefault'
75
+ include_class 'org.xml.sax.InputSource'
76
+
77
+ LibXMLJRuby.require_all_libs_relative_to __FILE__
78
+ ::LibXML = ::LibXMLJRuby
79
+
80
+ end # unless defined?
81
+
82
+ # EOF
data/lib/libxml.rb ADDED
@@ -0,0 +1 @@
1
+ require 'libxml-jruby'
data/lib/xml/libxml.rb ADDED
@@ -0,0 +1,8 @@
1
+ # This is here for backward compatibility.
2
+ #
3
+ # TODO: DEPRECATE!
4
+
5
+ require 'libxml.rb'
6
+
7
+ include LibXML
8
+
data/lib/xml.rb ADDED
@@ -0,0 +1,13 @@
1
+ # This file loads libxml and adds the LibXML namespace
2
+ # to the toplevel for conveneience. The end result
3
+ # is to have XML:: universally exposed.
4
+ #
5
+ # It is recommend that you only load this file for libs
6
+ # that do not have their own namespace, eg. administrative
7
+ # scripts, personal programs, etc. For other applications
8
+ # require 'libxml' instead and include LibXML into your
9
+ # app/libs namespace.
10
+
11
+ require 'libxml'
12
+
13
+ include LibXML
Binary file
@@ -0,0 +1,15 @@
1
+ require 'rake'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "libxml-jruby-modified"
5
+ s.version = "1.0.1"
6
+ s.date = "2015-05-19"
7
+ s.summary = "LibXMLRuby compatibility layer for jruby"
8
+ s.homepage = "http://rubyforge.org/projects/libxml-jruby"
9
+ s.authors = "Michael Guterl"
10
+ s.email = "mguterl @nospam@ gmail.com"
11
+ s.rubyforge_project = "libxml-jruby"
12
+ s.has_rdoc = false
13
+ s.platform = "jruby"
14
+ s.files = FileList['lib/**/*.rb', 'script/**/*', 'tasks/**/*', '[A-Z]*', 'test/**/*'].to_a
15
+ end