-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaaf8db
commit 357a05f
Showing
4 changed files
with
50 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ env: | |
matrix: | ||
- HANDLER="nokogiri" | ||
- HANDLER="ox" | ||
- HANDLER="oga" |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'sax-machine/handlers/sax_abstract_handler' | ||
require 'oga' | ||
|
||
module SAXMachine | ||
class SAXOgaHandler | ||
include SAXAbstractHandler | ||
|
||
def initialize(*args) | ||
_initialize(*args) | ||
end | ||
|
||
def sax_parse(xml_text) | ||
Oga.sax_parse_xml(self, xml_text) | ||
end | ||
|
||
def on_element(namespace, name, attrs) | ||
_start_element(node_name(namespace, name), attrs.map { |a| [a.name, a.value] }) | ||
end | ||
|
||
def after_element(namespace, name) | ||
_end_element(node_name(namespace, name)) | ||
end | ||
|
||
def on_error(*args) | ||
_error(args.join(" ")) | ||
end | ||
|
||
alias_method :on_text, :_characters | ||
alias_method :on_cdata, :_characters | ||
|
||
private | ||
|
||
def node_name(namespace, name) | ||
namespace ? [namespace, name].join(":") : name | ||
end | ||
end | ||
end |