Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.caldersphere.net/svn/main/rubyforge/jrexml/tags/0.5.3@194 b03c2d0b-2f10-0410-a2f9-fc8001506dfa
- Loading branch information
1 parent
e9b8b36
commit 028d37a
Showing
10 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
require 'rexml/parsers/baseparser' | ||
require 'jrexml/java_pull_parser' | ||
|
||
class REXML::Parsers::BaseParser #:nodoc: | ||
# Extend every REXML base parser with a version that uses a Java pull parser | ||
# library | ||
def self.new(*args) | ||
obj = allocate | ||
obj.extend(JREXML::JavaPullParser) | ||
obj.send :initialize, *args | ||
obj | ||
end | ||
end | ||
require 'jrexml/ext/base_parser' | ||
require 'jrexml/ext/no_unnormalize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'rexml/parsers/baseparser' | ||
|
||
class REXML::Parsers::BaseParser #:nodoc: | ||
class << self | ||
# Set to true to disable JREXML (default nil/unset means use JREXML) | ||
attr_accessor :default_parser | ||
|
||
def new_default_parser(*args) | ||
prev = self.default_parser | ||
self.default_parser = true | ||
new(*args) | ||
ensure | ||
self.default_parser = prev | ||
end | ||
|
||
# Extend every REXML base parser with a version that uses a Java pull parser | ||
# library | ||
def new(*args) | ||
obj = allocate | ||
obj.extend(JREXML::JavaPullParser) unless self.default_parser | ||
class << obj; public :initialize; end | ||
obj.initialize *args | ||
obj | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rexml/text' | ||
require 'jrexml/ext/base_parser' | ||
|
||
module REXML | ||
class Text | ||
alias_method :original_initialize, :initialize | ||
|
||
# Redefine text initialize to receive the expanded value, since this is done | ||
# by JREXML. | ||
# | ||
# Original arity/args is: | ||
# def initialize arg, respect_whitespace=false, parent=nil, raw=nil, entity_filter=nil, illegal=ILLEGAL | ||
def initialize(value, *args) | ||
# Text.new is always called with raw = true from treeparser.rb | ||
if !REXML::Parsers::BaseParser.default_parser && args[2] | ||
args[2] = nil | ||
original_initialize(value, *args) | ||
# Set the 'unnormalized' ivar up front, since it's already expanded | ||
@unnormalized = value | ||
else | ||
original_initialize(value, *args) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module JREXML | ||
Version = "0.5.3" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require File.dirname(__FILE__) + '/spec_helper' | ||
require 'rexml/document' | ||
|
||
describe JREXML do | ||
def document | ||
REXML::Document.new %q(<document>text < other > text</document>) | ||
end | ||
|
||
it "should not need REXML's unnormalize method" do | ||
REXML::Parsers::BaseParser.default_parser = true | ||
document.root.text.should == %q(text < other > text) | ||
|
||
require 'jrexml/ext/no_unnormalize' | ||
REXML::Parsers::BaseParser.default_parser = false | ||
document.root.text.should == %q(text < other > text) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters