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

ruby-changes:30442

From: kou <ko1@a...>
Date: Sun, 11 Aug 2013 19:08:10 +0900 (JST)
Subject: [ruby-changes:30442] kou:r42521 (trunk): * lib/rexml/sax2listener.rb (REXML::SAX2Listener#notationdecl): Fix

kou	2013-08-11 19:08:05 +0900 (Sun, 11 Aug 2013)

  New Revision: 42521

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

  Log:
    * lib/rexml/sax2listener.rb (REXML::SAX2Listener#notationdecl): Fix
      wrong number of arguments in the template listener.
      [Bug #8731] [ruby-dev:47582]
      Reported by Ippei Obayashi.
    * test/rexml/parser/test_sax2.rb: Add tests for parsing notation
      declarations with SAX2 API.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/sax2listener.rb
    trunk/test/rexml/parser/test_sax2.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42520)
+++ ChangeLog	(revision 42521)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Aug 11 19:06:03 2013  Kouhei Sutou  <kou@c...>
+
+	* lib/rexml/sax2listener.rb (REXML::SAX2Listener#notationdecl): Fix
+	  wrong number of arguments in the template listener.
+	  [Bug #8731] [ruby-dev:47582]
+	  Reported by Ippei Obayashi.
+	* test/rexml/parser/test_sax2.rb: Add tests for parsing notation
+	  declarations with SAX2 API.
+
 Sun Aug 11 18:44:04 2013  Kouhei Sutou  <kou@c...>
 
 	* lib/rexml/sax2listener.rb (REXML::SAX2Listener#elementdecl): Fix wrong
Index: lib/rexml/sax2listener.rb
===================================================================
--- lib/rexml/sax2listener.rb	(revision 42520)
+++ lib/rexml/sax2listener.rb	(revision 42521)
@@ -73,7 +73,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/sax2listener.rb#L73
     def entitydecl declaration
     end
     # <!NOTATION ...>
-    def notationdecl content
+    def notationdecl name, public_or_system, public_id, system_id
     end
     # Called when <![CDATA[ ... ]]> is encountered in a document.
     # @p content "..."
Index: test/rexml/parser/test_sax2.rb
===================================================================
--- test/rexml/parser/test_sax2.rb	(revision 42520)
+++ test/rexml/parser/test_sax2.rb	(revision 42521)
@@ -145,5 +145,56 @@ class TestSAX2Parser < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rexml/parser/test_sax2.rb#L145
         end
       end
     end
+
+    class TestNotationDeclaration < self
+      class Listener
+        include REXML::SAX2Listener
+        attr_reader :notation_declarations
+        def initialize
+          @notation_declarations = []
+        end
+
+        def notationdecl(*declaration)
+          super
+          @notation_declarations << declaration
+        end
+      end
+
+      private
+      def parse(internal_subset)
+        listener = Listener.new
+        parser = REXML::Parsers::SAX2Parser.new(xml(internal_subset))
+        parser.listen(listener)
+        parser.parse
+        listener.notation_declarations
+      end
+
+      class TestExternlID < self
+        def test_system
+          declaration = ["name", "SYSTEM", nil, "system-literal"]
+          assert_equal([declaration],
+                       parse(<<-INTERNAL_SUBSET))
+<!NOTATION name SYSTEM "system-literal">
+          INTERNAL_SUBSET
+        end
+
+        def test_public
+          declaration = ["name", "PUBLIC", "public-literal", "system-literal"]
+          assert_equal([declaration], parse(<<-INTERNAL_SUBSET))
+<!NOTATION name PUBLIC "public-literal" "system-literal">
+          INTERNAL_SUBSET
+        end
+      end
+
+      class TestPublicID < self
+        def test_literal
+          declaration = ["name", "PUBLIC", "public-literal", nil]
+          assert_equal([declaration],
+                       parse(<<-INTERNAL_SUBSET))
+<!NOTATION name PUBLIC "public-literal">
+          INTERNAL_SUBSET
+        end
+      end
+    end
   end
 end

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

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