[前][次][番号順一覧][スレッド一覧]

ruby-changes:35820

From: hsbt <ko1@a...>
Date: Mon, 13 Oct 2014 17:53:23 +0900 (JST)
Subject: [ruby-changes:35820] hsbt:r47902 (trunk): * lib/xmlrpc/parser.rb: added new parser class using libxml-ruby gem.

hsbt	2014-10-13 17:53:16 +0900 (Mon, 13 Oct 2014)

  New Revision: 47902

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47902

  Log:
    * lib/xmlrpc/parser.rb: added new parser class using libxml-ruby gem.
      [Feature #9379][ruby-core:59633]
    * lib/xmlrpc/config.rb: ditto.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/xmlrpc/config.rb
    trunk/lib/xmlrpc/parser.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47901)
+++ ChangeLog	(revision 47902)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Oct 13 17:53:01 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
+
+	* lib/xmlrpc/parser.rb: added new parser class using libxml-ruby gem.
+	  [Feature #9379][ruby-core:59633]
+	* lib/xmlrpc/config.rb: ditto.
+
 Mon Oct 13 16:32:56 2014  Tanaka Akira  <akr@f...>
 
 	* lib/find.rb (Find.find): Call to_path for arguments to obtain
Index: lib/xmlrpc/config.rb
===================================================================
--- lib/xmlrpc/config.rb	(revision 47901)
+++ lib/xmlrpc/config.rb	(revision 47902)
@@ -18,6 +18,7 @@ module XMLRPC # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/config.rb#L18
     # * XMLParser::XMLStreamParser (fastest)
     # * XMLParser::REXMLStreamParser
     # * XMLParser::XMLScanStreamParser
+    # * XMLParser::LibXMLStreamParser
     DEFAULT_PARSER = XMLParser::REXMLStreamParser
 
     # enable <code><nil/></code> tag
Index: lib/xmlrpc/parser.rb
===================================================================
--- lib/xmlrpc/parser.rb	(revision 47901)
+++ lib/xmlrpc/parser.rb	(revision 47902)
@@ -814,12 +814,44 @@ module XMLRPC # :nodoc: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/parser.rb#L814
       end
     end
 
+    class LibXMLStreamParser < AbstractStreamParser
+      def initialize
+        require 'libxml'
+        @parser_class = LibXMLStreamListener
+      end
+
+      class LibXMLStreamListener
+        include StreamParserMixin
+
+        def on_start_element_ns(name, attributes, prefix, uri, namespaces)
+          startElement(name)
+        end
+
+        def on_end_element_ns(name, prefix, uri)
+          endElement(name)
+        end
+
+        alias :on_characters :character
+        alias :on_cdata_block :character
+
+        def method_missing(*a)
+        end
+
+        def parse(str)
+          parser = LibXML::XML::SaxParser.string(str)
+          parser.callbacks = self
+          parser.parse()
+        end
+      end
+    end
+
     XMLParser   = XMLTreeParser
     NQXMLParser = NQXMLTreeParser
 
     Classes = [XMLStreamParser, XMLTreeParser,
                NQXMLStreamParser, NQXMLTreeParser,
-               REXMLStreamParser, XMLScanStreamParser]
+               REXMLStreamParser, XMLScanStreamParser,
+               LibXMLStreamParser]
 
     # yields an instance of each installed parser
     def self.each_installed_parser
Index: NEWS
===================================================================
--- NEWS	(revision 47901)
+++ NEWS	(revision 47902)
@@ -159,6 +159,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L159
 
     http://docs.seattlerb.org/rubygems/History_txt.html#label-2.4.2+%2F+2014-10-01
 
+* XMLRPC
+  * Added new parser class named LibXMLStreamParser.
+
 === Stdlib compatibility issues (excluding feature bug fixes)
 
 * lib/mathn.rb

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]