summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/maintainers.rdoc6
-rw-r--r--doc/standard_library.rdoc2
-rw-r--r--gems/bundled_gems1
-rw-r--r--lib/rexml/attlistdecl.rb63
-rw-r--r--lib/rexml/attribute.rb205
-rw-r--r--lib/rexml/cdata.rb68
-rw-r--r--lib/rexml/child.rb97
-rw-r--r--lib/rexml/comment.rb80
-rw-r--r--lib/rexml/doctype.rb287
-rw-r--r--lib/rexml/document.rb291
-rw-r--r--lib/rexml/dtd/attlistdecl.rb11
-rw-r--r--lib/rexml/dtd/dtd.rb47
-rw-r--r--lib/rexml/dtd/elementdecl.rb18
-rw-r--r--lib/rexml/dtd/entitydecl.rb57
-rw-r--r--lib/rexml/dtd/notationdecl.rb40
-rw-r--r--lib/rexml/element.rb1269
-rw-r--r--lib/rexml/encoding.rb51
-rw-r--r--lib/rexml/entity.rb171
-rw-r--r--lib/rexml/formatters/default.rb116
-rw-r--r--lib/rexml/formatters/pretty.rb142
-rw-r--r--lib/rexml/formatters/transitive.rb58
-rw-r--r--lib/rexml/functions.rb447
-rw-r--r--lib/rexml/instruction.rb79
-rw-r--r--lib/rexml/light/node.rb196
-rw-r--r--lib/rexml/namespace.rb59
-rw-r--r--lib/rexml/node.rb76
-rw-r--r--lib/rexml/output.rb30
-rw-r--r--lib/rexml/parent.rb166
-rw-r--r--lib/rexml/parseexception.rb52
-rw-r--r--lib/rexml/parsers/baseparser.rb594
-rw-r--r--lib/rexml/parsers/lightparser.rb59
-rw-r--r--lib/rexml/parsers/pullparser.rb197
-rw-r--r--lib/rexml/parsers/sax2parser.rb273
-rw-r--r--lib/rexml/parsers/streamparser.rb61
-rw-r--r--lib/rexml/parsers/treeparser.rb101
-rw-r--r--lib/rexml/parsers/ultralightparser.rb57
-rw-r--r--lib/rexml/parsers/xpathparser.rb675
-rw-r--r--lib/rexml/quickpath.rb266
-rw-r--r--lib/rexml/rexml.gemspec84
-rw-r--r--lib/rexml/rexml.rb32
-rw-r--r--lib/rexml/sax2listener.rb98
-rw-r--r--lib/rexml/security.rb28
-rw-r--r--lib/rexml/source.rb298
-rw-r--r--lib/rexml/streamlistener.rb93
-rw-r--r--lib/rexml/text.rb424
-rw-r--r--lib/rexml/undefinednamespaceexception.rb9
-rw-r--r--lib/rexml/validation/relaxng.rb539
-rw-r--r--lib/rexml/validation/validation.rb144
-rw-r--r--lib/rexml/validation/validationexception.rb10
-rw-r--r--lib/rexml/xmldecl.rb130
-rw-r--r--lib/rexml/xmltokens.rb85
-rw-r--r--lib/rexml/xpath.rb81
-rw-r--r--lib/rexml/xpath_parser.rb968
-rw-r--r--test/rexml/data/LostineRiver.kml.gzbin50154 -> 0 bytes
-rw-r--r--test/rexml/data/ProductionSupport.xml29
-rw-r--r--test/rexml/data/axis.xml25
-rw-r--r--test/rexml/data/bad.xml5
-rw-r--r--test/rexml/data/basic.xml11
-rw-r--r--test/rexml/data/basicupdate.xml47
-rw-r--r--test/rexml/data/broken.rss20
-rw-r--r--test/rexml/data/contents.xml70
-rw-r--r--test/rexml/data/dash.xml12
-rw-r--r--test/rexml/data/defaultNamespace.xml6
-rw-r--r--test/rexml/data/doctype_test.xml34
-rw-r--r--test/rexml/data/documentation.xml542
-rw-r--r--test/rexml/data/euc.xml296
-rw-r--r--test/rexml/data/evaluate.xml28
-rw-r--r--test/rexml/data/fibo.xml29
-rw-r--r--test/rexml/data/foo.xml10
-rw-r--r--test/rexml/data/google.2.xml156
-rw-r--r--test/rexml/data/id.xml21
-rw-r--r--test/rexml/data/iso8859-1.xml4
-rw-r--r--test/rexml/data/jaxen24.xml2
-rw-r--r--test/rexml/data/jaxen3.xml15
-rw-r--r--test/rexml/data/lang.xml11
-rw-r--r--test/rexml/data/lang0.xml18
-rw-r--r--test/rexml/data/message.xml27
-rw-r--r--test/rexml/data/moreover.xml244
-rw-r--r--test/rexml/data/much_ado.xml6850
-rw-r--r--test/rexml/data/namespaces.xml18
-rw-r--r--test/rexml/data/nitf.xml67
-rw-r--r--test/rexml/data/numbers.xml18
-rw-r--r--test/rexml/data/ofbiz-issues-full-177.xml13971
-rw-r--r--test/rexml/data/pi.xml13
-rw-r--r--test/rexml/data/pi2.xml6
-rw-r--r--test/rexml/data/project.xml1
-rw-r--r--test/rexml/data/simple.xml2
-rw-r--r--test/rexml/data/stream_accents.xml4
-rw-r--r--test/rexml/data/t63-1.xmlbin161690 -> 0 bytes
-rw-r--r--test/rexml/data/t63-2.svg2828
-rw-r--r--test/rexml/data/t75.xml31
-rw-r--r--test/rexml/data/test/tests.xml683
-rw-r--r--test/rexml/data/test/tests.xsl369
-rw-r--r--test/rexml/data/testNamespaces.xml22
-rw-r--r--test/rexml/data/testsrc.xml64
-rw-r--r--test/rexml/data/text.xml10
-rw-r--r--test/rexml/data/ticket_61.xml4
-rw-r--r--test/rexml/data/ticket_68.xml590
-rw-r--r--test/rexml/data/tutorial.xml678
-rw-r--r--test/rexml/data/underscore.xml6
-rw-r--r--test/rexml/data/utf16.xmlbin207464 -> 0 bytes
-rw-r--r--test/rexml/data/web.xml42
-rw-r--r--test/rexml/data/web2.xml7
-rw-r--r--test/rexml/data/working.rss202
-rw-r--r--test/rexml/data/xmlfile-bug.xml15
-rw-r--r--test/rexml/data/xp.tst27
-rw-r--r--test/rexml/data/yahoo.xml80
-rw-r--r--test/rexml/formatter/test_default.rb19
-rw-r--r--test/rexml/functions/test_base.rb261
-rw-r--r--test/rexml/functions/test_boolean.rb75
-rw-r--r--test/rexml/functions/test_local_name.rb44
-rw-r--r--test/rexml/functions/test_number.rb38
-rw-r--r--test/rexml/listener.rb51
-rw-r--r--test/rexml/parse/test_document_type_declaration.rb50
-rw-r--r--test/rexml/parse/test_element.rb51
-rw-r--r--test/rexml/parse/test_notation_declaration.rb100
-rw-r--r--test/rexml/parse/test_processing_instruction.rb25
-rw-r--r--test/rexml/parser/test_sax2.rb203
-rw-r--r--test/rexml/parser/test_stream.rb32
-rw-r--r--test/rexml/parser/test_tree.rb43
-rw-r--r--test/rexml/parser/test_ultra_light.rb70
-rw-r--r--test/rexml/rexml_test_utils.rb10
-rw-r--r--test/rexml/test_attribute.rb14
-rw-r--r--test/rexml/test_attributes.rb223
-rw-r--r--test/rexml/test_attributes_mixin.rb32
-rw-r--r--test/rexml/test_changing_encoding.rb45
-rw-r--r--test/rexml/test_comment.rb26
-rw-r--r--test/rexml/test_contrib.rb585
-rw-r--r--test/rexml/test_core.rb1517
-rw-r--r--test/rexml/test_doctype.rb157
-rw-r--r--test/rexml/test_document.rb416
-rw-r--r--test/rexml/test_element.rb18
-rw-r--r--test/rexml/test_elements.rb119
-rw-r--r--test/rexml/test_encoding.rb108
-rw-r--r--test/rexml/test_entity.rb206
-rw-r--r--test/rexml/test_instruction.rb14
-rw-r--r--test/rexml/test_jaxen.rb131
-rw-r--r--test/rexml/test_light.rb107
-rw-r--r--test/rexml/test_lightparser.rb16
-rw-r--r--test/rexml/test_listener.rb131
-rw-r--r--test/rexml/test_martin_fowler.rb40
-rw-r--r--test/rexml/test_namespace.rb41
-rw-r--r--test/rexml/test_order.rb110
-rw-r--r--test/rexml/test_preceding_sibling.rb41
-rw-r--r--test/rexml/test_pullparser.rb103
-rw-r--r--test/rexml/test_rexml_issuezilla.rb19
-rw-r--r--test/rexml/test_sax.rb287
-rw-r--r--test/rexml/test_stream.rb130
-rw-r--r--test/rexml/test_text.rb75
-rw-r--r--test/rexml/test_ticket_80.rb59
-rw-r--r--test/rexml/test_validation_rng.rb793
-rw-r--r--test/rexml/test_xml_declaration.rb48
-rw-r--r--test/rexml/xpath/test_attribute.rb38
-rw-r--r--test/rexml/xpath/test_axis_preceding_sibling.rb40
-rw-r--r--test/rexml/xpath/test_base.rb1125
-rw-r--r--test/rexml/xpath/test_compare.rb256
-rw-r--r--test/rexml/xpath/test_node.rb43
-rw-r--r--test/rexml/xpath/test_predicate.rb83
-rw-r--r--test/rexml/xpath/test_text.rb77
-rw-r--r--tool/sync_default_gems.rb2
160 files changed, 4 insertions, 46104 deletions
diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc
index 071c958d30e..c8b4f9af20b 100644
--- a/doc/maintainers.rdoc
+++ b/doc/maintainers.rdoc
@@ -239,10 +239,6 @@ Zachary Scott (zzak)
aycabta
https://github.com/ruby/reline
https://rubygems.org/gems/reline
-[lib/rexml/*]
- Kouhei Sutou (kou)
- https://github.com/ruby/rexml
- https://rubygems.org/gems/rexml
[lib/rss.rb, lib/rss/*]
Kouhei Sutou (kou)
https://github.com/ruby/rss
@@ -357,3 +353,5 @@ Zachary Scott (zzak)
https://github.com/test-unit/test-unit
[xmlrpc]
https://github.com/ruby/xmlrpc
+[rexml]
+ https://github.com/ruby/rexml
diff --git a/doc/standard_library.rdoc b/doc/standard_library.rdoc
index f71cedebf7f..82dda4b532f 100644
--- a/doc/standard_library.rdoc
+++ b/doc/standard_library.rdoc
@@ -80,7 +80,6 @@ Prime:: Prime numbers and factorization library
PStore:: Implements a file based persistence mechanism based on a Hash
Racc:: A LALR(1) parser generator written in Ruby.
RDoc:: Produces HTML and command-line documentation for Ruby
-REXML:: An XML toolkit for Ruby
RSS:: Family of libraries that support various formats of XML "feeds"
Singleton:: Implementation of the Singleton pattern for Ruby
Timeout:: Auto-terminate potentially long-running operations in Ruby
@@ -119,3 +118,4 @@ PowerAssert:: Power Assert for Ruby.
Rake:: Ruby build program with capabilities similar to make
Test::Unit:: A compatibility layer for MiniTest
XMLRPC:: Remote Procedure Call over HTTP support for Ruby
+REXML:: An XML toolkit for Ruby
diff --git a/gems/bundled_gems b/gems/bundled_gems
index b2c6e2d5cb3..635ff1d1c6d 100644
--- a/gems/bundled_gems
+++ b/gems/bundled_gems
@@ -4,3 +4,4 @@ power_assert 1.1.5 https://github.com/k-tsj/power_assert
rake 13.0.1 https://github.com/ruby/rake
test-unit 3.3.4 https://github.com/test-unit/test-unit
xmlrpc 0.3.0 https://github.com/ruby/xmlrpc
+rexml 3.2.3 https://github.com/ruby/rexml
diff --git a/lib/rexml/attlistdecl.rb b/lib/rexml/attlistdecl.rb
deleted file mode 100644
index 44a91d66d63..00000000000
--- a/lib/rexml/attlistdecl.rb
+++ /dev/null
@@ -1,63 +0,0 @@
-# frozen_string_literal: false
-#vim:ts=2 sw=2 noexpandtab:
-require_relative 'child'
-require_relative 'source'
-
-module REXML
- # This class needs:
- # * Documentation
- # * Work! Not all types of attlists are intelligently parsed, so we just
- # spew back out what we get in. This works, but it would be better if
- # we formatted the output ourselves.
- #
- # AttlistDecls provide *just* enough support to allow namespace
- # declarations. If you need some sort of generalized support, or have an
- # interesting idea about how to map the hideous, terrible design of DTD
- # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate
- # for anything to make DTDs more palateable.
- class AttlistDecl < Child
- include Enumerable
-
- # What is this? Got me.
- attr_reader :element_name
-
- # Create an AttlistDecl, pulling the information from a Source. Notice
- # that this isn't very convenient; to create an AttlistDecl, you basically
- # have to format it yourself, and then have the initializer parse it.
- # Sorry, but for the foreseeable future, DTD support in REXML is pretty
- # weak on convenience. Have I mentioned how much I hate DTDs?
- def initialize(source)
- super()
- if (source.kind_of? Array)
- @element_name, @pairs, @contents = *source
- end
- end
-
- # Access the attlist attribute/value pairs.
- # value = attlist_decl[ attribute_name ]
- def [](key)
- @pairs[key]
- end
-
- # Whether an attlist declaration includes the given attribute definition
- # if attlist_decl.include? "xmlns:foobar"
- def include?(key)
- @pairs.keys.include? key
- end
-
- # Iterate over the key/value pairs:
- # attlist_decl.each { |attribute_name, attribute_value| ... }
- def each(&block)
- @pairs.each(&block)
- end
-
- # Write out exactly what we got in.
- def write out, indent=-1
- out << @contents
- end
-
- def node_type
- :attlistdecl
- end
- end
-end
diff --git a/lib/rexml/attribute.rb b/lib/rexml/attribute.rb
deleted file mode 100644
index 8933a013a25..00000000000
--- a/lib/rexml/attribute.rb
+++ /dev/null
@@ -1,205 +0,0 @@
-# frozen_string_literal: false
-require_relative "namespace"
-require_relative 'text'
-
-module REXML
- # Defines an Element Attribute; IE, a attribute=value pair, as in:
- # <element attribute="value"/>. Attributes can be in their own
- # namespaces. General users of REXML will not interact with the
- # Attribute class much.
- class Attribute
- include Node
- include Namespace
-
- # The element to which this attribute belongs
- attr_reader :element
- # The normalized value of this attribute. That is, the attribute with
- # entities intact.
- attr_writer :normalized
- PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
-
- NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
-
- # Constructor.
- # FIXME: The parser doesn't catch illegal characters in attributes
- #
- # first::
- # Either: an Attribute, which this new attribute will become a
- # clone of; or a String, which is the name of this attribute
- # second::
- # If +first+ is an Attribute, then this may be an Element, or nil.
- # If nil, then the Element parent of this attribute is the parent
- # of the +first+ Attribute. If the first argument is a String,
- # then this must also be a String, and is the content of the attribute.
- # If this is the content, it must be fully normalized (contain no
- # illegal characters).
- # parent::
- # Ignored unless +first+ is a String; otherwise, may be the Element
- # parent of this attribute, or nil.
- #
- #
- # Attribute.new( attribute_to_clone )
- # Attribute.new( attribute_to_clone, parent_element )
- # Attribute.new( "attr", "attr_value" )
- # Attribute.new( "attr", "attr_value", parent_element )
- def initialize( first, second=nil, parent=nil )
- @normalized = @unnormalized = @element = nil
- if first.kind_of? Attribute
- self.name = first.expanded_name
- @unnormalized = first.value
- if second.kind_of? Element
- @element = second
- else
- @element = first.element
- end
- elsif first.kind_of? String
- @element = parent
- self.name = first
- @normalized = second.to_s
- else
- raise "illegal argument #{first.class.name} to Attribute constructor"
- end
- end
-
- # Returns the namespace of the attribute.
- #
- # e = Element.new( "elns:myelement" )
- # e.add_attribute( "nsa:a", "aval" )
- # e.add_attribute( "b", "bval" )
- # e.attributes.get_attribute( "a" ).prefix # -> "nsa"
- # e.attributes.get_attribute( "b" ).prefix # -> ""
- # a = Attribute.new( "x", "y" )
- # a.prefix # -> ""
- def prefix
- super
- end
-
- # Returns the namespace URL, if defined, or nil otherwise
- #
- # e = Element.new("el")
- # e.add_namespace("ns", "http://url")
- # e.add_attribute("ns:a", "b")
- # e.add_attribute("nsx:a", "c")
- # e.attribute("ns:a").namespace # => "http://url"
- # e.attribute("nsx:a").namespace # => nil
- #
- # This method always returns "" for no namespace attribute. Because
- # the default namespace doesn't apply to attribute names.
- #
- # From https://www.w3.org/TR/xml-names/#uniqAttrs
- #
- # > the default namespace does not apply to attribute names
- #
- # e = REXML::Element.new("el")
- # e.add_namespace("", "http://example.com/")
- # e.namespace # => "http://example.com/"
- # e.add_attribute("a", "b")
- # e.attribute("a").namespace # => ""
- def namespace arg=nil
- arg = prefix if arg.nil?
- if arg == ""
- ""
- else
- @element.namespace(arg)
- end
- end
-
- # Returns true if other is an Attribute and has the same name and value,
- # false otherwise.
- def ==( other )
- other.kind_of?(Attribute) and other.name==name and other.value==value
- end
-
- # Creates (and returns) a hash from both the name and value
- def hash
- name.hash + value.hash
- end
-
- # Returns this attribute out as XML source, expanding the name
- #
- # a = Attribute.new( "x", "y" )
- # a.to_string # -> "x='y'"
- # b = Attribute.new( "ns:x", "y" )
- # b.to_string # -> "ns:x='y'"
- def to_string
- if @element and @element.context and @element.context[:attribute_quote] == :quote
- %Q^#@expanded_name="#{to_s().gsub(/"/, '&quot;')}"^
- else
- "#@expanded_name='#{to_s().gsub(/'/, '&apos;')}'"
- end
- end
-
- def doctype
- if @element
- doc = @element.document
- doc.doctype if doc
- end
- end
-
- # Returns the attribute value, with entities replaced
- def to_s
- return @normalized if @normalized
-
- @normalized = Text::normalize( @unnormalized, doctype )
- @unnormalized = nil
- @normalized
- end
-
- # Returns the UNNORMALIZED value of this attribute. That is, entities
- # have been expanded to their values
- def value
- return @unnormalized if @unnormalized
- @unnormalized = Text::unnormalize( @normalized, doctype )
- @normalized = nil
- @unnormalized
- end
-
- # Returns a copy of this attribute
- def clone
- Attribute.new self
- end
-
- # Sets the element of which this object is an attribute. Normally, this
- # is not directly called.
- #
- # Returns this attribute
- def element=( element )
- @element = element
-
- if @normalized
- Text.check( @normalized, NEEDS_A_SECOND_CHECK, doctype )
- end
-
- self
- end
-
- # Removes this Attribute from the tree, and returns true if successful
- #
- # This method is usually not called directly.
- def remove
- @element.attributes.delete self.name unless @element.nil?
- end
-
- # Writes this attribute (EG, puts 'key="value"' to the output)
- def write( output, indent=-1 )
- output << to_string
- end
-
- def node_type
- :attribute
- end
-
- def inspect
- rv = ""
- write( rv )
- rv
- end
-
- def xpath
- path = @element.xpath
- path += "/@#{self.expanded_name}"
- return path
- end
- end
-end
-#vim:ts=2 sw=2 noexpandtab:
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb
deleted file mode 100644
index 997f5a08dbc..00000000000
--- a/lib/rexml/cdata.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# frozen_string_literal: false
-require_relative "text"
-
-module REXML
- class CData < Text
- START = '<![CDATA['
- STOP = ']]>'
- ILLEGAL = /(\]\]>)/
-
- # Constructor. CData is data between <![CDATA[ ... ]]>
- #
- # _Examples_
- # CData.new( source )
- # CData.new( "Here is some CDATA" )
- # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
- def initialize( first, whitespace=true, parent=nil )
- super( first, whitespace, parent, false, true, ILLEGAL )
- end
-
- # Make a copy of this object
- #
- # _Examples_
- # c = CData.new( "Some text" )
- # d = c.clone
- # d.to_s # -> "Some text"
- def clone
- CData.new self
- end
-
- # Returns the content of this CData object
- #
- # _Examples_
- # c = CData.new( "Some text" )
- # c.to_s # -> "Some text"
- def to_s
- @string
- end
-
- def value
- @string
- end
-
- # == DEPRECATED
- # See the rexml/formatters package
- #
- # Generates XML output of this object
- #
- # output::
- # Where to write the string. Defaults to $stdout
- # indent::
- # The amount to indent this node by
- # transitive::
- # Ignored
- # ie_hack::
- # Ignored
- #
- # _Examples_
- # c = CData.new( " Some text " )
- # c.write( $stdout ) #-> <![CDATA[ Some text ]]>
- def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
- Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
- indent( output, indent )
- output << START
- output << @string
- output << STOP
- end
- end
-end
diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb
deleted file mode 100644
index cc6e9a47199..00000000000
--- a/lib/rexml/child.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-# frozen_string_literal: false
-require_relative "node"
-
-module REXML
- ##
- # A Child object is something contained by a parent, and this class
- # contains methods to support that. Most user code will not use this
- # class directly.
- class Child
- include Node
- attr_reader :parent # The Parent of this object
-
- # Constructor. Any inheritors of this class should call super to make
- # sure this method is called.
- # parent::
- # if supplied, the parent of this child will be set to the
- # supplied value, and self will be added to the parent
- def initialize( parent = nil )
- @parent = nil
- # Declare @parent, but don't define it. The next line sets the
- # parent.
- parent.add( self ) if parent
- end
-
- # Replaces this object with another object. Basically, calls
- # Parent.replace_child
- #
- # Returns:: self
- def replace_with( child )
- @parent.replace_child( self, child )
- self
- end
-
- # Removes this child from the parent.
- #
- # Returns:: self
- def remove
- unless @parent.nil?
- @parent.delete self
- end
- self
- end
-
- # Sets the parent of this child to the supplied argument.
- #
- # other::
- # Must be a Parent object. If this object is the same object as the
- # existing parent of this child, no action is taken. Otherwise, this
- # child is removed from the current parent (if one exists), and is added
- # to the new parent.
- # Returns:: The parent added
- def parent=( other )
- return @parent if @parent == other
- @parent.delete self if defined? @parent and @parent
- @parent = other
- end
-
- alias :next_sibling :next_sibling_node
- alias :previous_sibling :previous_sibling_node
-
- # Sets the next sibling of this child. This can be used to insert a child
- # after some other child.
- # a = Element.new("a")
- # b = a.add_element("b")
- # c = Element.new("c")
- # b.next_sibling = c
- # # => <a><b/><c/></a>
- def next_sibling=( other )
- parent.insert_after self, other
- end
-
- # Sets the previous sibling of this child. This can be used to insert a
- # child before some other child.
- # a = Element.new("a")
- # b = a.add_element("b")
- # c = Element.new("c")
- # b.previous_sibling = c
- # # => <a><b/><c/></a>
- def previous_sibling=(other)
- parent.insert_before self, other
- end
-
- # Returns:: the document this child belongs to, or nil if this child
- # belongs to no document
- def document
- return parent.document unless parent.nil?
- nil
- end
-
- # This doesn't yet handle encodings
- def bytes
- document.encoding
-
- to_s
- end
- end
-end
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
deleted file mode 100644
index 52c58b46f6f..00000000000
--- a/lib/rexml/comment.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: false
-require_relative "child"
-
-module REXML
- ##
- # Represents an XML comment; that is, text between \<!-- ... -->
- class Comment < Child
- include Comparable
- START = "<!--"
- STOP = "-->"
-
- # The content text
-
- attr_accessor :string
-
- ##
- # Constructor. The first argument can be one of three types:
- # @param first If String, the contents of this comment are set to the
- # argument. If Comment, the argument is duplicated. If
- # Source, the argument is scanned for a comment.
- # @param second If the first argument is a Source, this argument
- # should be nil, not supplied, or a Parent to be set as the parent
- # of this object
- def initialize( first, second = nil )
- super(second)
- if first.kind_of? String
- @string = first
- elsif first.kind_of? Comment
- @string = first.string
- end
- end
-
- def clone
- Comment.new self
- end
-
- # == DEPRECATED
- # See REXML::Formatters
- #
- # output::
- # Where to write the string
- # indent::
- # An integer. If -1, no indenting will be used; otherwise, the
- # indentation will be this number of spaces, and children will be
- # indented an additional amount.
- # transitive::
- # Ignored by this class. The contents of comments are never modified.
- # ie_hack::
- # Needed for conformity to the child API, but not used by this class.
- def write( output, indent=-1, transitive=false, ie_hack=false )
- Kernel.warn("Comment.write is deprecated. See REXML::Formatters", uplevel: 1)
- indent( output, indent )
- output << START
- output << @string
- output << STOP
- end
-
- alias :to_s :string
-
- ##
- # Compares this Comment to another; the contents of the comment are used
- # in the comparison.
- def <=>(other)
- other.to_s <=> @string
- end
-
- ##
- # Compares this Comment to another; the contents of the comment are used
- # in the comparison.
- def ==( other )
- other.kind_of? Comment and
- (other <=> self) == 0
- end
-
- def node_type
- :comment
- end
- end
-end
-#vim:ts=2 sw=2 noexpandtab:
diff --git a/lib/rexml/doctype.rb b/lib/rexml/doctype.rb
deleted file mode 100644
index 757b639639e..00000000000
--- a/lib/rexml/doctype.rb
+++ /dev/null
@@ -1,287 +0,0 @@
-# frozen_string_literal: false
-require_relative "parent"
-require_relative "parseexception"
-require_relative "namespace"
-require_relative 'entity'
-require_relative 'attlistdecl'
-require_relative 'xmltokens'
-
-module REXML
- # Represents an XML DOCTYPE declaration; that is, the contents of <!DOCTYPE
- # ... >. DOCTYPES can be used to declare the DTD of a document, as well as
- # being used to declare entities used in the document.
- class DocType < Parent
- include XMLTokens
- START = "<!DOCTYPE"
- STOP = ">"
- SYSTEM = "SYSTEM"
- PUBLIC = "PUBLIC"
- DEFAULT_ENTITIES = {
- 'gt'=>EntityConst::GT,
- 'lt'=>EntityConst::LT,
- 'quot'=>EntityConst::QUOT,
- "apos"=>EntityConst::APOS
- }
-
- # name is the name of the doctype
- # external_id is the referenced DTD, if given
- attr_reader :name, :external_id, :entities, :namespaces
-
- # Constructor
- #
- # dt = DocType.new( 'foo', '-//I/Hate/External/IDs' )
- # # <!DOCTYPE foo '-//I/Hate/External/IDs'>
- # dt = DocType.new( doctype_to_clone )
- # # Incomplete. Shallow clone of doctype
- #
- # +Note+ that the constructor:
- #
- # Doctype.new( Source.new( "<!DOCTYPE foo 'bar'>" ) )
- #
- # is _deprecated_. Do not use it. It will probably disappear.
- def initialize( first, parent=nil )
- @entities = DEFAULT_ENTITIES
- @long_name = @uri = nil
- if first.kind_of? String
- super()
- @name = first
- @external_id = parent
- elsif first.kind_of? DocType
- super( parent )
- @name = first.name
- @external_id = first.external_id
- elsif first.kind_of? Array
- super( parent )
- @name = first[0]
- @external_id = first[1]
- @long_name = first[2]
- @uri = first[3]
- elsif first.kind_of? Source
- super( parent )
- parser = Parsers::BaseParser.new( first )
- event = parser.pull
- if event[0] == :start_doctype
- @name, @external_id, @long_name, @uri, = event[1..-1]
- end
- else
- super()
- end
- end
-
- def node_type
- :doctype
- end
-
- def attributes_of element
- rv = []
- each do |child|
- child.each do |key,val|
- rv << Attribute.new(key,val)
- end if child.kind_of? AttlistDecl and child.element_name == element
- end
- rv
- end
-
- def attribute_of element, attribute
- att_decl = find do |child|
- child.kind_of? AttlistDecl and
- child.element_name == element and
- child.include? attribute
- end
- return nil unless att_decl
- att_decl[attribute]
- end
-
- def clone
- DocType.new self
- end
-
- # output::
- # Where to write the string
- # indent::
- # An integer. If -1, no indentation will be used; otherwise, the
- # indentation will be this number of spaces, and children will be
- # indented an additional amount.
- # transitive::
- # Ignored
- # ie_hack::
- # Ignored
- def write( output, indent=0, transitive=false, ie_hack=false )
- f = REXML::Formatters::Default.new
- c = context
- if c and c[:prologue_quote] == :apostrophe
- quote = "'"
- else
- quote = "\""
- end
- indent( output, indent )
- output << START
- output << ' '
- output << @name
- output << " #{@external_id}" if @external_id
- output << " #{quote}#{@long_name}#{quote}" if @long_name
- output << " #{quote}#{@uri}#{quote}" if @uri
- unless @children.empty?
- output << ' ['
- @children.each { |child|
- output << "\n"
- f.write( child, output )
- }
- output << "\n]"
- end
- output << STOP
- end
-
- def context
- if @parent
- @parent.context
- else
- nil
- end
- end
-
- def entity( name )
- @entities[name].unnormalized if @entities[name]
- end
-
- def add child
- super(child)
- @entities = DEFAULT_ENTITIES.clone if @entities == DEFAULT_ENTITIES
- @entities[ child.name ] = child if child.kind_of? Entity
- end
-
- # This method retrieves the public identifier identifying the document's
- # DTD.
- #
- # Method contributed by Henrik Martensson
- def public
- case @external_id
- when "SYSTEM"
- nil
- when "PUBLIC"
- strip_quotes(@long_name)
- end
- end
-
- # This method retrieves the system identifier identifying the document's DTD
- #
- # Method contributed by Henrik Martensson
- def system
- case @external_id
- when "SYSTEM"
- strip_quotes(@long_name)
- when "PUBLIC"
- @uri.kind_of?(String) ? strip_quotes(@uri) : nil
- end
- end
-
- # This method returns a list of notations that have been declared in the
- # _internal_ DTD subset. Notations in the external DTD subset are not
- # listed.
- #
- # Method contributed by Henrik Martensson
- def notations
- children().select {|node| node.kind_of?(REXML::NotationDecl)}
- end
-
- # Retrieves a named notation. Only notations declared in the internal
- # DTD subset can be retrieved.
- #
- # Method contributed by Henrik Martensson
- def notation(name)
- notations.find { |notation_decl|
- notation_decl.name == name
- }
- end
-
- private
-
- # Method contributed by Henrik Martensson
- def strip_quotes(quoted_string)
- quoted_string =~ /^[\'\"].*[\'\"]$/ ?
- quoted_string[1, quoted_string.length-2] :
- quoted_string
- end
- end
-
- # We don't really handle any of these since we're not a validating
- # parser, so we can be pretty dumb about them. All we need to be able
- # to do is spew them back out on a write()
-
- # This is an abstract class. You never use this directly; it serves as a
- # parent class for the specific declarations.
- class Declaration < Child
- def initialize src
- super()
- @string = src
- end
-
- def to_s
- @string+'>'
- end
-
- # == DEPRECATED
- # See REXML::Formatters
- #
- def write( output, indent )
- output << to_s
- end
- end
-
- public
- class ElementDecl < Declaration
- def initialize( src )
- super
- end
- end
-
- class ExternalEntity < Child
- def initialize( src )
- super()
- @entity = src
- end
- def to_s
- @entity
- end
- def write( output, indent )
- output << @entity
- end
- end
-
- class NotationDecl < Child
- attr_accessor :public, :system
- def initialize name, middle, pub, sys
- super(nil)
- @name = name
- @middle = middle
- @public = pub
- @system = sys
- end
-
- def to_s
- c = nil
- c = parent.context if parent
- if c and c[:prologue_quote] == :apostrophe
- quote = "'"
- else
- quote = "\""
- end
- notation = "<!NOTATION #{@name} #{@middle}"
- notation << " #{quote}#{@public}#{quote}" if @public
- notation << " #{quote}#{@system}#{quote}" if @system
- notation << ">"
- notation
- end
-
- def write( output, indent=-1 )
- output << to_s
- end
-
- # This method retrieves the name of the notation.
- #
- # Method contributed by Henrik Martensson
- def name
- @name
- end
- end
-end
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
deleted file mode 100644
index adec2930667..00000000000
--- a/lib/rexml/document.rb
+++ /dev/null
@@ -1,291 +0,0 @@
-# frozen_string_literal: false
-require_relative "security"
-require_relative "element"
-require_relative "xmldecl"
-require_relative "source"
-require_relative "comment"
-require_relative "doctype"
-require_relative "instruction"
-require_relative "rexml"
-require_relative "parseexception"
-require_relative "output"
-require_relative "parsers/baseparser"
-require_relative "parsers/streamparser"
-require_relative "parsers/treeparser"
-
-module REXML
- # Represents a full XML document, including PIs, a doctype, etc. A
- # Document has a single child that can be accessed by root().
- # Note that if you want to have an XML declaration written for a document
- # you create, you must add one; REXML documents do not write a default
- # declaration for you. See |DECLARATION| and |write|.
- class Document < Element
- # A convenient default XML declaration. If you want an XML declaration,
- # the easiest way to add one is mydoc << Document::DECLARATION
- # +DEPRECATED+
- # Use: mydoc << XMLDecl.default
- DECLARATION = XMLDecl.default
-
- # Constructor
- # @param source if supplied, must be a Document, String, or IO.
- # Documents have their context and Element attributes cloned.
- # Strings are expected to be valid XML documents. IOs are expected
- # to be sources of valid XML documents.
- # @param context if supplied, contains the context of the document;
- # this should be a Hash.
- def initialize( source = nil, context = {} )
- @entity_expansion_count = 0
- super()
- @context = context
- return if source.nil?
- if source.kind_of? Document
- @context = source.context
- super source
- else
- build( source )
- end
- end
-
- def node_type
- :document
- end
-
- # Should be obvious
- def clone
- Document.new self
- end
-
- # According to the XML spec, a root node has no expanded name
- def expanded_name
- ''
- #d = doc_type
- #d ? d.name : "UNDEFINED"
- end
-
- alias :name :expanded_name
-
- # We override this, because XMLDecls and DocTypes must go at the start
- # of the document
- def add( child )
- if child.kind_of? XMLDecl
- if @children[0].kind_of? XMLDecl
- @children[0] = child
- else
- @children.unshift child
- end
- child.parent = self
- elsif child.kind_of? DocType
- # Find first Element or DocType node and insert the decl right
- # before it. If there is no such node, just insert the child at the
- # end. If there is a child and it is an DocType, then replace it.
- insert_before_index = @children.find_index { |x|
- x.kind_of?(Element) || x.kind_of?(DocType)
- }
- if insert_before_index # Not null = not end of list
- if @children[ insert_before_index ].kind_of? DocType
- @children[ insert_before_index ] = child
- else
- @children[ insert_before_index-1, 0 ] = child
- end
- else # Insert at end of list
- @children << child
- end
- child.parent = self
- else
- rv = super
- raise "attempted adding second root element to document" if @elements.size > 1
- rv
- end
- end
- alias :<< :add
-
- def add_element(arg=nil, arg2=nil)
- rv = super
- raise "attempted adding second root element to document" if @elements.size > 1
- rv
- end
-
- # @return the root Element of the document, or nil if this document
- # has no children.
- def root
- elements[1]
- #self
- #@children.find { |item| item.kind_of? Element }
- end
-
- # @return the DocType child of the document, if one exists,
- # and nil otherwise.
- def doctype
- @children.find { |item| item.kind_of? DocType }
- end
-
- # @return the XMLDecl of this document; if no XMLDecl has been
- # set, the default declaration is returned.
- def xml_decl
- rv = @children[0]
- return rv if rv.kind_of? XMLDecl
- @children.unshift(XMLDecl.default)[0]
- end
-
- # @return the XMLDecl version of this document as a String.
- # If no XMLDecl has been set, returns the default version.
- def version
- xml_decl().version
- end
-
- # @return the XMLDecl encoding of this document as an
- # Encoding object.
- # If no XMLDecl has been set, returns the default encoding.
- def encoding
- xml_decl().encoding
- end
-
- # @return the XMLDecl standalone value of this document as a String.
- # If no XMLDecl has been set, returns the default setting.
- def stand_alone?
- xml_decl().stand_alone?
- end
-
- # :call-seq:
- # doc.write(output=$stdout, indent=-1, transtive=false, ie_hack=false, encoding=nil)
- # doc.write(options={:output => $stdout, :indent => -1, :transtive => false, :ie_hack => false, :encoding => nil})
- #
- # Write the XML tree out, optionally with indent. This writes out the
- # entire XML document, including XML declarations, doctype declarations,
- # and processing instructions (if any are given).
- #
- # A controversial point is whether Document should always write the XML
- # declaration (<?xml version='1.0'?>) whether or not one is given by the
- # user (or source document). REXML does not write one if one was not
- # specified, because it adds unnecessary bandwidth to applications such
- # as XML-RPC.
- #
- # Accept Nth argument style and options Hash style as argument.
- # The recommended style is options Hash style for one or more
- # arguments case.
- #
- # _Examples_
- # Document.new("<a><b/></a>").write
- #
- # output = ""
- # Document.new("<a><b/></a>").write(output)
- #
- # output = ""
- # Document.new("<a><b/></a>").write(:output => output, :indent => 2)
- #
- # See also the classes in the rexml/formatters package for the proper way
- # to change the default formatting of XML output.
- #
- # _Examples_
- #
- # output = ""
- # tr = Transitive.new
- # tr.write(Document.new("<a><b/></a>"), output)
- #
- # output::
- # output an object which supports '<< string'; this is where the
- # document will be written.
- # indent::
- # An integer. If -1, no indenting will be used; otherwise, the
- # indentation will be twice this number of spaces, and children will be
- # indented an additional amount. For a value of 3, every item will be
- # indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1
- # transitive::
- # If transitive is true and indent is >= 0, then the output will be
- # pretty-printed in such a way that the added whitespace does not affect
- # the absolute *value* of the document -- that is, it leaves the value
- # and number of Text nodes in the document unchanged.
- # ie_hack::
- # This hack inserts a space before the /> on empty tags to address
- # a limitation of Internet Explorer. Defaults to false
- # encoding::
- # Encoding name as String. Change output encoding to specified encoding
- # instead of encoding in XML declaration.
- # Defaults to nil. It means encoding in XML declaration is used.
- def write(*arguments)
- if arguments.size == 1 and arguments[0].class == Hash
- options = arguments[0]
-
- output = options[:output]
- indent = options[:indent]
- transitive = options[:transitive]
- ie_hack = options[:ie_hack]
- encoding = options[:encoding]
- else
- output, indent, transitive, ie_hack, encoding, = *arguments
- end
-
- output ||= $stdout
- indent ||= -1
- transitive = false if transitive.nil?
- ie_hack = false if ie_hack.nil?
- encoding ||= xml_decl.encoding
-
- if encoding != 'UTF-8' && !output.kind_of?(Output)
- output = Output.new( output, encoding )
- end
- formatter = if indent > -1
- if transitive
- require_relative "formatters/transitive"
- REXML::Formatters::Transitive.new( indent, ie_hack )
- else
- REXML::Formatters::Pretty.new( indent, ie_hack )
- end
- else
- REXML::Formatters::Default.new( ie_hack )
- end
- formatter.write( self, output )
- end
-
-
- def Document::parse_stream( source, listener )
- Parsers::StreamParser.new( source, listener ).parse
- end
-
- # Set the entity expansion limit. By default the limit is set to 10000.
- #
- # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
- def Document::entity_expansion_limit=( val )
- Security.entity_expansion_limit = val
- end
-
- # Get the entity expansion limit. By default the limit is set to 10000.
- #
- # Deprecated. Use REXML::Security.entity_expansion_limit= instead.
- def Document::entity_expansion_limit
- return Security.entity_expansion_limit
- end
-
- # Set the entity expansion limit. By default the limit is set to 10240.
- #
- # Deprecated. Use REXML::Security.entity_expansion_text_limit= instead.
- def Document::entity_expansion_text_limit=( val )
- Security.entity_expansion_text_limit = val
- end
-
- # Get the entity expansion limit. By default the limit is set to 10240.
- #
- # Deprecated. Use REXML::Security.entity_expansion_text_limit instead.
- def Document::entity_expansion_text_limit
- return Security.entity_expansion_text_limit
- end
-
- attr_reader :entity_expansion_count
-
- def record_entity_expansion
- @entity_expansion_count += 1
- if @entity_expansion_count > Security.entity_expansion_limit
- raise "number of entity expansions exceeded, processing aborted."
- end
- end
-
- def document
- self
- end
-
- private
- def build( source )
- Parsers::TreeParser.new( source, self ).parse
- end
- end
-end
diff --git a/lib/rexml/dtd/attlistdecl.rb b/lib/rexml/dtd/attlistdecl.rb
deleted file mode 100644
index 1326cb21e4c..00000000000
--- a/lib/rexml/dtd/attlistdecl.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: false
-require_relative "../child"
-module REXML
- module DTD
- class AttlistDecl < Child
- START = "<!ATTLIST"
- START_RE = /^\s*#{START}/um
- PATTERN_RE = /\s*(#{START}.*?>)/um
- end
- end
-end
diff --git a/lib/rexml/dtd/dtd.rb b/lib/rexml/dtd/dtd.rb
deleted file mode 100644
index 8b0f2d753af..00000000000
--- a/lib/rexml/dtd/dtd.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: false
-require_relative "elementdecl"
-require_relative "entitydecl"
-require_relative "../comment"
-require_relative "notationdecl"
-require_relative "attlistdecl"
-require_relative "../parent"
-
-module REXML
- module DTD
- class Parser
- def Parser.parse( input )
- case input
- when String
- parse_helper input
- when File
- parse_helper input.read
- end
- end
-
- # Takes a String and parses it out
- def Parser.parse_helper( input )
- contents = Parent.new
- while input.size > 0
- case input
- when ElementDecl.PATTERN_RE
- match = $&
- contents << ElementDecl.new( match )
- when AttlistDecl.PATTERN_RE
- matchdata = $~
- contents << AttlistDecl.new( matchdata )
- when EntityDecl.PATTERN_RE
- matchdata = $~
- contents << EntityDecl.new( matchdata )
- when Comment.PATTERN_RE
- matchdata = $~
- contents << Comment.new( matchdata )
- when NotationDecl.PATTERN_RE
- matchdata = $~
- contents << NotationDecl.new( matchdata )
- end
- end
- contents
- end
- end
- end
-end
diff --git a/lib/rexml/dtd/elementdecl.rb b/lib/rexml/dtd/elementdecl.rb
deleted file mode 100644
index 20ed0232441..00000000000
--- a/lib/rexml/dtd/elementdecl.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: false
-require_relative "../child"
-module REXML
- module DTD
- class ElementDecl < Child
- START = "<!ELEMENT"
- START_RE = /^\s*#{START}/um
- # PATTERN_RE = /^\s*(#{START}.*?)>/um
- PATTERN_RE = /^\s*#{START}\s+((?:[:\w][-\.\w]*:)?[-!\*\.\w]*)(.*?)>/
- #\s*((((["']).*?\5)|[^\/'">]*)*?)(\/)?>/um, true)
-
- def initialize match
- @name = match[1]
- @rest = match[2]
- end
- end
- end
-end
diff --git a/lib/rexml/dtd/entitydecl.rb b/lib/rexml/dtd/entitydecl.rb
deleted file mode 100644
index 312df655ff2..00000000000
--- a/lib/rexml/dtd/entitydecl.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: false
-require_relative "../child"
-module REXML
- module DTD
- class EntityDecl < Child
- START = "<!ENTITY"
- START_RE = /^\s*#{START}/um
- PUBLIC = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+PUBLIC\s+((["']).*?\3)\s+((["']).*?\5)\s*>/um
- SYSTEM = /^\s*#{START}\s+(?:%\s+)?(\w+)\s+SYSTEM\s+((["']).*?\3)(?:\s+NDATA\s+\w+)?\s*>/um
- PLAIN = /^\s*#{START}\s+(\w+)\s+((["']).*?\3)\s*>/um
- PERCENT = /^\s*#{START}\s+%\s+(\w+)\s+((["']).*?\3)\s*>/um
- # <!ENTITY name SYSTEM "...">
- # <!ENTITY name "...">
- def initialize src
- super()
- md = nil
- if src.match( PUBLIC )
- md = src.match( PUBLIC, true )
- @middle = "PUBLIC"
- @content = "#{md[2]} #{md[4]}"
- elsif src.match( SYSTEM )
- md = src.match( SYSTEM, true )
- @middle = "SYSTEM"
- @content = md[2]
- elsif src.match( PLAIN )
- md = src.match( PLAIN, true )
- @middle = ""
- @content = md[2]
- elsif src.match( PERCENT )
- md = src.match( PERCENT, true )
- @middle = ""
- @content = md[2]
- end
- raise ParseException.new("failed Entity match", src) if md.nil?
- @name = md[1]
- end
-
- def to_s
- rv = "<!ENTITY #@name "
- rv << "#@middle " if @middle.size > 0
- rv << @content
- rv
- end
-
- def write( output, indent )
- indent( output, indent )
- output << to_s
- end
-
- def EntityDecl.parse_source source, listener
- md = source.match( PATTERN_RE, true )
- thing = md[0].squeeze(" \t\n\r")
- listener.send inspect.downcase, thing
- end
- end
- end
-end
diff --git a/lib/rexml/dtd/notationdecl.rb b/lib/rexml/dtd/notationdecl.rb
deleted file mode 100644
index 04a9b08aa7d..00000000000
--- a/lib/rexml/dtd/notationdecl.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# frozen_string_literal: false
-require_relative "../child"
-module REXML
- module DTD
- class NotationDecl < Child
- START = "<!NOTATION"
- START_RE = /^\s*#{START}/um
- PUBLIC = /^\s*#{START}\s+(\w[\w-]*)\s+(PUBLIC)\s+((["']).*?\4)\s*>/um
- SYSTEM = /^\s*#{START}\s+(\w[\w-]*)\s+(SYSTEM)\s+((["']).*?\4)\s*>/um
- def initialize src
- super()
- if src.match( PUBLIC )
- md = src.match( PUBLIC, true )
- elsif src.match( SYSTEM )
- md = src.match( SYSTEM, true )
- else
- raise ParseException.new( "error parsing notation: no matching pattern", src )
- end
- @name = md[1]
- @middle = md[2]
- @rest = md[3]
- end
-
- def to_s
- "<!NOTATION #@name #@middle #@rest>"
- end
-
- def write( output, indent )
- indent( output, indent )
- output << to_s
- end
-
- def NotationDecl.parse_source source, listener
- md = source.match( PATTERN_RE, true )
- thing = md[0].squeeze(" \t\n\r")
- listener.send inspect.downcase, thing
- end
- end
- end
-end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
deleted file mode 100644
index c706a7c2457..00000000000
--- a/lib/rexml/element.rb
+++ /dev/null
@@ -1,1269 +0,0 @@
-# frozen_string_literal: false
-require_relative "parent"
-require_relative "namespace"
-require_relative "attribute"
-require_relative "cdata"
-require_relative "xpath"
-require_relative "parseexception"
-
-module REXML
- # An implementation note about namespaces:
- # As we parse, when we find namespaces we put them in a hash and assign
- # them a unique ID. We then convert the namespace prefix for the node
- # to the unique ID. This makes namespace lookup much faster for the
- # cost of extra memory use. We save the namespace prefix for the
- # context node and convert it back when we write it.
- @@namespaces = {}
-
- # Represents a tagged XML element. Elements are characterized by
- # having children, attributes, and names, and can themselves be
- # children.
- class Element < Parent
- include Namespace
-
- UNDEFINED = "UNDEFINED"; # The default name
-
- # Mechanisms for accessing attributes and child elements of this
- # element.
- attr_reader :attributes, :elements
- # The context holds information about the processing environment, such as
- # whitespace handling.
- attr_accessor :context
-
- # Constructor
- # arg::
- # if not supplied, will be set to the default value.
- # If a String, the name of this object will be set to the argument.
- # If an Element, the object will be shallowly cloned; name,
- # attributes, and namespaces will be copied. Children will +not+ be
- # copied.
- # parent::
- # if supplied, must be a Parent, and will be used as
- # the parent of this object.
- # context::
- # If supplied, must be a hash containing context items. Context items
- # include:
- # * <tt>:respect_whitespace</tt> the value of this is :+all+ or an array of
- # strings being the names of the elements to respect
- # whitespace for. Defaults to :+all+.
- # * <tt>:compress_whitespace</tt> the value can be :+all+ or an array of
- # strings being the names of the elements to ignore whitespace on.
- # Overrides :+respect_whitespace+.
- # * <tt>:ignore_whitespace_nodes</tt> the value can be :+all+ or an array
- # of strings being the names of the elements in which to ignore
- # whitespace-only nodes. If this is set, Text nodes which contain only
- # whitespace will not be added to the document tree.
- # * <tt>:raw</tt> can be :+all+, or an array of strings being the names of
- # the elements to process in raw mode. In raw mode, special
- # characters in text is not converted to or from entities.
- def initialize( arg = UNDEFINED, parent=nil, context=nil )
- super(parent)
-
- @elements = Elements.new(self)
- @attributes = Attributes.new(self)
- @context = context
-
- if arg.kind_of? String
- self.name = arg
- elsif arg.kind_of? Element
- self.name = arg.expanded_name
- arg.attributes.each_attribute{ |attribute|
- @attributes << Attribute.new( attribute )
- }
- @context = arg.context
- end
- end
-
- def inspect
- rv = "<#@expanded_name"
-
- @attributes.each_attribute do |attr|
- rv << " "
- attr.write( rv, 0 )
- end
-
- if children.size > 0
- rv << "> ... </>"
- else
- rv << "/>"
- end
- end
-
-
- # Creates a shallow copy of self.
- # d = Document.new "<a><b/><b/><c><d/></c></a>"
- # new_a = d.root.clone
- # puts new_a # => "<a/>"
- def clone
- self.class.new self
- end
-
- # Evaluates to the root node of the document that this element
- # belongs to. If this element doesn't belong to a document, but does
- # belong to another Element, the parent's root will be returned, until the
- # earliest ancestor is found.
- #
- # Note that this is not the same as the document element.
- # In the following example, <a> is the document element, and the root
- # node is the parent node of the document element. You may ask yourself
- # why the root node is useful: consider the doctype and XML declaration,
- # and any processing instructions before the document element... they
- # are children of the root node, or siblings of the document element.
- # The only time this isn't true is when an Element is created that is
- # not part of any Document. In this case, the ancestor that has no
- # parent acts as the root node.
- # d = Document.new '<a><b><c/></b></a>'
- # a = d[1] ; c = a[1][1]
- # d.root_node == d # TRUE
- # a.root_node # namely, d
- # c.root_node # again, d
- def root_node
- parent.nil? ? self : parent.root_node
- end
-
- def root
- return elements[1] if self.kind_of? Document
- return self if parent.kind_of? Document or parent.nil?
- return parent.root
- end
-
- # Evaluates to the document to which this element belongs, or nil if this
- # element doesn't belong to a document.
- def document
- rt = root
- rt.parent if rt
- end
-
- # Evaluates to +true+ if whitespace is respected for this element. This
- # is the case if:
- # 1. Neither :+respect_whitespace+ nor :+compress_whitespace+ has any value
- # 2. The context has :+respect_whitespace+ set to :+all+ or
- # an array containing the name of this element, and
- # :+compress_whitespace+ isn't set to :+all+ or an array containing the
- # name of this element.
- # The evaluation is tested against +expanded_name+, and so is namespace
- # sensitive.
- def whitespace
- @whitespace = nil
- if @context
- if @context[:respect_whitespace]
- @whitespace = (@context[:respect_whitespace] == :all or
- @context[:respect_whitespace].include? expanded_name)
- end
- @whitespace = false if (@context[:compress_whitespace] and
- (@context[:compress_whitespace] == :all or
- @context[:compress_whitespace].include? expanded_name)
- )
- end
- @whitespace = true unless @whitespace == false
- @whitespace
- end
-
- def ignore_whitespace_nodes
- @ignore_whitespace_nodes = false
- if @context
- if @context[:ignore_whitespace_nodes]
- @ignore_whitespace_nodes =
- (@context[:ignore_whitespace_nodes] == :all or
- @context[:ignore_whitespace_nodes].include? expanded_name)
- end
- end
- end
-
- # Evaluates to +true+ if raw mode is set for this element. This
- # is the case if the context has :+raw+ set to :+all+ or
- # an array containing the name of this element.
- #
- # The evaluation is tested against +expanded_name+, and so is namespace
- # sensitive.
- def raw
- @raw = (@context and @context[:raw] and
- (@context[:raw] == :all or
- @context[:raw].include? expanded_name))
- @raw
- end
-
- #once :whitespace, :raw, :ignore_whitespace_nodes
-
- #################################################
- # Namespaces #
- #################################################
-
- # Evaluates to an +Array+ containing the prefixes (names) of all defined
- # namespaces at this context node.
- # doc = Document.new("<a xmlns:x='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
- # doc.elements['//b'].prefixes # -> ['x', 'y']
- def prefixes
- prefixes = []
- prefixes = parent.prefixes if parent
- prefixes |= attributes.prefixes
- return prefixes
- end
-
- def namespaces
- namespaces = {}
- namespaces = parent.namespaces if parent
- namespaces = namespaces.merge( attributes.namespaces )
- return namespaces
- end
-
- # Evaluates to the URI for a prefix, or the empty string if no such
- # namespace is declared for this element. Evaluates recursively for
- # ancestors. Returns the default namespace, if there is one.
- # prefix::
- # the prefix to search for. If not supplied, returns the default
- # namespace if one exists
- # Returns::
- # the namespace URI as a String, or nil if no such namespace
- # exists. If the namespace is undefined, returns an empty string
- # doc = Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
- # b = doc.elements['//b']
- # b.namespace # -> '1'
- # b.namespace("y") # -> '2'
- def namespace(prefix=nil)
- if prefix.nil?
- prefix = prefix()
- end
- if prefix == ''
- prefix = "xmlns"
- else
- prefix = "xmlns:#{prefix}" unless prefix[0,5] == 'xmlns'
- end
- ns = attributes[ prefix ]
- ns = parent.namespace(prefix) if ns.nil? and parent
- ns = '' if ns.nil? and prefix == 'xmlns'
- return ns
- end
-
- # Adds a namespace to this element.
- # prefix::
- # the prefix string, or the namespace URI if +uri+ is not
- # supplied
- # uri::
- # the namespace URI. May be nil, in which +prefix+ is used as
- # the URI
- # Evaluates to: this Element
- # a = Element.new("a")
- # a.add_namespace("xmlns:foo", "bar" )
- # a.add_namespace("foo", "bar") # shorthand for previous line
- # a.add_namespace("twiddle")
- # puts a #-> <a xmlns:foo='bar' xmlns='twiddle'/>
- def add_namespace( prefix, uri=nil )
- unless uri
- @attributes["xmlns"] = prefix
- else
- prefix = "xmlns:#{prefix}" unless prefix =~ /^xmlns:/
- @attributes[ prefix ] = uri
- end
- self
- end
-
- # Removes a namespace from this node. This only works if the namespace is
- # actually declared in this node. If no argument is passed, deletes the
- # default namespace.
- #
- # Evaluates to: this element
- # doc = Document.new "<a xmlns:foo='bar' xmlns='twiddle'/>"
- # doc.root.delete_namespace
- # puts doc # -> <a xmlns:foo='bar'/>
- # doc.root.delete_namespace 'foo'
- # puts doc # -> <a/>
- def delete_namespace namespace="xmlns"
- namespace = "xmlns:#{namespace}" unless namespace == 'xmlns'
- attribute = attributes.get_attribute(namespace)
- attribute.remove unless attribute.nil?
- self
- end
-
- #################################################
- # Elements #
- #################################################
-
- # Adds a child to this element, optionally setting attributes in
- # the element.
- # element::
- # optional. If Element, the element is added.
- # Otherwise, a new Element is constructed with the argument (see
- # Element.initialize).
- # attrs::
- # If supplied, must be a Hash containing String name,value
- # pairs, which will be used to set the attributes of the new Element.
- # Returns:: the Element that was added
- # el = doc.add_element 'my-tag'
- # el = doc.add_element 'my-tag', {'attr1'=>'val1', 'attr2'=>'val2'}
- # el = Element.new 'my-tag'
- # doc.add_element el
- def add_element element, attrs=nil
- raise "First argument must be either an element name, or an Element object" if element.nil?
- el = @elements.add(element)
- attrs.each do |key, value|
- el.attributes[key]=value
- end if attrs.kind_of? Hash
- el
- end
-
- # Deletes a child element.
- # element::
- # Must be an +Element+, +String+, or +Integer+. If Element,
- # the element is removed. If String, the element is found (via XPath)
- # and removed. <em>This means that any parent can remove any
- # descendant.<em> If Integer, the Element indexed by that number will be
- # removed.
- # Returns:: the element that was removed.
- # doc.delete_element "/a/b/c[@id='4']"
- # doc.delete_element doc.elements["//k"]
- # doc.delete_element 1
- def delete_element element
- @elements.delete element
- end
-
- # Evaluates to +true+ if this element has at least one child Element
- # doc = Document.new "<a><b/><c>Text</c></a>"
- # doc.root.has_elements # -> true
- # doc.elements["/a/b"].has_elements # -> false
- # doc.elements["/a/c"].has_elements # -> false
- def has_elements?
- !@elements.empty?
- end
-
- # Iterates through the child elements, yielding for each Element that
- # has a particular attribute set.
- # key::
- # the name of the attribute to search for
- # value::
- # the value of the attribute
- # max::
- # (optional) causes this method to return after yielding
- # for this number of matching children
- # name::
- # (optional) if supplied, this is an XPath that filters
- # the children to check.
- #
- # doc = Document.new "<a><b @id='1'/><c @id='2'/><d @id='1'/><e/></a>"
- # # Yields b, c, d
- # doc.root.each_element_with_attribute( 'id' ) {|e| p e}
- # # Yields b, d
- # doc.root.each_element_with_attribute( 'id', '1' ) {|e| p e}
- # # Yields b
- # doc.root.each_element_with_attribute( 'id', '1', 1 ) {|e| p e}
- # # Yields d
- # doc.root.each_element_with_attribute( 'id', '1', 0, 'd' ) {|e| p e}
- def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element
- each_with_something( proc {|child|
- if value.nil?
- child.attributes[key] != nil
- else
- child.attributes[key]==value
- end
- }, max, name, &block )
- end
-
- # Iterates through the children, yielding for each Element that
- # has a particular text set.
- # text::
- # the text to search for. If nil, or not supplied, will iterate
- # over all +Element+ children that contain at least one +Text+ node.
- # max::
- # (optional) causes this method to return after yielding
- # for this number of matching children
- # name::
- # (optional) if supplied, this is an XPath that filters
- # the children to check.
- #
- # doc = Document.new '<a><b>b</b><c>b</c><d>d</d><e/></a>'
- # # Yields b, c, d
- # doc.each_element_with_text {|e|p e}
- # # Yields b, c
- # doc.each_element_with_text('b'){|e|p e}
- # # Yields b
- # doc.each_element_with_text('b', 1){|e|p e}
- # # Yields d
- # doc.each_element_with_text(nil, 0, 'd'){|e|p e}
- def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
- each_with_something( proc {|child|
- if text.nil?
- child.has_text?
- else
- child.text == text
- end
- }, max, name, &block )
- end
-
- # Synonym for Element.elements.each
- def each_element( xpath=nil, &block ) # :yields: Element
- @elements.each( xpath, &block )
- end
-
- # Synonym for Element.to_a
- # This is a little slower than calling elements.each directly.
- # xpath:: any XPath by which to search for elements in the tree
- # Returns:: an array of Elements that match the supplied path
- def get_elements( xpath )
- @elements.to_a( xpath )
- end
-
- # Returns the next sibling that is an element, or nil if there is
- # no Element sibling after this one
- # doc = Document.new '<a><b/>text<c/></a>'
- # doc.root.elements['b'].next_element #-> <c/>
- # doc.root.elements['c'].next_element #-> nil
- def next_element
- element = next_sibling
- element = element.next_sibling until element.nil? or element.kind_of? Element
- return element
- end
-
- # Returns the previous sibling that is an element, or nil if there is
- # no Element sibling prior to this one
- # doc = Document.new '<a><b/>text<c/></a>'
- # doc.root.elements['c'].previous_element #-> <b/>
- # doc.root.elements['b'].previous_element #-> nil
- def previous_element
- element = previous_sibling
- element = element.previous_sibling until element.nil? or element.kind_of? Element
- return element
- end
-
-
- #################################################
- # Text #
- #################################################
-
- # Evaluates to +true+ if this element has at least one Text child
- def has_text?
- not text().nil?
- end
-
- # A convenience method which returns the String value of the _first_
- # child text element, if one exists, and +nil+ otherwise.
- #
- # <em>Note that an element may have multiple Text elements, perhaps
- # separated by other children</em>. Be aware that this method only returns
- # the first Text node.
- #
- # This method returns the +value+ of the first text child node, which
- # ignores the +raw+ setting, so always returns normalized text. See
- # the Text::value documentation.
- #
- # doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
- # # The element 'p' has two text elements, "some text " and " more text".
- # doc.root.text #-> "some text "
- def text( path = nil )
- rv = get_text(path)
- return rv.value unless rv.nil?
- nil
- end
-
- # Returns the first child Text node, if any, or +nil+ otherwise.
- # This method returns the actual +Text+ node, rather than the String content.
- # doc = Document.new "<p>some text <b>this is bold!</b> more text</p>"
- # # The element 'p' has two text elements, "some text " and " more text".
- # doc.root.get_text.value #-> "some text "
- def get_text path = nil
- rv = nil
- if path
- element = @elements[ path ]
- rv = element.get_text unless element.nil?
- else
- rv = @children.find { |node| node.kind_of? Text }
- end
- return rv
- end
-
- # Sets the first Text child of this object. See text() for a
- # discussion about Text children.
- #
- # If a Text child already exists, the child is replaced by this
- # content. This means that Text content can be deleted by calling
- # this method with a nil argument. In this case, the next Text
- # child becomes the first Text child. In no case is the order of
- # any siblings disturbed.
- # text::
- # If a String, a new Text child is created and added to
- # this Element as the first Text child. If Text, the text is set
- # as the first Child element. If nil, then any existing first Text
- # child is removed.
- # Returns:: this Element.
- # doc = Document.new '<a><b/></a>'
- # doc.root.text = 'Sean' #-> '<a><b/>Sean</a>'
- # doc.root.text = 'Elliott' #-> '<a><b/>Elliott</a>'
- # doc.root.add_element 'c' #-> '<a><b/>Elliott<c/></a>'
- # doc.root.text = 'Russell' #-> '<a><b/>Russell<c/></a>'
- # doc.root.text = nil #-> '<a><b/><c/></a>'
- def text=( text )
- if text.kind_of? String
- text = Text.new( text, whitespace(), nil, raw() )
- elsif !text.nil? and !text.kind_of? Text
- text = Text.new( text.to_s, whitespace(), nil, raw() )
- end
- old_text = get_text
- if text.nil?
- old_text.remove unless old_text.nil?
- else
- if old_text.nil?
- self << text
- else
- old_text.replace_with( text )
- end
- end
- return self
- end
-
- # A helper method to add a Text child. Actual Text instances can
- # be added with regular Parent methods, such as add() and <<()
- # text::
- # if a String, a new Text instance is created and added
- # to the parent. If Text, the object is added directly.
- # Returns:: this Element
- # e = Element.new('a') #-> <e/>
- # e.add_text 'foo' #-> <e>foo</e>
- # e.add_text Text.new(' bar') #-> <e>foo bar</e>
- # Note that at the end of this example, the branch has <b>3</b> nodes; the 'e'
- # element and <b>2</b> Text node children.
- def add_text( text )
- if text.kind_of? String
- if @children[-1].kind_of? Text
- @children[-1] << text
- return
- end
- text = Text.new( text, whitespace(), nil, raw() )
- end
- self << text unless text.nil?
- return self
- end
-
- def node_type
- :element
- end
-
- def xpath
- path_elements = []
- cur = self
- path_elements << __to_xpath_helper( self )
- while cur.parent
- cur = cur.parent
- path_elements << __to_xpath_helper( cur )
- end
- return path_elements.reverse.join( "/" )
- end
-
- #################################################
- # Attributes #
- #################################################
-
- # Fetches an attribute value or a child.
- #
- # If String or Symbol is specified, it's treated as attribute
- # name. Attribute value as String or +nil+ is returned. This case
- # is shortcut of +attributes[name]+.
- #
- # If Integer is specified, it's treated as the index of
- # child. It returns Nth child.
- #
- # doc = REXML::Document.new("<a attr='1'><b/><c/></a>")
- # doc.root["attr"] # => "1"
- # doc.root.attributes["attr"] # => "1"
- # doc.root[1] # => <c/>
- def [](name_or_index)
- case name_or_index
- when String
- attributes[name_or_index]
- when Symbol
- attributes[name_or_index.to_s]
- else
- super
- end
- end
-
- def attribute( name, namespace=nil )
- prefix = nil
- if namespaces.respond_to? :key
- prefix = namespaces.key(namespace) if namespace
- else
- prefix = namespaces.index(namespace) if namespace
- end
- prefix = nil if prefix == 'xmlns'
-
- ret_val =
- attributes.get_attribute( "#{prefix ? prefix + ':' : ''}#{name}" )
-
- return ret_val unless ret_val.nil?
- return nil if prefix.nil?
-
- # now check that prefix'es namespace is not the same as the
- # default namespace
- return nil unless ( namespaces[ prefix ] == namespaces[ 'xmlns' ] )
-
- attributes.get_attribute( name )
-
- end
-
- # Evaluates to +true+ if this element has any attributes set, false
- # otherwise.
- def has_attributes?
- return !@attributes.empty?
- end
-
- # Adds an attribute to this element, overwriting any existing attribute
- # by the same name.
- # key::
- # can be either an Attribute or a String. If an Attribute,
- # the attribute is added to the list of Element attributes. If String,
- # the argument is used as the name of the new attribute, and the value
- # parameter must be supplied.
- # value::
- # Required if +key+ is a String, and ignored if the first argument is
- # an Attribute. This is a String, and is used as the value
- # of the new Attribute. This should be the unnormalized value of the
- # attribute (without entities).
- # Returns:: the Attribute added
- # e = Element.new 'e'
- # e.add_attribute( 'a', 'b' ) #-> <e a='b'/>
- # e.add_attribute( 'x:a', 'c' ) #-> <e a='b' x:a='c'/>
- # e.add_attribute Attribute.new('b', 'd') #-> <e a='b' x:a='c' b='d'/>
- def add_attribute( key, value=nil )
- if key.kind_of? Attribute
- @attributes << key
- else
- @attributes[key] = value
- end
- end
-
- # Add multiple attributes to this element.
- # hash:: is either a hash, or array of arrays
- # el.add_attributes( {"name1"=>"value1", "name2"=>"value2"} )
- # el.add_attributes( [ ["name1","value1"], ["name2"=>"value2"] ] )
- def add_attributes hash
- if hash.kind_of? Hash
- hash.each_pair {|key, value| @attributes[key] = value }
- elsif hash.kind_of? Array
- hash.each { |value| @attributes[ value[0] ] = value[1] }
- end
- end
-
- # Removes an attribute
- # key::
- # either an Attribute or a String. In either case, the
- # attribute is found by matching the attribute name to the argument,
- # and then removed. If no attribute is found, no action is taken.
- # Returns::
- # the attribute removed, or nil if this Element did not contain
- # a matching attribute
- # e = Element.new('E')
- # e.add_attribute( 'name', 'Sean' ) #-> <E name='Sean'/>
- # r = e.add_attribute( 'sur:name', 'Russell' ) #-> <E name='Sean' sur:name='Russell'/>
- # e.delete_attribute( 'name' ) #-> <E sur:name='Russell'/>
- # e.delete_attribute( r ) #-> <E/>
- def delete_attribute(key)
- attr = @attributes.get_attribute(key)
- attr.remove unless attr.nil?
- end
-
- #################################################
- # Other Utilities #
- #################################################
-
- # Get an array of all CData children.
- # IMMUTABLE
- def cdatas
- find_all { |child| child.kind_of? CData }.freeze
- end
-
- # Get an array of all Comment children.
- # IMMUTABLE
- def comments
- find_all { |child| child.kind_of? Comment }.freeze
- end
-
- # Get an array of all Instruction children.
- # IMMUTABLE
- def instructions
- find_all { |child| child.kind_of? Instruction }.freeze
- end
-
- # Get an array of all Text children.
- # IMMUTABLE
- def texts
- find_all { |child| child.kind_of? Text }.freeze
- end
-
- # == DEPRECATED
- # See REXML::Formatters
- #
- # Writes out this element, and recursively, all children.
- # output::
- # output an object which supports '<< string'; this is where the
- # document will be written.
- # indent::
- # An integer. If -1, no indenting will be used; otherwise, the
- # indentation will be this number of spaces, and children will be
- # indented an additional amount. Defaults to -1
- # transitive::
- # If transitive is true and indent is >= 0, then the output will be
- # pretty-printed in such a way that the added whitespace does not affect
- # the parse tree of the document
- # ie_hack::
- # This hack inserts a space before the /> on empty tags to address
- # a limitation of Internet Explorer. Defaults to false
- #
- # out = ''
- # doc.write( out ) #-> doc is written to the string 'out'
- # doc.write( $stdout ) #-> doc written to the console
- def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
- Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters", uplevel: 1)
- formatter = if indent > -1
- if transitive
- require_relative "formatters/transitive"
- REXML::Formatters::Transitive.new( indent, ie_hack )
- else
- REXML::Formatters::Pretty.new( indent, ie_hack )
- end
- else
- REXML::Formatters::Default.new( ie_hack )
- end
- formatter.write( self, output )
- end
-
-
- private
- def __to_xpath_helper node
- rv = node.expanded_name.clone
- if node.parent
- results = node.parent.find_all {|n|
- n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
- }
- if results.length > 1
- idx = results.index( node )
- rv << "[#{idx+1}]"
- end
- end
- rv
- end
-
- # A private helper method
- def each_with_something( test, max=0, name=nil )
- num = 0
- @elements.each( name ){ |child|
- yield child if test.call(child) and num += 1
- return if max>0 and num == max
- }
- end
- end
-
- ########################################################################
- # ELEMENTS #
- ########################################################################
-
- # A class which provides filtering of children for Elements, and
- # XPath search support. You are expected to only encounter this class as
- # the <tt>element.elements</tt> object. Therefore, you are
- # _not_ expected to instantiate this yourself.
- class Elements
- include Enumerable
- # Constructor
- # parent:: the parent Element
- def initialize parent
- @element = parent
- end
-
- # Fetches a child element. Filters only Element children, regardless of
- # the XPath match.
- # index::
- # the search parameter. This is either an Integer, which
- # will be used to find the index'th child Element, or an XPath,
- # which will be used to search for the Element. <em>Because
- # of the nature of XPath searches, any element in the connected XML
- # document can be fetched through any other element.</em> <b>The
- # Integer index is 1-based, not 0-based.</b> This means that the first
- # child element is at index 1, not 0, and the +n+th element is at index
- # +n+, not <tt>n-1</tt>. This is because XPath indexes element children
- # starting from 1, not 0, and the indexes should be the same.
- # name::
- # optional, and only used in the first argument is an
- # Integer. In that case, the index'th child Element that has the
- # supplied name will be returned. Note again that the indexes start at 1.
- # Returns:: the first matching Element, or nil if no child matched
- # doc = Document.new '<a><b/><c id="1"/><c id="2"/><d/></a>'
- # doc.root.elements[1] #-> <b/>
- # doc.root.elements['c'] #-> <c id="1"/>
- # doc.root.elements[2,'c'] #-> <c id="2"/>
- def []( index, name=nil)
- if index.kind_of? Integer
- raise "index (#{index}) must be >= 1" if index < 1
- name = literalize(name) if name
- num = 0
- @element.find { |child|
- child.kind_of? Element and
- (name.nil? ? true : child.has_name?( name )) and
- (num += 1) == index
- }
- else
- return XPath::first( @element, index )
- #{ |element|
- # return element if element.kind_of? Element
- #}
- #return nil
- end
- end
-
- # Sets an element, replacing any previous matching element. If no
- # existing element is found ,the element is added.
- # index:: Used to find a matching element to replace. See []().
- # element::
- # The element to replace the existing element with
- # the previous element
- # Returns:: nil if no previous element was found.
- #
- # doc = Document.new '<a/>'
- # doc.root.elements[10] = Element.new('b') #-> <a><b/></a>
- # doc.root.elements[1] #-> <b/>
- # doc.root.elements[1] = Element.new('c') #-> <a><c/></a>
- # doc.root.elements['c'] = Element.new('d') #-> <a><d/></a>
- def []=( index, element )
- previous = self[index]
- if previous.nil?
- @element.add element
- else
- previous.replace_with element
- end
- return previous
- end
-
- # Returns +true+ if there are no +Element+ children, +false+ otherwise
- def empty?
- @element.find{ |child| child.kind_of? Element}.nil?
- end
-
- # Returns the index of the supplied child (starting at 1), or -1 if
- # the element is not a child
- # element:: an +Element+ child
- def index element
- rv = 0
- found = @element.find do |child|
- child.kind_of? Element and
- (rv += 1) and
- child == element
- end
- return rv if found == element
- return -1
- end
-
- # Deletes a child Element
- # element::
- # Either an Element, which is removed directly; an
- # xpath, where the first matching child is removed; or an Integer,
- # where the n'th Element is removed.
- # Returns:: the removed child
- # doc = Document.new '<a><b/><c/><c id="1"/></a>'
- # b = doc.root.elements[1]
- # doc.root.elements.delete b #-> <a><c/><c id="1"/></a>
- # doc.elements.delete("a/c[@id='1']") #-> <a><c/></a>
- # doc.root.elements.delete 1 #-> <a/>
- def delete element
- if element.kind_of? Element
- @element.delete element
- else
- el = self[element]
- el.remove if el
- end
- end
-
- # Removes multiple elements. Filters for Element children, regardless of
- # XPath matching.
- # xpath:: all elements matching this String path are removed.
- # Returns:: an Array of Elements that have been removed
- # doc = Document.new '<a><c/><c/><c/><c/></a>'
- # deleted = doc.elements.delete_all 'a/c' #-> [<c/>, <c/>, <c/>, <c/>]
- def delete_all( xpath )
- rv = []
- XPath::each( @element, xpath) {|element|
- rv << element if element.kind_of? Element
- }
- rv.each do |element|
- @element.delete element
- element.remove
- end
- return rv
- end
-
- # Adds an element
- # element::
- # if supplied, is either an Element, String, or
- # Source (see Element.initialize). If not supplied or nil, a
- # new, default Element will be constructed
- # Returns:: the added Element
- # a = Element.new('a')
- # a.elements.add(Element.new('b')) #-> <a><b/></a>
- # a.elements.add('c') #-> <a><b/><c/></a>
- def add element=nil
- if element.nil?
- Element.new("", self, @element.context)
- elsif not element.kind_of?(Element)
- Element.new(element, self, @element.context)
- else
- @element << element
- element.context = @element.context
- element
- end
- end
-
- alias :<< :add
-
- # Iterates through all of the child Elements, optionally filtering
- # them by a given XPath
- # xpath::
- # optional. If supplied, this is a String XPath, and is used to
- # filter the children, so that only matching children are yielded. Note
- # that XPaths are automatically filtered for Elements, so that
- # non-Element children will not be yielded
- # doc = Document.new '<a><b/><c/><d/>sean<b/><c/><d/></a>'
- # doc.root.elements.each {|e|p e} #-> Yields b, c, d, b, c, d elements
- # doc.root.elements.each('b') {|e|p e} #-> Yields b, b elements
- # doc.root.elements.each('child::node()') {|e|p e}
- # #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/>
- # XPath.each(doc.root, 'child::node()', &block)
- # #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>
- def each( xpath=nil )
- XPath::each( @element, xpath ) {|e| yield e if e.kind_of? Element }
- end
-
- def collect( xpath=nil )
- collection = []
- XPath::each( @element, xpath ) {|e|
- collection << yield(e) if e.kind_of?(Element)
- }
- collection
- end
-
- def inject( xpath=nil, initial=nil )
- first = true
- XPath::each( @element, xpath ) {|e|
- if (e.kind_of? Element)
- if (first and initial == nil)
- initial = e
- first = false
- else
- initial = yield( initial, e ) if e.kind_of? Element
- end
- end
- }
- initial
- end
-
- # Returns the number of +Element+ children of the parent object.
- # doc = Document.new '<a>sean<b/>elliott<b/>russell<b/></a>'
- # doc.root.size #-> 6, 3 element and 3 text nodes
- # doc.root.elements.size #-> 3
- def size
- count = 0
- @element.each {|child| count+=1 if child.kind_of? Element }
- count
- end
-
- # Returns an Array of Element children. An XPath may be supplied to
- # filter the children. Only Element children are returned, even if the
- # supplied XPath matches non-Element children.
- # doc = Document.new '<a>sean<b/>elliott<c/></a>'
- # doc.root.elements.to_a #-> [ <b/>, <c/> ]
- # doc.root.elements.to_a("child::node()") #-> [ <b/>, <c/> ]
- # XPath.match(doc.root, "child::node()") #-> [ sean, <b/>, elliott, <c/> ]
- def to_a( xpath=nil )
- rv = XPath.match( @element, xpath )
- return rv.find_all{|e| e.kind_of? Element} if xpath
- rv
- end
-
- private
- # Private helper class. Removes quotes from quoted strings
- def literalize name
- name = name[1..-2] if name[0] == ?' or name[0] == ?" #'
- name
- end
- end
-
- ########################################################################
- # ATTRIBUTES #
- ########################################################################
-
- # A class that defines the set of Attributes of an Element and provides
- # operations for accessing elements in that set.
- class Attributes < Hash
- # Constructor
- # element:: the Element of which this is an Attribute
- def initialize element
- @element = element
- end
-
- # Fetches an attribute value. If you want to get the Attribute itself,
- # use get_attribute()
- # name:: an XPath attribute name. Namespaces are relevant here.
- # Returns::
- # the String value of the matching attribute, or +nil+ if no
- # matching attribute was found. This is the unnormalized value
- # (with entities expanded).
- #
- # doc = Document.new "<a foo:att='1' bar:att='2' att='&lt;'/>"
- # doc.root.attributes['att'] #-> '<'
- # doc.root.attributes['bar:att'] #-> '2'
- def [](name)
- attr = get_attribute(name)
- return attr.value unless attr.nil?
- return nil
- end
-
- def to_a
- enum_for(:each_attribute).to_a
- end
-
- # Returns the number of attributes the owning Element contains.
- # doc = Document "<a x='1' y='2' foo:x='3'/>"
- # doc.root.attributes.length #-> 3
- def length
- c = 0
- each_attribute { c+=1 }
- c
- end
- alias :size :length
-
- # Iterates over the attributes of an Element. Yields actual Attribute
- # nodes, not String values.
- #
- # doc = Document.new '<a x="1" y="2"/>'
- # doc.root.attributes.each_attribute {|attr|
- # p attr.expanded_name+" => "+attr.value
- # }
- def each_attribute # :yields: attribute
- return to_enum(__method__) unless block_given?
- each_value do |val|
- if val.kind_of? Attribute
- yield val
- else
- val.each_value { |atr| yield atr }
- end
- end
- end
-
- # Iterates over each attribute of an Element, yielding the expanded name
- # and value as a pair of Strings.
- #
- # doc = Document.new '<a x="1" y="2"/>'
- # doc.root.attributes.each {|name, value| p name+" => "+value }
- def each
- return to_enum(__method__) unless block_given?
- each_attribute do |attr|
- yield [attr.expanded_name, attr.value]
- end
- end
-
- # Fetches an attribute
- # name::
- # the name by which to search for the attribute. Can be a
- # <tt>prefix:name</tt> namespace name.
- # Returns:: The first matching attribute, or nil if there was none. This
- # value is an Attribute node, not the String value of the attribute.
- # doc = Document.new '<a x:foo="1" foo="2" bar="3"/>'
- # doc.root.attributes.get_attribute("foo").value #-> "2"
- # doc.root.attributes.get_attribute("x:foo").value #-> "1"
- def get_attribute( name )
- attr = fetch( name, nil )
- if attr.nil?
- return nil if name.nil?
- # Look for prefix
- name =~ Namespace::NAMESPLIT
- prefix, n = $1, $2
- if prefix
- attr = fetch( n, nil )
- # check prefix
- if attr == nil
- elsif attr.kind_of? Attribute
- return attr if prefix == attr.prefix
- else
- attr = attr[ prefix ]
- return attr
- end
- end
- element_document = @element.document
- if element_document and element_document.doctype
- expn = @element.expanded_name
- expn = element_document.doctype.name if expn.size == 0
- attr_val = element_document.doctype.attribute_of(expn, name)
- return Attribute.new( name, attr_val ) if attr_val
- end
- return nil
- end
- if attr.kind_of? Hash
- attr = attr[ @element.prefix ]
- end
- return attr
- end
-
- # Sets an attribute, overwriting any existing attribute value by the
- # same name. Namespace is significant.
- # name:: the name of the attribute
- # value::
- # (optional) If supplied, the value of the attribute. If
- # nil, any existing matching attribute is deleted.
- # Returns::
- # Owning element
- # doc = Document.new "<a x:foo='1' foo='3'/>"
- # doc.root.attributes['y:foo'] = '2'
- # doc.root.attributes['foo'] = '4'
- # doc.root.attributes['x:foo'] = nil
- def []=( name, value )
- if value.nil? # Delete the named attribute
- attr = get_attribute(name)
- delete attr
- return
- end
-
- unless value.kind_of? Attribute
- if @element.document and @element.document.doctype
- value = Text::normalize( value, @element.document.doctype )
- else
- value = Text::normalize( value, nil )
- end
- value = Attribute.new(name, value)
- end
- value.element = @element
- old_attr = fetch(value.name, nil)
- if old_attr.nil?
- store(value.name, value)
- elsif old_attr.kind_of? Hash
- old_attr[value.prefix] = value
- elsif old_attr.prefix != value.prefix
- # Check for conflicting namespaces
- if value.prefix != "xmlns" and old_attr.prefix != "xmlns"
- old_namespace = old_attr.namespace
- new_namespace = value.namespace
- if old_namespace == new_namespace
- raise ParseException.new(
- "Namespace conflict in adding attribute \"#{value.name}\": "+
- "Prefix \"#{old_attr.prefix}\" = \"#{old_namespace}\" and "+
- "prefix \"#{value.prefix}\" = \"#{new_namespace}\"")
- end
- end
- store value.name, {old_attr.prefix => old_attr,
- value.prefix => value}
- else
- store value.name, value
- end
- return @element
- end
-
- # Returns an array of Strings containing all of the prefixes declared
- # by this set of # attributes. The array does not include the default
- # namespace declaration, if one exists.
- # doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
- # "z='glorp' p:k='gru'/>")
- # prefixes = doc.root.attributes.prefixes #-> ['x', 'y']
- def prefixes
- ns = []
- each_attribute do |attribute|
- ns << attribute.name if attribute.prefix == 'xmlns'
- end
- if @element.document and @element.document.doctype
- expn = @element.expanded_name
- expn = @element.document.doctype.name if expn.size == 0
- @element.document.doctype.attributes_of(expn).each {
- |attribute|
- ns << attribute.name if attribute.prefix == 'xmlns'
- }
- end
- ns
- end
-
- def namespaces
- namespaces = {}
- each_attribute do |attribute|
- namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
- end
- if @element.document and @element.document.doctype
- expn = @element.expanded_name
- expn = @element.document.doctype.name if expn.size == 0
- @element.document.doctype.attributes_of(expn).each {
- |attribute|
- namespaces[attribute.name] = attribute.value if attribute.prefix == 'xmlns' or attribute.name == 'xmlns'
- }
- end
- namespaces
- end
-
- # Removes an attribute
- # attribute::
- # either a String, which is the name of the attribute to remove --
- # namespaces are significant here -- or the attribute to remove.
- # Returns:: the owning element
- # doc = Document.new "<a y:foo='0' x:foo='1' foo='3' z:foo='4'/>"
- # doc.root.attributes.delete 'foo' #-> <a y:foo='0' x:foo='1' z:foo='4'/>"
- # doc.root.attributes.delete 'x:foo' #-> <a y:foo='0' z:foo='4'/>"
- # attr = doc.root.attributes.get_attribute('y:foo')
- # doc.root.attributes.delete attr #-> <a z:foo='4'/>"
- def delete( attribute )
- name = nil
- prefix = nil
- if attribute.kind_of? Attribute
- name = attribute.name
- prefix = attribute.prefix
- else
- attribute =~ Namespace::NAMESPLIT
- prefix, name = $1, $2
- prefix = '' unless prefix
- end
- old = fetch(name, nil)
- if old.kind_of? Hash # the supplied attribute is one of many
- old.delete(prefix)
- if old.size == 1
- repl = nil
- old.each_value{|v| repl = v}
- store name, repl
- end
- elsif old.nil?
- return @element
- else # the supplied attribute is a top-level one
- super(name)
- end
- @element
- end
-
- # Adds an attribute, overriding any existing attribute by the
- # same name. Namespaces are significant.
- # attribute:: An Attribute
- def add( attribute )
- self[attribute.name] = attribute
- end
-
- alias :<< :add
-
- # Deletes all attributes matching a name. Namespaces are significant.
- # name::
- # A String; all attributes that match this path will be removed
- # Returns:: an Array of the Attributes that were removed
- def delete_all( name )
- rv = []
- each_attribute { |attribute|
- rv << attribute if attribute.expanded_name == name
- }
- rv.each{ |attr| attr.remove }
- return rv
- end
-
- # The +get_attribute_ns+ method retrieves a method by its namespace
- # and name. Thus it is possible to reliably identify an attribute
- # even if an XML processor has changed the prefix.
- #
- # Method contributed by Henrik Martensson
- def get_attribute_ns(namespace, name)
- result = nil
- each_attribute() { |attribute|
- if name == attribute.name &&
- namespace == attribute.namespace() &&
- ( !namespace.empty? || !attribute.fully_expanded_name.index(':') )
- # foo will match xmlns:foo, but only if foo isn't also an attribute
- result = attribute if !result or !namespace.empty? or
- !attribute.fully_expanded_name.index(':')
- end
- }
- result
- end
- end
-end
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
deleted file mode 100644
index da2d70d6c9d..00000000000
--- a/lib/rexml/encoding.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# coding: US-ASCII
-# frozen_string_literal: false
-module REXML
- module Encoding
- # ID ---> Encoding name
- attr_reader :encoding
- def encoding=(encoding)
- encoding = encoding.name if encoding.is_a?(Encoding)
- if encoding.is_a?(String)
- original_encoding = encoding
- encoding = find_encoding(encoding)
- unless encoding
- raise ArgumentError, "Bad encoding name #{original_encoding}"
- end
- end
- return false if defined?(@encoding) and encoding == @encoding
- if encoding
- @encoding = encoding.upcase
- else
- @encoding = 'UTF-8'
- end
- true
- end
-
- def encode(string)
- string.encode(@encoding)
- end
-
- def decode(string)
- string.encode(::Encoding::UTF_8, @encoding)
- end
-
- private
- def find_encoding(name)
- case name
- when /\Ashift-jis\z/i
- return "SHIFT_JIS"
- when /\ACP-(\d+)\z/
- name = "CP#{$1}"
- when /\AUTF-8\z/i
- return name
- end
- begin
- ::Encoding::Converter.search_convpath(name, 'UTF-8')
- rescue ::Encoding::ConverterNotFoundError
- return nil
- end
- name
- end
- end
-end
diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb
deleted file mode 100644
index 89a9e84c577..00000000000
--- a/lib/rexml/entity.rb
+++ /dev/null
@@ -1,171 +0,0 @@
-# frozen_string_literal: false
-require_relative 'child'
-require_relative 'source'
-require_relative 'xmltokens'
-
-module REXML
- class Entity < Child
- include XMLTokens
- PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
- SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))}
- PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')}
- EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))"
- NDATADECL = "\\s+NDATA\\s+#{NAME}"
- PEREFERENCE = "%#{NAME};"
- ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))}
- PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})"
- ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))"
- PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>"
- GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>"
- ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um
-
- attr_reader :name, :external, :ref, :ndata, :pubid
-
- # Create a new entity. Simple entities can be constructed by passing a
- # name, value to the constructor; this creates a generic, plain entity
- # reference. For anything more complicated, you have to pass a Source to
- # the constructor with the entity definition, or use the accessor methods.
- # +WARNING+: There is no validation of entity state except when the entity
- # is read from a stream. If you start poking around with the accessors,
- # you can easily create a non-conformant Entity.
- #
- # e = Entity.new( 'amp', '&' )
- def initialize stream, value=nil, parent=nil, reference=false
- super(parent)
- @ndata = @pubid = @value = @external = nil
- if stream.kind_of? Array
- @name = stream[1]
- if stream[-1] == '%'
- @reference = true
- stream.pop
- else
- @reference = false
- end
- if stream[2] =~ /SYSTEM|PUBLIC/
- @external = stream[2]
- if @external == 'SYSTEM'
- @ref = stream[3]
- @ndata = stream[4] if stream.size == 5
- else
- @pubid = stream[3]
- @ref = stream[4]
- end
- else
- @value = stream[2]
- end
- else
- @reference = reference
- @external = nil
- @name = stream
- @value = value
- end
- end
-
- # Evaluates whether the given string matches an entity definition,
- # returning true if so, and false otherwise.
- def Entity::matches? string
- (ENTITYDECL =~ string) == 0
- end
-
- # Evaluates to the unnormalized value of this entity; that is, replacing
- # all entities -- both %ent; and &ent; entities. This differs from
- # +value()+ in that +value+ only replaces %ent; entities.
- def unnormalized
- document.record_entity_expansion unless document.nil?
- v = value()
- return nil if v.nil?
- @unnormalized = Text::unnormalize(v, parent)
- @unnormalized
- end
-
- #once :unnormalized
-
- # Returns the value of this entity unprocessed -- raw. This is the
- # normalized value; that is, with all %ent; and &ent; entities intact
- def normalized
- @value
- end
-
- # Write out a fully formed, correct entity definition (assuming the Entity
- # object itself is valid.)
- #
- # out::
- # An object implementing <TT>&lt;&lt;</TT> to which the entity will be
- # output
- # indent::
- # *DEPRECATED* and ignored
- def write out, indent=-1
- out << '<!ENTITY '
- out << '% ' if @reference
- out << @name
- out << ' '
- if @external
- out << @external << ' '
- if @pubid
- q = @pubid.include?('"')?"'":'"'
- out << q << @pubid << q << ' '
- end
- q = @ref.include?('"')?"'":'"'
- out << q << @ref << q
- out << ' NDATA ' << @ndata if @ndata
- else
- q = @value.include?('"')?"'":'"'
- out << q << @value << q
- end
- out << '>'
- end
-
- # Returns this entity as a string. See write().
- def to_s
- rv = ''
- write rv
- rv
- end
-
- PEREFERENCE_RE = /#{PEREFERENCE}/um
- # Returns the value of this entity. At the moment, only internal entities
- # are processed. If the value contains internal references (IE,
- # %blah;), those are replaced with their values. IE, if the doctype
- # contains:
- # <!ENTITY % foo "bar">
- # <!ENTITY yada "nanoo %foo; nanoo>
- # then:
- # doctype.entity('yada').value #-> "nanoo bar nanoo"
- def value
- if @value
- matches = @value.scan(PEREFERENCE_RE)
- rv = @value.clone
- if @parent
- sum = 0
- matches.each do |entity_reference|
- entity_value = @parent.entity( entity_reference[0] )
- if sum + entity_value.bytesize > Security.entity_expansion_text_limit
- raise "entity expansion has grown too large"
- else
- sum += entity_value.bytesize
- end
- rv.gsub!( /%#{entity_reference.join};/um, entity_value )
- end
- end
- return rv
- end
- nil
- end
- end
-
- # This is a set of entity constants -- the ones defined in the XML
- # specification. These are +gt+, +lt+, +amp+, +quot+ and +apos+.
- # CAUTION: these entities does not have parent and document
- module EntityConst
- # +>+
- GT = Entity.new( 'gt', '>' )
- # +<+
- LT = Entity.new( 'lt', '<' )
- # +&+
- AMP = Entity.new( 'amp', '&' )
- # +"+
- QUOT = Entity.new( 'quot', '"' )
- # +'+
- APOS = Entity.new( 'apos', "'" )
- end
-end
diff --git a/lib/rexml/formatters/default.rb b/lib/rexml/formatters/default.rb
deleted file mode 100644
index 811b2ff3d5e..00000000000
--- a/lib/rexml/formatters/default.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-# frozen_string_literal: false
-
-module REXML
- module Formatters
- class Default
- # Prints out the XML document with no formatting -- except if ie_hack is
- # set.
- #
- # ie_hack::
- # If set to true, then inserts whitespace before the close of an empty
- # tag, so that IE's bad XML parser doesn't choke.
- def initialize( ie_hack=false )
- @ie_hack = ie_hack
- end
-
- # Writes the node to some output.
- #
- # node::
- # The node to write
- # output::
- # A class implementing <TT>&lt;&lt;</TT>. Pass in an Output object to
- # change the output encoding.
- def write( node, output )
- case node
-
- when Document
- if node.xml_decl.encoding != 'UTF-8' && !output.kind_of?(Output)
- output = Output.new( output, node.xml_decl.encoding )
- end
- write_document( node, output )
-
- when Element
- write_element( node, output )
-
- when Declaration, ElementDecl, NotationDecl, ExternalEntity, Entity,
- Attribute, AttlistDecl
- node.write( output,-1 )
-
- when Instruction
- write_instruction( node, output )
-
- when DocType, XMLDecl
- node.write( output )
-
- when Comment
- write_comment( node, output )
-
- when CData
- write_cdata( node, output )
-
- when Text
- write_text( node, output )
-
- else
- raise Exception.new("XML FORMATTING ERROR")
-
- end
- end
-
- protected
- def write_document( node, output )
- node.children.each { |child| write( child, output ) }
- end
-
- def write_element( node, output )
- output << "<#{node.expanded_name}"
-
- node.attributes.to_a.map { |a|
- Hash === a ? a.values : a
- }.flatten.sort_by {|attr| attr.name}.each do |attr|
- output << " "
- attr.write( output )
- end unless node.attributes.empty?
-
- if node.children.empty?
- output << " " if @ie_hack
- output << "/"
- else
- output << ">"
- node.children.each { |child|
- write( child, output )
- }
- output << "</#{node.expanded_name}"
- end
- output << ">"
- end
-
- def write_text( node, output )
- output << node.to_s()
- end
-
- def write_comment( node, output )
- output << Comment::START
- output << node.to_s
- output << Comment::STOP
- end
-
- def write_cdata( node, output )
- output << CData::START
- output << node.to_s
- output << CData::STOP
- end
-
- def write_instruction( node, output )
- output << Instruction::START
- output << node.target
- content = node.content
- if content
- output << ' '
- output << content
- end
- output << Instruction::STOP
- end
- end
- end
-end
diff --git a/lib/rexml/formatters/pretty.rb b/lib/rexml/formatters/pretty.rb
deleted file mode 100644
index 562ef9462e1..00000000000
--- a/lib/rexml/formatters/pretty.rb
+++ /dev/null
@@ -1,142 +0,0 @@
-# frozen_string_literal: false
-require_relative 'default'
-
-module REXML
- module Formatters
- # Pretty-prints an XML document. This destroys whitespace in text nodes
- # and will insert carriage returns and indentations.
- #
- # TODO: Add an option to print attributes on new lines
- class Pretty < Default
-
- # If compact is set to true, then the formatter will attempt to use as
- # little space as possible
- attr_accessor :compact
- # The width of a page. Used for formatting text
- attr_accessor :width
-
- # Create a new pretty printer.
- #
- # output::
- # An object implementing '<<(String)', to which the output will be written.
- # indentation::
- # An integer greater than 0. The indentation of each level will be
- # this number of spaces. If this is < 1, the behavior of this object
- # is undefined. Defaults to 2.
- # ie_hack::
- # If true, the printer will insert whitespace before closing empty
- # tags, thereby allowing Internet Explorer's XML parser to
- # function. Defaults to false.
- def initialize( indentation=2, ie_hack=false )
- @indentation = indentation
- @level = 0
- @ie_hack = ie_hack
- @width = 80
- @compact = false
- end
-
- protected
- def write_element(node, output)
- output << ' '*@level
- output << "<#{node.expanded_name}"
-
- node.attributes.each_attribute do |attr|
- output << " "
- attr.write( output )
- end unless node.attributes.empty?
-
- if node.children.empty?
- if @ie_hack
- output << " "
- end
- output << "/"
- else
- output << ">"
- # If compact and all children are text, and if the formatted output
- # is less than the specified width, then try to print everything on
- # one line
- skip = false
- if compact
- if node.children.inject(true) {|s,c| s & c.kind_of?(Text)}
- string = ""
- old_level = @level
- @level = 0
- node.children.each { |child| write( child, string ) }
- @level = old_level
- if string.length < @width
- output << string
- skip = true
- end
- end
- end
- unless skip
- output << "\n"
- @level += @indentation
- node.children.each { |child|
- next if child.kind_of?(Text) and child.to_s.strip.length == 0
- write( child, output )
- output << "\n"
- }
- @level -= @indentation
- output << ' '*@level
- end
- output << "</#{node.expanded_name}"
- end
- output << ">"
- end
-
- def write_text( node, output )
- s = node.to_s()
- s.gsub!(/\s/,' ')
- s.squeeze!(" ")
- s = wrap(s, @width - @level)
- s = indent_text(s, @level, " ", true)
- output << (' '*@level + s)
- end
-
- def write_comment( node, output)
- output << ' ' * @level
- super
- end
-
- def write_cdata( node, output)
- output << ' ' * @level
- super
- end
-
- def write_document( node, output )
- # Ok, this is a bit odd. All XML documents have an XML declaration,
- # but it may not write itself if the user didn't specifically add it,
- # either through the API or in the input document. If it doesn't write
- # itself, then we don't need a carriage return... which makes this
- # logic more complex.
- node.children.each { |child|
- next if child == node.children[-1] and child.instance_of?(Text)
- unless child == node.children[0] or child.instance_of?(Text) or
- (child == node.children[1] and !node.children[0].writethis)
- output << "\n"
- end
- write( child, output )
- }
- end
-
- private
- def indent_text(string, level=1, style="\t", indentfirstline=true)
- return string if level < 0
- string.gsub(/\n/, "\n#{style*level}")
- end
-
- def wrap(string, width)
- parts = []
- while string.length > width and place = string.rindex(' ', width)
- parts << string[0...place]
- string = string[place+1..-1]
- end
- parts << string
- parts.join("\n")
- end
-
- end
- end
-end
-
diff --git a/lib/rexml/formatters/transitive.rb b/lib/rexml/formatters/transitive.rb
deleted file mode 100644
index 5ff51e10f37..00000000000
--- a/lib/rexml/formatters/transitive.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: false
-require_relative 'pretty'
-
-module REXML
- module Formatters
- # The Transitive formatter writes an XML document that parses to an
- # identical document as the source document. This means that no extra
- # whitespace nodes are inserted, and whitespace within text nodes is
- # preserved. Within these constraints, the document is pretty-printed,
- # with whitespace inserted into the metadata to introduce formatting.
- #
- # Note that this is only useful if the original XML is not already
- # formatted. Since this formatter does not alter whitespace nodes, the
- # results of formatting already formatted XML will be odd.
- class Transitive < Default
- def initialize( indentation=2, ie_hack=false )
- @indentation = indentation
- @level = 0
- @ie_hack = ie_hack
- end
-
- protected
- def write_element( node, output )
- output << "<#{node.expanded_name}"
-
- node.attributes.each_attribute do |attr|
- output << " "
- attr.write( output )
- end unless node.attributes.empty?
-
- output << "\n"
- output << ' '*@level
- if node.children.empty?
- output << " " if @ie_hack
- output << "/"
- else
- output << ">"
- # If compact and all children are text, and if the formatted output
- # is less than the specified width, then try to print everything on
- # one line
- @level += @indentation
- node.children.each { |child|
- write( child, output )
- }
- @level -= @indentation
- output << "</#{node.expanded_name}"
- output << "\n"
- output << ' '*@level
- end
- output << ">"
- end
-
- def write_text( node, output )
- output << node.to_s()
- end
- end
- end
-end
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
deleted file mode 100644
index 77926bf2af4..00000000000
--- a/lib/rexml/functions.rb
+++ /dev/null
@@ -1,447 +0,0 @@
-# frozen_string_literal: false
-module REXML
- # If you add a method, keep in mind two things:
- # (1) the first argument will always be a list of nodes from which to
- # filter. In the case of context methods (such as position), the function
- # should return an array with a value for each child in the array.
- # (2) all method calls from XML will have "-" replaced with "_".
- # Therefore, in XML, "local-name()" is identical (and actually becomes)
- # "local_name()"
- module Functions
- @@available_functions = {}
- @@context = nil
- @@namespace_context = {}
- @@variables = {}
-
- INTERNAL_METHODS = [
- :namespace_context,
- :namespace_context=,
- :variables,
- :variables=,
- :context=,
- :get_namespace,
- :send,
- ]
- class << self
- def singleton_method_added(name)
- unless INTERNAL_METHODS.include?(name)
- @@available_functions[name] = true
- end
- end
- end
-
- def Functions::namespace_context=(x) ; @@namespace_context=x ; end
- def Functions::variables=(x) ; @@variables=x ; end
- def Functions::namespace_context ; @@namespace_context ; end
- def Functions::variables ; @@variables ; end
-
- def Functions::context=(value); @@context = value; end
-
- def Functions::text( )
- if @@context[:node].node_type == :element
- return @@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value}
- elsif @@context[:node].node_type == :text
- return @@context[:node].value
- else
- return false
- end
- end
-
- # Returns the last node of the given list of nodes.
- def Functions::last( )
- @@context[:size]
- end
-
- def Functions::position( )
- @@context[:index]
- end
-
- # Returns the size of the given list of nodes.
- def Functions::count( node_set )
- node_set.size
- end
-
- # Since REXML is non-validating, this method is not implemented as it
- # requires a DTD
- def Functions::id( object )
- end
-
- def Functions::local_name(node_set=nil)
- get_namespace(node_set) do |node|
- return node.local_name
- end
- ""
- end
-
- def Functions::namespace_uri( node_set=nil )
- get_namespace( node_set ) {|node| node.namespace}
- end
-
- def Functions::name( node_set=nil )
- get_namespace( node_set ) do |node|
- node.expanded_name
- end
- end
-
- # Helper method.
- def Functions::get_namespace( node_set = nil )
- if node_set == nil
- yield @@context[:node] if @@context[:node].respond_to?(:namespace)
- else
- if node_set.respond_to? :each
- result = []
- node_set.each do |node|
- result << yield(node) if node.respond_to?(:namespace)
- end
- result
- elsif node_set.respond_to? :namespace
- yield node_set
- end
- end
- end
-
- # A node-set is converted to a string by returning the string-value of the
- # node in the node-set that is first in document order. If the node-set is
- # empty, an empty string is returned.
- #
- # A number is converted to a string as follows
- #
- # NaN is converted to the string NaN
- #
- # positive zero is converted to the string 0
- #
- # negative zero is converted to the string 0
- #
- # positive infinity is converted to the string Infinity
- #
- # negative infinity is converted to the string -Infinity
- #
- # if the number is an integer, the number is represented in decimal form
- # as a Number with no decimal point and no leading zeros, preceded by a
- # minus sign (-) if the number is negative
- #
- # otherwise, the number is represented in decimal form as a Number
- # including a decimal point with at least one digit before the decimal
- # point and at least one digit after the decimal point, preceded by a
- # minus sign (-) if the number is negative; there must be no leading zeros
- # before the decimal point apart possibly from the one required digit
- # immediately before the decimal point; beyond the one required digit
- # after the decimal point there must be as many, but only as many, more
- # digits as are needed to uniquely distinguish the number from all other
- # IEEE 754 numeric values.
- #
- # The boolean false value is converted to the string false. The boolean
- # true value is converted to the string true.
- #
- # An object of a type other than the four basic types is converted to a
- # string in a way that is dependent on that type.
- def Functions::string( object=@@context[:node] )
- if object.respond_to?(:node_type)
- case object.node_type
- when :attribute
- object.value
- when :element
- string_value(object)
- when :document
- string_value(object.root)
- when :processing_instruction
- object.content
- else
- object.to_s
- end
- else
- case object
- when Array
- string(object[0])
- when Float
- if object.nan?
- "NaN"
- else
- integer = object.to_i
- if object == integer
- "%d" % integer
- else
- object.to_s
- end
- end
- else
- object.to_s
- end
- end
- end
-
- # A node-set is converted to a string by
- # returning the concatenation of the string-value
- # of each of the children of the node in the
- # node-set that is first in document order.
- # If the node-set is empty, an empty string is returned.
- def Functions::string_value( o )
- rv = ""
- o.children.each { |e|
- if e.node_type == :text
- rv << e.to_s
- elsif e.node_type == :element
- rv << string_value( e )
- end
- }
- rv
- end
-
- def Functions::concat( *objects )
- concatenated = ""
- objects.each do |object|
- concatenated << string(object)
- end
- concatenated
- end
-
- # Fixed by Mike Stok
- def Functions::starts_with( string, test )
- string(string).index(string(test)) == 0
- end
-
- # Fixed by Mike Stok
- def Functions::contains( string, test )
- string(string).include?(string(test))
- end
-
- # Kouhei fixed this
- def Functions::substring_before( string, test )
- ruby_string = string(string)
- ruby_index = ruby_string.index(string(test))
- if ruby_index.nil?
- ""
- else
- ruby_string[ 0...ruby_index ]
- end
- end
-
- # Kouhei fixed this too
- def Functions::substring_after( string, test )
- ruby_string = string(string)
- return $1 if ruby_string =~ /#{test}(.*)/
- ""
- end
-
- # Take equal portions of Mike Stok and Sean Russell; mix
- # vigorously, and pour into a tall, chilled glass. Serves 10,000.
- def Functions::substring( string, start, length=nil )
- ruby_string = string(string)
- ruby_length = if length.nil?
- ruby_string.length.to_f
- else
- number(length)
- end
- ruby_start = number(start)
-
- # Handle the special cases
- return '' if (
- ruby_length.nan? or
- ruby_start.nan? or
- ruby_start.infinite?
- )
-
- infinite_length = ruby_length.infinite? == 1
- ruby_length = ruby_string.length if infinite_length
-
- # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
- # are 0..length. Therefore, we have to offset the bounds by one.
- ruby_start = round(ruby_start) - 1
- ruby_length = round(ruby_length)
-
- if ruby_start < 0
- ruby_length += ruby_start unless infinite_length
- ruby_start = 0
- end
- return '' if ruby_length <= 0
- ruby_string[ruby_start,ruby_length]
- end
-
- # UNTESTED
- def Functions::string_length( string )
- string(string).length
- end
-
- # UNTESTED
- def Functions::normalize_space( string=nil )
- string = string(@@context[:node]) if string.nil?
- if string.kind_of? Array
- string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
- else
- string.to_s.strip.gsub(/\s+/um, ' ')
- end
- end
-
- # This is entirely Mike Stok's beast
- def Functions::translate( string, tr1, tr2 )
- from = string(tr1)
- to = string(tr2)
-
- # the map is our translation table.
- #
- # if a character occurs more than once in the
- # from string then we ignore the second &
- # subsequent mappings
- #
- # if a character maps to nil then we delete it
- # in the output. This happens if the from
- # string is longer than the to string
- #
- # there's nothing about - or ^ being special in
- # http://www.w3.org/TR/xpath#function-translate
- # so we don't build ranges or negated classes
-
- map = Hash.new
- 0.upto(from.length - 1) { |pos|
- from_char = from[pos]
- unless map.has_key? from_char
- map[from_char] =
- if pos < to.length
- to[pos]
- else
- nil
- end
- end
- }
-
- if ''.respond_to? :chars
- string(string).chars.collect { |c|
- if map.has_key? c then map[c] else c end
- }.compact.join
- else
- string(string).unpack('U*').collect { |c|
- if map.has_key? c then map[c] else c end
- }.compact.pack('U*')
- end
- end
-
- def Functions::boolean(object=@@context[:node])
- case object
- when true, false
- object
- when Float
- return false if object.zero?
- return false if object.nan?
- true
- when Numeric
- not object.zero?
- when String
- not object.empty?
- when Array
- not object.empty?
- else
- object ? true : false
- end
- end
-
- # UNTESTED
- def Functions::not( object )
- not boolean( object )
- end
-
- # UNTESTED
- def Functions::true( )
- true
- end
-
- # UNTESTED
- def Functions::false( )
- false
- end
-
- # UNTESTED
- def Functions::lang( language )
- lang = false
- node = @@context[:node]
- attr = nil
- until node.nil?
- if node.node_type == :element
- attr = node.attributes["xml:lang"]
- unless attr.nil?
- lang = compare_language(string(language), attr)
- break
- else
- end
- end
- node = node.parent
- end
- lang
- end
-
- def Functions::compare_language lang1, lang2
- lang2.downcase.index(lang1.downcase) == 0
- end
-
- # a string that consists of optional whitespace followed by an optional
- # minus sign followed by a Number followed by whitespace is converted to
- # the IEEE 754 number that is nearest (according to the IEEE 754
- # round-to-nearest rule) to the mathematical value represented by the
- # string; any other string is converted to NaN
- #
- # boolean true is converted to 1; boolean false is converted to 0
- #
- # a node-set is first converted to a string as if by a call to the string
- # function and then converted in the same way as a string argument
- #
- # an object of a type other than the four basic types is converted to a
- # number in a way that is dependent on that type
- def Functions::number(object=@@context[:node])
- case object
- when true
- Float(1)
- when false
- Float(0)
- when Array
- number(string(object))
- when Numeric
- object.to_f
- else
- str = string(object)
- case str.strip
- when /\A\s*(-?(?:\d+(?:\.\d*)?|\.\d+))\s*\z/
- $1.to_f
- else
- Float::NAN
- end
- end
- end
-
- def Functions::sum( nodes )
- nodes = [nodes] unless nodes.kind_of? Array
- nodes.inject(0) { |r,n| r + number(string(n)) }
- end
-
- def Functions::floor( number )
- number(number).floor
- end
-
- def Functions::ceiling( number )
- number(number).ceil
- end
-
- def Functions::round( number )
- number = number(number)
- begin
- neg = number.negative?
- number = number.abs.round
- neg ? -number : number
- rescue FloatDomainError
- number
- end
- end
-
- def Functions::processing_instruction( node )
- node.node_type == :processing_instruction
- end
-
- def Functions::send(name, *args)
- if @@available_functions[name.to_sym]
- super
- else
- # TODO: Maybe, this is not XPath spec behavior.
- # This behavior must be reconsidered.
- XPath.match(@@context[:node], name.to_s)
- end
- end
- end
-end
diff --git a/lib/rexml/instruction.rb b/lib/rexml/instruction.rb
deleted file mode 100644
index 318741f03b5..00000000000
--- a/lib/rexml/instruction.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-# frozen_string_literal: false
-
-require_relative "child"
-require_relative "source"
-
-module REXML
- # Represents an XML Instruction; IE, <? ... ?>
- # TODO: Add parent arg (3rd arg) to constructor
- class Instruction < Child
- START = "<?"
- STOP = "?>"
-
- # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
- # content is everything else.
- attr_accessor :target, :content
-
- # Constructs a new Instruction
- # @param target can be one of a number of things. If String, then
- # the target of this instruction is set to this. If an Instruction,
- # then the Instruction is shallowly cloned (target and content are
- # copied).
- # @param content Must be either a String, or a Parent. Can only
- # be a Parent if the target argument is a Source. Otherwise, this
- # String is set as the content of this instruction.
- def initialize(target, content=nil)
- case target
- when String
- super()
- @target = target
- @content = content
- when Instruction
- super(content)
- @target = target.target
- @content = target.content
- else
- message =
- "processing instruction target must be String or REXML::Instruction: "
- message << "<#{target.inspect}>"
- raise ArgumentError, message
- end
- @content.strip! if @content
- end
-
- def clone
- Instruction.new self
- end
-
- # == DEPRECATED
- # See the rexml/formatters package
- #
- def write writer, indent=-1, transitive=false, ie_hack=false
- Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
- indent(writer, indent)
- writer << START
- writer << @target
- if @content
- writer << ' '
- writer << @content
- end
- writer << STOP
- end
-
- # @return true if other is an Instruction, and the content and target
- # of the other matches the target and content of this object.
- def ==( other )
- other.kind_of? Instruction and
- other.target == @target and
- other.content == @content
- end
-
- def node_type
- :processing_instruction
- end
-
- def inspect
- "<?p-i #{target} ...?>"
- end
- end
-end
diff --git a/lib/rexml/light/node.rb b/lib/rexml/light/node.rb
deleted file mode 100644
index 01177c64d28..00000000000
--- a/lib/rexml/light/node.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-# frozen_string_literal: false
-require_relative '../xmltokens'
-
-# [ :element, parent, name, attributes, children* ]
- # a = Node.new
- # a << "B" # => <a>B</a>
- # a.b # => <a>B<b/></a>
- # a.b[1] # => <a>B<b/><b/><a>
- # a.b[1]["x"] = "y" # => <a>B<b/><b x="y"/></a>
- # a.b[0].c # => <a>B<b><c/></b><b x="y"/></a>
- # a.b.c << "D" # => <a>B<b><c>D</c></b><b x="y"/></a>
-module REXML
- module Light
- # Represents a tagged XML element. Elements are characterized by
- # having children, attributes, and names, and can themselves be
- # children.
- class Node
- NAMESPLIT = /^(?:(#{XMLTokens::NCNAME_STR}):)?(#{XMLTokens::NCNAME_STR})/u
- PARENTS = [ :element, :document, :doctype ]
- # Create a new element.
- def initialize node=nil
- @node = node
- if node.kind_of? String
- node = [ :text, node ]
- elsif node.nil?
- node = [ :document, nil, nil ]
- elsif node[0] == :start_element
- node[0] = :element
- elsif node[0] == :start_doctype
- node[0] = :doctype
- elsif node[0] == :start_document
- node[0] = :document
- end
- end
-
- def size
- if PARENTS.include? @node[0]
- @node[-1].size
- else
- 0
- end
- end
-
- def each
- size.times { |x| yield( at(x+4) ) }
- end
-
- def name
- at(2)
- end
-
- def name=( name_str, ns=nil )
- pfx = ''
- pfx = "#{prefix(ns)}:" if ns
- _old_put(2, "#{pfx}#{name_str}")
- end
-
- def parent=( node )
- _old_put(1,node)
- end
-
- def local_name
- namesplit
- @name
- end
-
- def local_name=( name_str )
- _old_put( 1, "#@prefix:#{name_str}" )
- end
-
- def prefix( namespace=nil )
- prefix_of( self, namespace )
- end
-
- def namespace( prefix=prefix() )
- namespace_of( self, prefix )
- end
-
- def namespace=( namespace )
- @prefix = prefix( namespace )
- pfx = ''
- pfx = "#@prefix:" if @prefix.size > 0
- _old_put(1, "#{pfx}#@name")
- end
-
- def []( reference, ns=nil )
- if reference.kind_of? String
- pfx = ''
- pfx = "#{prefix(ns)}:" if ns
- at(3)["#{pfx}#{reference}"]
- elsif reference.kind_of? Range
- _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) )
- else
- _old_get( 4+reference )
- end
- end
-
- def =~( path )
- XPath.match( self, path )
- end
-
- # Doesn't handle namespaces yet
- def []=( reference, ns, value=nil )
- if reference.kind_of? String
- value = ns unless value
- at( 3 )[reference] = value
- elsif reference.kind_of? Range
- _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns )
- else
- if value
- _old_put( 4+reference, ns, value )
- else
- _old_put( 4+reference, ns )
- end
- end
- end
-
- # Append a child to this element, optionally under a provided namespace.
- # The namespace argument is ignored if the element argument is an Element
- # object. Otherwise, the element argument is a string, the namespace (if
- # provided) is the namespace the element is created in.
- def << element
- if node_type() == :text
- at(-1) << element
- else
- newnode = Node.new( element )
- newnode.parent = self
- self.push( newnode )
- end
- at(-1)
- end
-
- def node_type
- _old_get(0)
- end
-
- def text=( foo )
- replace = at(4).kind_of?(String)? 1 : 0
- self._old_put(4,replace, normalizefoo)
- end
-
- def root
- context = self
- context = context.at(1) while context.at(1)
- end
-
- def has_name?( name, namespace = '' )
- at(3) == name and namespace() == namespace
- end
-
- def children
- self
- end
-
- def parent
- at(1)
- end
-
- def to_s
-
- end
-
- private
-
- def namesplit
- return if @name.defined?
- at(2) =~ NAMESPLIT
- @prefix = '' || $1
- @name = $2
- end
-
- def namespace_of( node, prefix=nil )
- if not prefix
- name = at(2)
- name =~ NAMESPLIT
- prefix = $1
- end
- to_find = 'xmlns'
- to_find = "xmlns:#{prefix}" if not prefix.nil?
- ns = at(3)[ to_find ]
- ns ? ns : namespace_of( @node[0], prefix )
- end
-
- def prefix_of( node, namespace=nil )
- if not namespace
- name = node.name
- name =~ NAMESPLIT
- $1
- else
- ns = at(3).find { |k,v| v == namespace }
- ns ? ns : prefix_of( node.parent, namespace )
- end
- end
- end
- end
-end
diff --git a/lib/rexml/namespace.rb b/lib/rexml/namespace.rb
deleted file mode 100644
index 924edf95063..00000000000
--- a/lib/rexml/namespace.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: false
-
-require_relative 'xmltokens'
-
-module REXML
- # Adds named attributes to an object.
- module Namespace
- # The name of the object, valid if set
- attr_reader :name, :expanded_name
- # The expanded name of the object, valid if name is set
- attr_accessor :prefix
- include XMLTokens
- NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
-
- # Sets the name and the expanded name
- def name=( name )
- @expanded_name = name
- case name
- when NAMESPLIT
- if $1
- @prefix = $1
- else
- @prefix = ""
- @namespace = ""
- end
- @name = $2
- when ""
- @prefix = nil
- @namespace = nil
- @name = nil
- else
- message = "name must be \#{PREFIX}:\#{LOCAL_NAME} or \#{LOCAL_NAME}: "
- message += "<#{name.inspect}>"
- raise ArgumentError, message
- end
- end
-
- # Compares names optionally WITH namespaces
- def has_name?( other, ns=nil )
- if ns
- return (namespace() == ns and name() == other)
- elsif other.include? ":"
- return fully_expanded_name == other
- else
- return name == other
- end
- end
-
- alias :local_name :name
-
- # Fully expand the name, even if the prefix wasn't specified in the
- # source file.
- def fully_expanded_name
- ns = prefix
- return "#{ns}:#@name" if ns.size > 0
- return @name
- end
- end
-end
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
deleted file mode 100644
index 081caba6cb7..00000000000
--- a/lib/rexml/node.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# frozen_string_literal: false
-require_relative "parseexception"
-require_relative "formatters/pretty"
-require_relative "formatters/default"
-
-module REXML
- # Represents a node in the tree. Nodes are never encountered except as
- # superclasses of other objects. Nodes have siblings.
- module Node
- # @return the next sibling (nil if unset)
- def next_sibling_node
- return nil if @parent.nil?
- @parent[ @parent.index(self) + 1 ]
- end
-
- # @return the previous sibling (nil if unset)
- def previous_sibling_node
- return nil if @parent.nil?
- ind = @parent.index(self)
- return nil if ind == 0
- @parent[ ind - 1 ]
- end
-
- # indent::
- # *DEPRECATED* This parameter is now ignored. See the formatters in the
- # REXML::Formatters package for changing the output style.
- def to_s indent=nil
- unless indent.nil?
- Kernel.warn( "#{self.class.name}.to_s(indent) parameter is deprecated", uplevel: 1)
- f = REXML::Formatters::Pretty.new( indent )
- f.write( self, rv = "" )
- else
- f = REXML::Formatters::Default.new
- f.write( self, rv = "" )
- end
- return rv
- end
-
- def indent to, ind
- if @parent and @parent.context and not @parent.context[:indentstyle].nil? then
- indentstyle = @parent.context[:indentstyle]
- else
- indentstyle = ' '
- end
- to << indentstyle*ind unless ind<1
- end
-
- def parent?
- false;
- end
-
-
- # Visit all subnodes of +self+ recursively
- def each_recursive(&block) # :yields: node
- self.elements.each {|node|
- block.call(node)
- node.each_recursive(&block)
- }
- end
-
- # Find (and return) first subnode (recursively) for which the block
- # evaluates to true. Returns +nil+ if none was found.
- def find_first_recursive(&block) # :yields: node
- each_recursive {|node|
- return node if block.call(node)
- }
- return nil
- end
-
- # Returns the position that +self+ holds in its parent's array, indexed
- # from 1.
- def index_in_parent
- parent.index(self)+1
- end
- end
-end
diff --git a/lib/rexml/output.rb b/lib/rexml/output.rb
deleted file mode 100644
index 88a5fb378d9..00000000000
--- a/lib/rexml/output.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: false
-require_relative 'encoding'
-
-module REXML
- class Output
- include Encoding
-
- attr_reader :encoding
-
- def initialize real_IO, encd="iso-8859-1"
- @output = real_IO
- self.encoding = encd
-
- @to_utf = encoding != 'UTF-8'
-
- if encoding == "UTF-16"
- @output << "\ufeff".encode("UTF-16BE")
- self.encoding = "UTF-16BE"
- end
- end
-
- def <<( content )
- @output << (@to_utf ? self.encode(content) : content)
- end
-
- def to_s
- "Output[#{encoding}]"
- end
- end
-end
diff --git a/lib/rexml/parent.rb b/lib/rexml/parent.rb
deleted file mode 100644
index 6a53b37a123..00000000000
--- a/lib/rexml/parent.rb
+++ /dev/null
@@ -1,166 +0,0 @@
-# frozen_string_literal: false
-require_relative "child"
-
-module REXML
- # A parent has children, and has methods for accessing them. The Parent
- # class is never encountered except as the superclass for some other
- # object.
- class Parent < Child
- include Enumerable
-
- # Constructor
- # @param parent if supplied, will be set as the parent of this object
- def initialize parent=nil
- super(parent)
- @children = []
- end
-
- def add( object )
- object.parent = self
- @children << object
- object
- end
-
- alias :push :add
- alias :<< :push
-
- def unshift( object )
- object.parent = self
- @children.unshift object
- end
-
- def delete( object )
- found = false
- @children.delete_if {|c| c.equal?(object) and found = true }
- object.parent = nil if found
- found ? object : nil
- end
-
- def each(&block)
- @children.each(&block)
- end
-
- def delete_if( &block )
- @children.delete_if(&block)
- end
-
- def delete_at( index )
- @children.delete_at index
- end
-
- def each_index( &block )
- @children.each_index(&block)
- end
-
- # Fetches a child at a given index
- # @param index the Integer index of the child to fetch
- def []( index )
- @children[index]
- end
-
- alias :each_child :each
-
-
-
- # Set an index entry. See Array.[]=
- # @param index the index of the element to set
- # @param opt either the object to set, or an Integer length
- # @param child if opt is an Integer, this is the child to set
- # @return the parent (self)
- def []=( *args )
- args[-1].parent = self
- @children[*args[0..-2]] = args[-1]
- end
-
- # Inserts an child before another child
- # @param child1 this is either an xpath or an Element. If an Element,
- # child2 will be inserted before child1 in the child list of the parent.
- # If an xpath, child2 will be inserted before the first child to match
- # the xpath.
- # @param child2 the child to insert
- # @return the parent (self)
- def insert_before( child1, child2 )
- if child1.kind_of? String
- child1 = XPath.first( self, child1 )
- child1.parent.insert_before child1, child2
- else
- ind = index(child1)
- child2.parent.delete(child2) if child2.parent
- @children[ind,0] = child2
- child2.parent = self
- end
- self
- end
-
- # Inserts an child after another child
- # @param child1 this is either an xpath or an Element. If an Element,
- # child2 will be inserted after child1 in the child list of the parent.
- # If an xpath, child2 will be inserted after the first child to match
- # the xpath.
- # @param child2 the child to insert
- # @return the parent (self)
- def insert_after( child1, child2 )
- if child1.kind_of? String
- child1 = XPath.first( self, child1 )
- child1.parent.insert_after child1, child2
- else
- ind = index(child1)+1
- child2.parent.delete(child2) if child2.parent
- @children[ind,0] = child2
- child2.parent = self
- end
- self
- end
-
- def to_a
- @children.dup
- end
-
- # Fetches the index of a given child
- # @param child the child to get the index of
- # @return the index of the child, or nil if the object is not a child
- # of this parent.
- def index( child )
- count = -1
- @children.find { |i| count += 1 ; i.hash == child.hash }
- count
- end
-
- # @return the number of children of this parent
- def size
- @children.size
- end
-
- alias :length :size
-
- # Replaces one child with another, making sure the nodelist is correct
- # @param to_replace the child to replace (must be a Child)
- # @param replacement the child to insert into the nodelist (must be a
- # Child)
- def replace_child( to_replace, replacement )
- @children.map! {|c| c.equal?( to_replace ) ? replacement : c }
- to_replace.parent = nil
- replacement.parent = self
- end
-
- # Deeply clones this object. This creates a complete duplicate of this
- # Parent, including all descendants.
- def deep_clone
- cl = clone()
- each do |child|
- if child.kind_of? Parent
- cl << child.deep_clone
- else
- cl << child.clone
- end
- end
- cl
- end
-
- alias :children :to_a
-
- def parent?
- true
- end
- end
-end
diff --git a/lib/rexml/parseexception.rb b/lib/rexml/parseexception.rb
deleted file mode 100644
index 7b16cd1a411..00000000000
--- a/lib/rexml/parseexception.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: false
-module REXML
- class ParseException < RuntimeError
- attr_accessor :source, :parser, :continued_exception
-
- def initialize( message, source=nil, parser=nil, exception=nil )
- super(message)
- @source = source
- @parser = parser
- @continued_exception = exception
- end
-
- def to_s
- # Quote the original exception, if there was one
- if @continued_exception
- err = @continued_exception.inspect
- err << "\n"
- err << @continued_exception.backtrace.join("\n")
- err << "\n...\n"
- else
- err = ""
- end
-
- # Get the stack trace and error message
- err << super
-
- # Add contextual information
- if @source
- err << "\nLine: #{line}\n"
- err << "Position: #{position}\n"
- err << "Last 80 unconsumed characters:\n"
- err << @source.buffer[0..80].force_encoding("ASCII-8BIT").gsub(/\n/, ' ')
- end
-
- err
- end
-
- def position
- @source.current_line[0] if @source and defined? @source.current_line and
- @source.current_line
- end
-
- def line
- @source.current_line[2] if @source and defined? @source.current_line and
- @source.current_line
- end
-
- def context
- @source.current_line
- end
- end
-end
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
deleted file mode 100644
index f76aed07875..00000000000
--- a/lib/rexml/parsers/baseparser.rb
+++ /dev/null
@@ -1,594 +0,0 @@
-# frozen_string_literal: false
-require_relative '../parseexception'
-require_relative '../undefinednamespaceexception'
-require_relative '../source'
-require 'set'
-require "strscan"
-
-module REXML
- module Parsers
- # = Using the Pull Parser
- # <em>This API is experimental, and subject to change.</em>
- # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
- # while parser.has_next?
- # res = parser.next
- # puts res[1]['att'] if res.start_tag? and res[0] == 'b'
- # end
- # See the PullEvent class for information on the content of the results.
- # The data is identical to the arguments passed for the various events to
- # the StreamListener API.
- #
- # Notice that:
- # parser = PullParser.new( "<a>BAD DOCUMENT" )
- # while parser.has_next?
- # res = parser.next
- # raise res[1] if res.error?
- # end
- #
- # Nat Price gave me some good ideas for the API.
- class BaseParser
- LETTER = '[:alpha:]'
- DIGIT = '[:digit:]'
-
- COMBININGCHAR = '' # TODO
- EXTENDER = '' # TODO
-
- NCNAME_STR= "[#{LETTER}_][-[:alnum:]._#{COMBININGCHAR}#{EXTENDER}]*"
- QNAME_STR= "(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})"
- QNAME = /(#{QNAME_STR})/
-
- # Just for backward compatibility. For example, kramdown uses this.
- # It's not used in REXML.
- UNAME_STR= "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
-
- NAMECHAR = '[\-\w\.:]'
- NAME = "([\\w:]#{NAMECHAR}*)"
- NMTOKEN = "(?:#{NAMECHAR})+"
- NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*"
- REFERENCE = "&(?:#{NAME};|#\\d+;|#x[0-9a-fA-F]+;)"
- REFERENCE_RE = /#{REFERENCE}/
-
- DOCTYPE_START = /\A\s*<!DOCTYPE\s/um
- DOCTYPE_END = /\A\s*\]\s*>/um
- DOCTYPE_PATTERN = /\s*<!DOCTYPE\s+(.*?)(\[|>)/um
- ATTRIBUTE_PATTERN = /\s*(#{QNAME_STR})\s*=\s*(["'])(.*?)\4/um
- COMMENT_START = /\A<!--/u
- COMMENT_PATTERN = /<!--(.*?)-->/um
- CDATA_START = /\A<!\[CDATA\[/u
- CDATA_END = /\A\s*\]\s*>/um
- CDATA_PATTERN = /<!\[CDATA\[(.*?)\]\]>/um
- XMLDECL_START = /\A<\?xml\s/u;
- XMLDECL_PATTERN = /<\?xml\s+(.*?)\?>/um
- INSTRUCTION_START = /\A<\?/u
- INSTRUCTION_PATTERN = /<\?#{NAME}(\s+.*?)?\?>/um
- TAG_MATCH = /^<((?>#{QNAME_STR}))/um
- CLOSE_MATCH = /^\s*<\/(#{QNAME_STR})\s*>/um
-
- VERSION = /\bversion\s*=\s*["'](.*?)['"]/um
- ENCODING = /\bencoding\s*=\s*["'](.*?)['"]/um
- STANDALONE = /\bstandalone\s*=\s*["'](.*?)['"]/um
-
- ENTITY_START = /\A\s*<!ENTITY/
- IDENTITY = /^([!\*\w\-]+)(\s+#{NCNAME_STR})?(\s+["'](.*?)['"])?(\s+['"](.*?)["'])?/u
- ELEMENTDECL_START = /\A\s*<!ELEMENT/um
- ELEMENTDECL_PATTERN = /\A\s*(<!ELEMENT.*?)>/um
- SYSTEMENTITY = /\A\s*(%.*?;)\s*$/um
- ENUMERATION = "\\(\\s*#{NMTOKEN}(?:\\s*\\|\\s*#{NMTOKEN})*\\s*\\)"
- NOTATIONTYPE = "NOTATION\\s+\\(\\s*#{NAME}(?:\\s*\\|\\s*#{NAME})*\\s*\\)"
- ENUMERATEDTYPE = "(?:(?:#{NOTATIONTYPE})|(?:#{ENUMERATION}))"
- ATTTYPE = "(CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS|#{ENUMERATEDTYPE})"
- ATTVALUE = "(?:\"((?:[^<&\"]|#{REFERENCE})*)\")|(?:'((?:[^<&']|#{REFERENCE})*)')"
- DEFAULTDECL = "(#REQUIRED|#IMPLIED|(?:(#FIXED\\s+)?#{ATTVALUE}))"
- ATTDEF = "\\s+#{NAME}\\s+#{ATTTYPE}\\s+#{DEFAULTDECL}"
- ATTDEF_RE = /#{ATTDEF}/
- ATTLISTDECL_START = /\A\s*<!ATTLIST/um
- ATTLISTDECL_PATTERN = /\A\s*<!ATTLIST\s+#{NAME}(?:#{ATTDEF})*\s*>/um
- NOTATIONDECL_START = /\A\s*<!NOTATION/um
- PUBLIC = /\A\s*<!NOTATION\s+(\w[\-\w]*)\s+(PUBLIC)\s+(["'])(.*?)\3(?:\s+(["'])(.*?)\5)?\s*>/um
- SYSTEM = /\A\s*<!NOTATION\s+(\w[\-\w]*)\s+(SYSTEM)\s+(["'])(.*?)\3\s*>/um
-
- TEXT_PATTERN = /\A([^<]*)/um
-
- # Entity constants
- PUBIDCHAR = "\x20\x0D\x0Aa-zA-Z0-9\\-()+,./:=?;!*@$_%#"
- SYSTEMLITERAL = %Q{((?:"[^"]*")|(?:'[^']*'))}
- PUBIDLITERAL = %Q{("[#{PUBIDCHAR}']*"|'[#{PUBIDCHAR}]*')}
- EXTERNALID = "(?:(?:(SYSTEM)\\s+#{SYSTEMLITERAL})|(?:(PUBLIC)\\s+#{PUBIDLITERAL}\\s+#{SYSTEMLITERAL}))"
- NDATADECL = "\\s+NDATA\\s+#{NAME}"
- PEREFERENCE = "%#{NAME};"
- ENTITYVALUE = %Q{((?:"(?:[^%&"]|#{PEREFERENCE}|#{REFERENCE})*")|(?:'([^%&']|#{PEREFERENCE}|#{REFERENCE})*'))}
- PEDEF = "(?:#{ENTITYVALUE}|#{EXTERNALID})"
- ENTITYDEF = "(?:#{ENTITYVALUE}|(?:#{EXTERNALID}(#{NDATADECL})?))"
- PEDECL = "<!ENTITY\\s+(%)\\s+#{NAME}\\s+#{PEDEF}\\s*>"
- GEDECL = "<!ENTITY\\s+#{NAME}\\s+#{ENTITYDEF}\\s*>"
- ENTITYDECL = /\s*(?:#{GEDECL})|(?:#{PEDECL})/um
-
- EREFERENCE = /&(?!#{NAME};)/
-
- DEFAULT_ENTITIES = {
- 'gt' => [/&gt;/, '&gt;', '>', />/],
- 'lt' => [/&lt;/, '&lt;', '<', /</],
- 'quot' => [/&quot;/, '&quot;', '"', /"/],
- "apos" => [/&apos;/, "&apos;", "'", /'/]
- }
-
- def initialize( source )
- self.stream = source
- @listeners = []
- end
-
- def add_listener( listener )
- @listeners << listener
- end
-
- attr_reader :source
-
- def stream=( source )
- @source = SourceFactory.create_from( source )
- @closed = nil
- @document_status = nil
- @tags = []
- @stack = []
- @entities = []
- @nsstack = []
- end
-
- def position
- if @source.respond_to? :position
- @source.position
- else
- # FIXME
- 0
- end
- end
-
- # Returns true if there are no more events
- def empty?
- return (@source.empty? and @stack.empty?)
- end
-
- # Returns true if there are more events. Synonymous with !empty?
- def has_next?
- return !(@source.empty? and @stack.empty?)
- end
-
- # Push an event back on the head of the stream. This method
- # has (theoretically) infinite depth.
- def unshift token
- @stack.unshift(token)
- end
-
- # Peek at the +depth+ event in the stack. The first element on the stack
- # is at depth 0. If +depth+ is -1, will parse to the end of the input
- # stream and return the last event, which is always :end_document.
- # Be aware that this causes the stream to be parsed up to the +depth+
- # event, so you can effectively pre-parse the entire document (pull the
- # entire thing into memory) using this method.
- def peek depth=0
- raise %Q[Illegal argument "#{depth}"] if depth < -1
- temp = []
- if depth == -1
- temp.push(pull()) until empty?
- else
- while @stack.size+temp.size < depth+1
- temp.push(pull())
- end
- end
- @stack += temp if temp.size > 0
- @stack[depth]
- end
-
- # Returns the next event. This is a +PullEvent+ object.
- def pull
- pull_event.tap do |event|
- @listeners.each do |listener|
- listener.receive event
- end
- end
- end
-
- def pull_event
- if @closed
- x, @closed = @closed, nil
- return [ :end_element, x ]
- end
- return [ :end_document ] if empty?
- return @stack.shift if @stack.size > 0
- #STDERR.puts @source.encoding
- @source.read if @source.buffer.size<2
- #STDERR.puts "BUFFER = #{@source.buffer.inspect}"
- if @document_status == nil
- #@source.consume( /^\s*/um )
- word = @source.match( /^((?:\s+)|(?:<[^>]*>))/um )
- word = word[1] unless word.nil?
- #STDERR.puts "WORD = #{word.inspect}"
- case word
- when COMMENT_START
- return [ :comment, @source.match( COMMENT_PATTERN, true )[1] ]
- when XMLDECL_START
- #STDERR.puts "XMLDECL"
- results = @source.match( XMLDECL_PATTERN, true )[1]
- version = VERSION.match( results )
- version = version[1] unless version.nil?
- encoding = ENCODING.match(results)
- encoding = encoding[1] unless encoding.nil?
- if need_source_encoding_update?(encoding)
- @source.encoding = encoding
- end
- if encoding.nil? and /\AUTF-16(?:BE|LE)\z/i =~ @source.encoding
- encoding = "UTF-16"
- end
- standalone = STANDALONE.match(results)
- standalone = standalone[1] unless standalone.nil?
- return [ :xmldecl, version, encoding, standalone ]
- when INSTRUCTION_START
- return process_instruction
- when DOCTYPE_START
- md = @source.match( DOCTYPE_PATTERN, true )
- @nsstack.unshift(curr_ns=Set.new)
- identity = md[1]
- close = md[2]
- identity =~ IDENTITY
- name = $1
- raise REXML::ParseException.new("DOCTYPE is missing a name") if name.nil?
- pub_sys = $2.nil? ? nil : $2.strip
- long_name = $4.nil? ? nil : $4.strip
- uri = $6.nil? ? nil : $6.strip
- args = [ :start_doctype, name, pub_sys, long_name, uri ]
- if close == ">"
- @document_status = :after_doctype
- @source.read if @source.buffer.size<2
- md = @source.match(/^\s*/um, true)
- @stack << [ :end_doctype ]
- else
- @document_status = :in_doctype
- end
- return args
- when /^\s+/
- else
- @document_status = :after_doctype
- @source.read if @source.buffer.size<2
- md = @source.match(/\s*/um, true)
- if @source.encoding == "UTF-8"
- @source.buffer.force_encoding(::Encoding::UTF_8)
- end
- end
- end
- if @document_status == :in_doctype
- md = @source.match(/\s*(.*?>)/um)
- case md[1]
- when SYSTEMENTITY
- match = @source.match( SYSTEMENTITY, true )[1]
- return [ :externalentity, match ]
-
- when ELEMENTDECL_START
- return [ :elementdecl, @source.match( ELEMENTDECL_PATTERN, true )[1] ]
-
- when ENTITY_START
- match = @source.match( ENTITYDECL, true ).to_a.compact
- match[0] = :entitydecl
- ref = false
- if match[1] == '%'
- ref = true
- match.delete_at 1
- end
- # Now we have to sort out what kind of entity reference this is
- if match[2] == 'SYSTEM'
- # External reference
- match[3] = match[3][1..-2] # PUBID
- match.delete_at(4) if match.size > 4 # Chop out NDATA decl
- # match is [ :entity, name, SYSTEM, pubid(, ndata)? ]
- elsif match[2] == 'PUBLIC'
- # External reference
- match[3] = match[3][1..-2] # PUBID
- match[4] = match[4][1..-2] # HREF
- match.delete_at(5) if match.size > 5 # Chop out NDATA decl
- # match is [ :entity, name, PUBLIC, pubid, href(, ndata)? ]
- else
- match[2] = match[2][1..-2]
- match.pop if match.size == 4
- # match is [ :entity, name, value ]
- end
- match << '%' if ref
- return match
- when ATTLISTDECL_START
- md = @source.match( ATTLISTDECL_PATTERN, true )
- raise REXML::ParseException.new( "Bad ATTLIST declaration!", @source ) if md.nil?
- element = md[1]
- contents = md[0]
-
- pairs = {}
- values = md[0].scan( ATTDEF_RE )
- values.each do |attdef|
- unless attdef[3] == "#IMPLIED"
- attdef.compact!
- val = attdef[3]
- val = attdef[4] if val == "#FIXED "
- pairs[attdef[0]] = val
- if attdef[0] =~ /^xmlns:(.*)/
- @nsstack[0] << $1
- end
- end
- end
- return [ :attlistdecl, element, pairs, contents ]
- when NOTATIONDECL_START
- md = nil
- if @source.match( PUBLIC )
- md = @source.match( PUBLIC, true )
- vals = [md[1],md[2],md[4],md[6]]
- elsif @source.match( SYSTEM )
- md = @source.match( SYSTEM, true )
- vals = [md[1],md[2],nil,md[4]]
- else
- raise REXML::ParseException.new( "error parsing notation: no matching pattern", @source )
- end
- return [ :notationdecl, *vals ]
- when DOCTYPE_END
- @document_status = :after_doctype
- @source.match( DOCTYPE_END, true )
- return [ :end_doctype ]
- end
- end
- begin
- if @source.buffer[0] == ?<
- if @source.buffer[1] == ?/
- @nsstack.shift
- last_tag = @tags.pop
- md = @source.match( CLOSE_MATCH, true )
- if md and !last_tag
- message = "Unexpected top-level end tag (got '#{md[1]}')"
- raise REXML::ParseException.new(message, @source)
- end
- if md.nil? or last_tag != md[1]
- message = "Missing end tag for '#{last_tag}'"
- message << " (got '#{md[1]}')" if md
- raise REXML::ParseException.new(message, @source)
- end
- return [ :end_element, last_tag ]
- elsif @source.buffer[1] == ?!
- md = @source.match(/\A(\s*[^>]*>)/um)
- #STDERR.puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}"
- raise REXML::ParseException.new("Malformed node", @source) unless md
- if md[0][2] == ?-
- md = @source.match( COMMENT_PATTERN, true )
-
- case md[1]
- when /--/, /-\z/
- raise REXML::ParseException.new("Malformed comment", @source)
- end
-
- return [ :comment, md[1] ] if md
- else
- md = @source.match( CDATA_PATTERN, true )
- return [ :cdata, md[1] ] if md
- end
- raise REXML::ParseException.new( "Declarations can only occur "+
- "in the doctype declaration.", @source)
- elsif @source.buffer[1] == ??
- return process_instruction
- else
- # Get the next tag
- md = @source.match(TAG_MATCH, true)
- unless md
- raise REXML::ParseException.new("malformed XML: missing tag start", @source)
- end
- prefixes = Set.new
- prefixes << md[2] if md[2]
- @nsstack.unshift(curr_ns=Set.new)
- attributes, closed = parse_attributes(prefixes, curr_ns)
- # Verify that all of the prefixes have been defined
- for prefix in prefixes
- unless @nsstack.find{|k| k.member?(prefix)}
- raise UndefinedNamespaceException.new(prefix,@source,self)
- end
- end
-
- if closed
- @closed = md[1]
- @nsstack.shift
- else
- @tags.push( md[1] )
- end
- return [ :start_element, md[1], attributes ]
- end
- else
- md = @source.match( TEXT_PATTERN, true )
- if md[0].length == 0
- @source.match( /(\s+)/, true )
- end
- #STDERR.puts "GOT #{md[1].inspect}" unless md[0].length == 0
- #return [ :text, "" ] if md[0].length == 0
- # unnormalized = Text::unnormalize( md[1], self )
- # return PullEvent.new( :text, md[1], unnormalized )
- return [ :text, md[1] ]
- end
- rescue REXML::UndefinedNamespaceException
- raise
- rescue REXML::ParseException
- raise
- rescue => error
- raise REXML::ParseException.new( "Exception parsing",
- @source, self, (error ? error : $!) )
- end
- return [ :dummy ]
- end
- private :pull_event
-
- def entity( reference, entities )
- value = nil
- value = entities[ reference ] if entities
- if not value
- value = DEFAULT_ENTITIES[ reference ]
- value = value[2] if value
- end
- unnormalize( value, entities ) if value
- end
-
- # Escapes all possible entities
- def normalize( input, entities=nil, entity_filter=nil )
- copy = input.clone
- # Doing it like this rather than in a loop improves the speed
- copy.gsub!( EREFERENCE, '&amp;' )
- entities.each do |key, value|
- copy.gsub!( value, "&#{key};" ) unless entity_filter and
- entity_filter.include?(entity)
- end if entities
- copy.gsub!( EREFERENCE, '&amp;' )
- DEFAULT_ENTITIES.each do |key, value|
- copy.gsub!( value[3], value[1] )
- end
- copy
- end
-
- # Unescapes all possible entities
- def unnormalize( string, entities=nil, filter=nil )
- rv = string.clone
- rv.gsub!( /\r\n?/, "\n" )
- matches = rv.scan( REFERENCE_RE )
- return rv if matches.size == 0
- rv.gsub!( /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/ ) {
- m=$1
- m = "0#{m}" if m[0] == ?x
- [Integer(m)].pack('U*')
- }
- matches.collect!{|x|x[0]}.compact!
- if matches.size > 0
- matches.each do |entity_reference|
- unless filter and filter.include?(entity_reference)
- entity_value = entity( entity_reference, entities )
- if entity_value
- re = /&#{entity_reference};/
- rv.gsub!( re, entity_value )
- else
- er = DEFAULT_ENTITIES[entity_reference]
- rv.gsub!( er[0], er[2] ) if er
- end
- end
- end
- rv.gsub!( /&amp;/, '&' )
- end
- rv
- end
-
- private
- def need_source_encoding_update?(xml_declaration_encoding)
- return false if xml_declaration_encoding.nil?
- return false if /\AUTF-16\z/i =~ xml_declaration_encoding
- true
- end
-
- def process_instruction
- match_data = @source.match(INSTRUCTION_PATTERN, true)
- unless match_data
- message = "Invalid processing instruction node"
- raise REXML::ParseException.new(message, @source)
- end
- [:processing_instruction, match_data[1], match_data[2]]
- end
-
- def parse_attributes(prefixes, curr_ns)
- attributes = {}
- closed = false
- match_data = @source.match(/^(.*?)(\/)?>/um, true)
- if match_data.nil?
- message = "Start tag isn't ended"
- raise REXML::ParseException.new(message, @source)
- end
-
- raw_attributes = match_data[1]
- closed = !match_data[2].nil?
- return attributes, closed if raw_attributes.nil?
- return attributes, closed if raw_attributes.empty?
-
- scanner = StringScanner.new(raw_attributes)
- until scanner.eos?
- if scanner.scan(/\s+/)
- break if scanner.eos?
- end
-
- pos = scanner.pos
- loop do
- break if scanner.scan(ATTRIBUTE_PATTERN)
- unless scanner.scan(QNAME)
- message = "Invalid attribute name: <#{scanner.rest}>"
- raise REXML::ParseException.new(message, @source)
- end
- name = scanner[0]
- unless scanner.scan(/\s*=\s*/um)
- message = "Missing attribute equal: <#{name}>"
- raise REXML::ParseException.new(message, @source)
- end
- quote = scanner.scan(/['"]/)
- unless quote
- message = "Missing attribute value start quote: <#{name}>"
- raise REXML::ParseException.new(message, @source)
- end
- unless scanner.scan(/.*#{Regexp.escape(quote)}/um)
- match_data = @source.match(/^(.*?)(\/)?>/um, true)
- if match_data
- scanner << "/" if closed
- scanner << ">"
- scanner << match_data[1]
- scanner.pos = pos
- closed = !match_data[2].nil?
- next
- end
- message =
- "Missing attribute value end quote: <#{name}>: <#{quote}>"
- raise REXML::ParseException.new(message, @source)
- end
- end
- name = scanner[1]
- prefix = scanner[2]
- local_part = scanner[3]
- # quote = scanner[4]
- value = scanner[5]
- if prefix == "xmlns"
- if local_part == "xml"
- if value != "http://www.w3.org/XML/1998/namespace"
- msg = "The 'xml' prefix must not be bound to any other namespace "+
- "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
- raise REXML::ParseException.new( msg, @source, self )
- end
- elsif local_part == "xmlns"
- msg = "The 'xmlns' prefix must not be declared "+
- "(http://www.w3.org/TR/REC-xml-names/#ns-decl)"
- raise REXML::ParseException.new( msg, @source, self)
- end
- curr_ns << local_part
- elsif prefix
- prefixes << prefix unless prefix == "xml"
- end
-
- if attributes.has_key?(name)
- msg = "Duplicate attribute #{name.inspect}"
- raise REXML::ParseException.new(msg, @source, self)
- end
-
- attributes[name] = value
- end
- return attributes, closed
- end
- end
- end
-end
-
-=begin
- case event[0]
- when :start_element
- when :text
- when :end_element
- when :processing_instruction
- when :cdata
- when :comment
- when :xmldecl
- when :start_doctype
- when :end_doctype
- when :externalentity
- when :elementdecl
- when :entity
- when :attlistdecl
- when :notationdecl
- when :end_doctype
- end
-=end
diff --git a/lib/rexml/parsers/lightparser.rb b/lib/rexml/parsers/lightparser.rb
deleted file mode 100644
index bdc08276a9a..00000000000
--- a/lib/rexml/parsers/lightparser.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: false
-require_relative 'streamparser'
-require_relative 'baseparser'
-require_relative '../light/node'
-
-module REXML
- module Parsers
- class LightParser
- def initialize stream
- @stream = stream
- @parser = REXML::Parsers::BaseParser.new( stream )
- end
-
- def add_listener( listener )
- @parser.add_listener( listener )
- end
-
- def rewind
- @stream.rewind
- @parser.stream = @stream
- end
-
- def parse
- root = context = [ :document ]
- while true
- event = @parser.pull
- case event[0]
- when :end_document
- break
- when :start_element, :start_doctype
- new_node = event
- context << new_node
- new_node[1,0] = [context]
- context = new_node
- when :end_element, :end_doctype
- context = context[1]
- else
- new_node = event
- context << new_node
- new_node[1,0] = [context]
- end
- end
- root
- end
- end
-
- # An element is an array. The array contains:
- # 0 The parent element
- # 1 The tag name
- # 2 A hash of attributes
- # 3..-1 The child elements
- # An element is an array of size > 3
- # Text is a String
- # PIs are [ :processing_instruction, target, data ]
- # Comments are [ :comment, data ]
- # DocTypes are DocType structs
- # The root is an array with XMLDecls, Text, DocType, Array, Text
- end
-end
diff --git a/lib/rexml/parsers/pullparser.rb b/lib/rexml/parsers/pullparser.rb
deleted file mode 100644
index f8b232a2cd3..00000000000
--- a/lib/rexml/parsers/pullparser.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-# frozen_string_literal: false
-require 'forwardable'
-
-require_relative '../parseexception'
-require_relative 'baseparser'
-require_relative '../xmltokens'
-
-module REXML
- module Parsers
- # = Using the Pull Parser
- # <em>This API is experimental, and subject to change.</em>
- # parser = PullParser.new( "<a>text<b att='val'/>txet</a>" )
- # while parser.has_next?
- # res = parser.next
- # puts res[1]['att'] if res.start_tag? and res[0] == 'b'
- # end
- # See the PullEvent class for information on the content of the results.
- # The data is identical to the arguments passed for the various events to
- # the StreamListener API.
- #
- # Notice that:
- # parser = PullParser.new( "<a>BAD DOCUMENT" )
- # while parser.has_next?
- # res = parser.next
- # raise res[1] if res.error?
- # end
- #
- # Nat Price gave me some good ideas for the API.
- class PullParser
- include XMLTokens
- extend Forwardable
-
- def_delegators( :@parser, :has_next? )
- def_delegators( :@parser, :entity )
- def_delegators( :@parser, :empty? )
- def_delegators( :@parser, :source )
-
- def initialize stream
- @entities = {}
- @listeners = nil
- @parser = BaseParser.new( stream )
- @my_stack = []
- end
-
- def add_listener( listener )
- @listeners = [] unless @listeners
- @listeners << listener
- end
-
- def each
- while has_next?
- yield self.pull
- end
- end
-
- def peek depth=0
- if @my_stack.length <= depth
- (depth - @my_stack.length + 1).times {
- e = PullEvent.new(@parser.pull)
- @my_stack.push(e)
- }
- end
- @my_stack[depth]
- end
-
- def pull
- return @my_stack.shift if @my_stack.length > 0
-
- event = @parser.pull
- case event[0]
- when :entitydecl
- @entities[ event[1] ] =
- event[2] unless event[2] =~ /PUBLIC|SYSTEM/
- when :text
- unnormalized = @parser.unnormalize( event[1], @entities )
- event << unnormalized
- end
- PullEvent.new( event )
- end
-
- def unshift token
- @my_stack.unshift token
- end
- end
-
- # A parsing event. The contents of the event are accessed as an +Array?,
- # and the type is given either by the ...? methods, or by accessing the
- # +type+ accessor. The contents of this object vary from event to event,
- # but are identical to the arguments passed to +StreamListener+s for each
- # event.
- class PullEvent
- # The type of this event. Will be one of :tag_start, :tag_end, :text,
- # :processing_instruction, :comment, :doctype, :attlistdecl, :entitydecl,
- # :notationdecl, :entity, :cdata, :xmldecl, or :error.
- def initialize(arg)
- @contents = arg
- end
-
- def []( start, endd=nil)
- if start.kind_of? Range
- @contents.slice( start.begin+1 .. start.end )
- elsif start.kind_of? Numeric
- if endd.nil?
- @contents.slice( start+1 )
- else
- @contents.slice( start+1, endd )
- end
- else
- raise "Illegal argument #{start.inspect} (#{start.class})"
- end
- end
-
- def event_type
- @contents[0]
- end
-
- # Content: [ String tag_name, Hash attributes ]
- def start_element?
- @contents[0] == :start_element
- end
-
- # Content: [ String tag_name ]
- def end_element?
- @contents[0] == :end_element
- end
-
- # Content: [ String raw_text, String unnormalized_text ]
- def text?
- @contents[0] == :text
- end
-
- # Content: [ String text ]
- def instruction?
- @contents[0] == :processing_instruction
- end
-
- # Content: [ String text ]
- def comment?
- @contents[0] == :comment
- end
-
- # Content: [ String name, String pub_sys, String long_name, String uri ]
- def doctype?
- @contents[0] == :start_doctype
- end
-
- # Content: [ String text ]
- def attlistdecl?
- @contents[0] == :attlistdecl
- end
-
- # Content: [ String text ]
- def elementdecl?
- @contents[0] == :elementdecl
- end
-
- # Due to the wonders of DTDs, an entity declaration can be just about
- # anything. There's no way to normalize it; you'll have to interpret the
- # content yourself. However, the following is true:
- #
- # * If the entity declaration is an internal entity:
- # [ String name, String value ]
- # Content: [ String text ]
- def entitydecl?
- @contents[0] == :entitydecl
- end
-
- # Content: [ String text ]
- def notationdecl?
- @contents[0] == :notationdecl
- end
-
- # Content: [ String text ]
- def entity?
- @contents[0] == :entity
- end
-
- # Content: [ String text ]
- def cdata?
- @contents[0] == :cdata
- end
-
- # Content: [ String version, String encoding, String standalone ]
- def xmldecl?
- @contents[0] == :xmldecl
- end
-
- def error?
- @contents[0] == :error
- end
-
- def inspect
- @contents[0].to_s + ": " + @contents[1..-1].inspect
- end
- end
- end
-end
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
deleted file mode 100644
index 6a24ce2227a..00000000000
--- a/lib/rexml/parsers/sax2parser.rb
+++ /dev/null
@@ -1,273 +0,0 @@
-# frozen_string_literal: false
-require_relative 'baseparser'
-require_relative '../parseexception'
-require_relative '../namespace'
-require_relative '../text'
-
-module REXML
- module Parsers
- # SAX2Parser
- class SAX2Parser
- def initialize source
- @parser = BaseParser.new(source)
- @listeners = []
- @procs = []
- @namespace_stack = []
- @has_listeners = false
- @tag_stack = []
- @entities = {}
- end
-
- def source
- @parser.source
- end
-
- def add_listener( listener )
- @parser.add_listener( listener )
- end
-
- # Listen arguments:
- #
- # Symbol, Array, Block
- # Listen to Symbol events on Array elements
- # Symbol, Block
- # Listen to Symbol events
- # Array, Listener
- # Listen to all events on Array elements
- # Array, Block
- # Listen to :start_element events on Array elements
- # Listener
- # Listen to All events
- #
- # Symbol can be one of: :start_element, :end_element,
- # :start_prefix_mapping, :end_prefix_mapping, :characters,
- # :processing_instruction, :doctype, :attlistdecl, :elementdecl,
- # :entitydecl, :notationdecl, :cdata, :xmldecl, :comment
- #
- # There is an additional symbol that can be listened for: :progress.
- # This will be called for every event generated, passing in the current
- # stream position.
- #
- # Array contains regular expressions or strings which will be matched
- # against fully qualified element names.
- #
- # Listener must implement the methods in SAX2Listener
- #
- # Block will be passed the same arguments as a SAX2Listener method would
- # be, where the method name is the same as the matched Symbol.
- # See the SAX2Listener for more information.
- def listen( *args, &blok )
- if args[0].kind_of? Symbol
- if args.size == 2
- args[1].each { |match| @procs << [args[0], match, blok] }
- else
- add( [args[0], nil, blok] )
- end
- elsif args[0].kind_of? Array
- if args.size == 2
- args[0].each { |match| add( [nil, match, args[1]] ) }
- else
- args[0].each { |match| add( [ :start_element, match, blok ] ) }
- end
- else
- add([nil, nil, args[0]])
- end
- end
-
- def deafen( listener=nil, &blok )
- if listener
- @listeners.delete_if {|item| item[-1] == listener }
- @has_listeners = false if @listeners.size == 0
- else
- @procs.delete_if {|item| item[-1] == blok }
- end
- end
-
- def parse
- @procs.each { |sym,match,block| block.call if sym == :start_document }
- @listeners.each { |sym,match,block|
- block.start_document if sym == :start_document or sym.nil?
- }
- context = []
- while true
- event = @parser.pull
- case event[0]
- when :end_document
- handle( :end_document )
- break
- when :start_doctype
- handle( :doctype, *event[1..-1])
- when :end_doctype
- context = context[1]
- when :start_element
- @tag_stack.push(event[1])
- # find the observers for namespaces
- procs = get_procs( :start_prefix_mapping, event[1] )
- listeners = get_listeners( :start_prefix_mapping, event[1] )
- if procs or listeners
- # break out the namespace declarations
- # The attributes live in event[2]
- event[2].each {|n, v| event[2][n] = @parser.normalize(v)}
- nsdecl = event[2].find_all { |n, value| n =~ /^xmlns(:|$)/ }
- nsdecl.collect! { |n, value| [ n[6..-1], value ] }
- @namespace_stack.push({})
- nsdecl.each do |n,v|
- @namespace_stack[-1][n] = v
- # notify observers of namespaces
- procs.each { |ob| ob.call( n, v ) } if procs
- listeners.each { |ob| ob.start_prefix_mapping(n, v) } if listeners
- end
- end
- event[1] =~ Namespace::NAMESPLIT
- prefix = $1
- local = $2
- uri = get_namespace(prefix)
- # find the observers for start_element
- procs = get_procs( :start_element, event[1] )
- listeners = get_listeners( :start_element, event[1] )
- # notify observers
- procs.each { |ob| ob.call( uri, local, event[1], event[2] ) } if procs
- listeners.each { |ob|
- ob.start_element( uri, local, event[1], event[2] )
- } if listeners
- when :end_element
- @tag_stack.pop
- event[1] =~ Namespace::NAMESPLIT
- prefix = $1
- local = $2
- uri = get_namespace(prefix)
- # find the observers for start_element
- procs = get_procs( :end_element, event[1] )
- listeners = get_listeners( :end_element, event[1] )
- # notify observers
- procs.each { |ob| ob.call( uri, local, event[1] ) } if procs
- listeners.each { |ob|
- ob.end_element( uri, local, event[1] )
- } if listeners
-
- namespace_mapping = @namespace_stack.pop
- # find the observers for namespaces
- procs = get_procs( :end_prefix_mapping, event[1] )
- listeners = get_listeners( :end_prefix_mapping, event[1] )
- if procs or listeners
- namespace_mapping.each do |ns_prefix, ns_uri|
- # notify observers of namespaces
- procs.each { |ob| ob.call( ns_prefix ) } if procs
- listeners.each { |ob| ob.end_prefix_mapping(ns_prefix) } if listeners
- end
- end
- when :text
- #normalized = @parser.normalize( event[1] )
- #handle( :characters, normalized )
- copy = event[1].clone
-
- esub = proc { |match|
- if @entities.has_key?($1)
- @entities[$1].gsub(Text::REFERENCE, &esub)
- else
- match
- end
- }
-
- copy.gsub!( Text::REFERENCE, &esub )
- copy.gsub!( Text::NUMERICENTITY ) {|m|
- m=$1
- m = "0#{m}" if m[0] == ?x
- [Integer(m)].pack('U*')
- }
- handle( :characters, copy )
- when :entitydecl
- handle_entitydecl( event )
- when :processing_instruction, :comment, :attlistdecl,
- :elementdecl, :cdata, :notationdecl, :xmldecl
- handle( *event )
- end
- handle( :progress, @parser.position )
- end
- end
-
- private
- def handle( symbol, *arguments )
- tag = @tag_stack[-1]
- procs = get_procs( symbol, tag )
- listeners = get_listeners( symbol, tag )
- # notify observers
- procs.each { |ob| ob.call( *arguments ) } if procs
- listeners.each { |l|
- l.send( symbol.to_s, *arguments )
- } if listeners
- end
-
- def handle_entitydecl( event )
- @entities[ event[1] ] = event[2] if event.size == 3
- parameter_reference_p = false
- case event[2]
- when "SYSTEM"
- if event.size == 5
- if event.last == "%"
- parameter_reference_p = true
- else
- event[4, 0] = "NDATA"
- end
- end
- when "PUBLIC"
- if event.size == 6
- if event.last == "%"
- parameter_reference_p = true
- else
- event[5, 0] = "NDATA"
- end
- end
- else
- parameter_reference_p = (event.size == 4)
- end
- event[1, 0] = event.pop if parameter_reference_p
- handle( event[0], event[1..-1] )
- end
-
- # The following methods are duplicates, but it is faster than using
- # a helper
- def get_procs( symbol, name )
- return nil if @procs.size == 0
- @procs.find_all do |sym, match, block|
- (
- (sym.nil? or symbol == sym) and
- ((name.nil? and match.nil?) or match.nil? or (
- (name == match) or
- (match.kind_of? Regexp and name =~ match)
- )
- )
- )
- end.collect{|x| x[-1]}
- end
- def get_listeners( symbol, name )
- return nil if @listeners.size == 0
- @listeners.find_all do |sym, match, block|
- (
- (sym.nil? or symbol == sym) and
- ((name.nil? and match.nil?) or match.nil? or (
- (name == match) or
- (match.kind_of? Regexp and name =~ match)
- )
- )
- )
- end.collect{|x| x[-1]}
- end
-
- def add( pair )
- if pair[-1].respond_to? :call
- @procs << pair unless @procs.include? pair
- else
- @listeners << pair unless @listeners.include? pair
- @has_listeners = true
- end
- end
-
- def get_namespace( prefix )
- uris = (@namespace_stack.find_all { |ns| not ns[prefix].nil? }) ||
- (@namespace_stack.find { |ns| not ns[nil].nil? })
- uris[-1][prefix] unless uris.nil? or 0 == uris.size
- end
- end
- end
-end
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb
deleted file mode 100644
index 9e0eb0b363c..00000000000
--- a/lib/rexml/parsers/streamparser.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: false
-require_relative "baseparser"
-
-module REXML
- module Parsers
- class StreamParser
- def initialize source, listener
- @listener = listener
- @parser = BaseParser.new( source )
- @tag_stack = []
- end
-
- def add_listener( listener )
- @parser.add_listener( listener )
- end
-
- def parse
- # entity string
- while true
- event = @parser.pull
- case event[0]
- when :end_document
- unless @tag_stack.empty?
- tag_path = "/" + @tag_stack.join("/")
- raise ParseException.new("Missing end tag for '#{tag_path}'",
- @parser.source)
- end
- return
- when :start_element
- @tag_stack << event[1]
- attrs = event[2].each do |n, v|
- event[2][n] = @parser.unnormalize( v )
- end
- @listener.tag_start( event[1], attrs )
- when :end_element
- @listener.tag_end( event[1] )
- @tag_stack.pop
- when :text
- normalized = @parser.unnormalize( event[1] )
- @listener.text( normalized )
- when :processing_instruction
- @listener.instruction( *event[1,2] )
- when :start_doctype
- @listener.doctype( *event[1..-1] )
- when :end_doctype
- # FIXME: remove this condition for milestone:3.2
- @listener.doctype_end if @listener.respond_to? :doctype_end
- when :comment, :attlistdecl, :cdata, :xmldecl, :elementdecl
- @listener.send( event[0].to_s, *event[1..-1] )
- when :entitydecl, :notationdecl
- @listener.send( event[0].to_s, event[1..-1] )
- when :externalentity
- entity_reference = event[1]
- content = entity_reference.gsub(/\A%|;\z/, "")
- @listener.entity(content)
- end
- end
- end
- end
- end
-end
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
deleted file mode 100644
index bf9a42545b8..00000000000
--- a/lib/rexml/parsers/treeparser.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-# frozen_string_literal: false
-require_relative '../validation/validationexception'
-require_relative '../undefinednamespaceexception'
-
-module REXML
- module Parsers
- class TreeParser
- def initialize( source, build_context = Document.new )
- @build_context = build_context
- @parser = Parsers::BaseParser.new( source )
- end
-
- def add_listener( listener )
- @parser.add_listener( listener )
- end
-
- def parse
- tag_stack = []
- in_doctype = false
- entities = nil
- begin
- while true
- event = @parser.pull
- #STDERR.puts "TREEPARSER GOT #{event.inspect}"
- case event[0]
- when :end_document
- unless tag_stack.empty?
- raise ParseException.new("No close tag for #{@build_context.xpath}",
- @parser.source, @parser)
- end
- return
- when :start_element
- tag_stack.push(event[1])
- el = @build_context = @build_context.add_element( event[1] )
- event[2].each do |key, value|
- el.attributes[key]=Attribute.new(key,value,self)
- end
- when :end_element
- tag_stack.pop
- @build_context = @build_context.parent
- when :text
- if not in_doctype
- if @build_context[-1].instance_of? Text
- @build_context[-1] << event[1]
- else
- @build_context.add(
- Text.new(event[1], @build_context.whitespace, nil, true)
- ) unless (
- @build_context.ignore_whitespace_nodes and
- event[1].strip.size==0
- )
- end
- end
- when :comment
- c = Comment.new( event[1] )
- @build_context.add( c )
- when :cdata
- c = CData.new( event[1] )
- @build_context.add( c )
- when :processing_instruction
- @build_context.add( Instruction.new( event[1], event[2] ) )
- when :end_doctype
- in_doctype = false
- entities.each { |k,v| entities[k] = @build_context.entities[k].value }
- @build_context = @build_context.parent
- when :start_doctype
- doctype = DocType.new( event[1..-1], @build_context )
- @build_context = doctype
- entities = {}
- in_doctype = true
- when :attlistdecl
- n = AttlistDecl.new( event[1..-1] )
- @build_context.add( n )
- when :externalentity
- n = ExternalEntity.new( event[1] )
- @build_context.add( n )
- when :elementdecl
- n = ElementDecl.new( event[1] )
- @build_context.add(n)
- when :entitydecl
- entities[ event[1] ] = event[2] unless event[2] =~ /PUBLIC|SYSTEM/
- @build_context.add(Entity.new(event))
- when :notationdecl
- n = NotationDecl.new( *event[1..-1] )
- @build_context.add( n )
- when :xmldecl
- x = XMLDecl.new( event[1], event[2], event[3] )
- @build_context.add( x )
- end
- end
- rescue REXML::Validation::ValidationException
- raise
- rescue REXML::ParseException
- raise
- rescue
- raise ParseException.new( $!.message, @parser.source, @parser, $! )
- end
- end
- end
- end
-end
diff --git a/lib/rexml/parsers/ultralightparser.rb b/lib/rexml/parsers/ultralightparser.rb
deleted file mode 100644
index e0029f43da5..00000000000
--- a/lib/rexml/parsers/ultralightparser.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-# frozen_string_literal: false
-require_relative 'streamparser'
-require_relative 'baseparser'
-
-module REXML
- module Parsers
- class UltraLightParser
- def initialize stream
- @stream = stream
- @parser = REXML::Parsers::BaseParser.new( stream )
- end
-
- def add_listener( listener )
- @parser.add_listener( listener )
- end
-
- def rewind
- @stream.rewind
- @parser.stream = @stream
- end
-
- def parse
- root = context = []
- while true
- event = @parser.pull
- case event[0]
- when :end_document
- break
- when :end_doctype
- context = context[1]
- when :start_element, :start_doctype
- context << event
- event[1,0] = [context]
- context = event
- when :end_element
- context = context[1]
- else
- context << event
- end
- end
- root
- end
- end
-
- # An element is an array. The array contains:
- # 0 The parent element
- # 1 The tag name
- # 2 A hash of attributes
- # 3..-1 The child elements
- # An element is an array of size > 3
- # Text is a String
- # PIs are [ :processing_instruction, target, data ]
- # Comments are [ :comment, data ]
- # DocTypes are DocType structs
- # The root is an array with XMLDecls, Text, DocType, Array, Text
- end
-end
diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb
deleted file mode 100644
index d01d325e04d..00000000000
--- a/lib/rexml/parsers/xpathparser.rb
+++ /dev/null
@@ -1,675 +0,0 @@
-# frozen_string_literal: false
-require_relative '../namespace'
-require_relative '../xmltokens'
-
-module REXML
- module Parsers
- # You don't want to use this class. Really. Use XPath, which is a wrapper
- # for this class. Believe me. You don't want to poke around in here.
- # There is strange, dark magic at work in this code. Beware. Go back! Go
- # back while you still can!
- class XPathParser
- include XMLTokens
- LITERAL = /^'([^']*)'|^"([^"]*)"/u
-
- def namespaces=( namespaces )
- Functions::namespace_context = namespaces
- @namespaces = namespaces
- end
-
- def parse path
- path = path.dup
- path.gsub!(/([\(\[])\s+/, '\1') # Strip ignorable spaces
- path.gsub!( /\s+([\]\)])/, '\1')
- parsed = []
- OrExpr(path, parsed)
- parsed
- end
-
- def predicate path
- parsed = []
- Predicate( "[#{path}]", parsed )
- parsed
- end
-
- def abbreviate( path )
- path = path.kind_of?(String) ? parse( path ) : path
- string = ""
- document = false
- while path.size > 0
- op = path.shift
- case op
- when :node
- when :attribute
- string << "/" if string.size > 0
- string << "@"
- when :child
- string << "/" if string.size > 0
- when :descendant_or_self
- string << "/"
- when :self
- string << "."
- when :parent
- string << ".."
- when :any
- string << "*"
- when :text
- string << "text()"
- when :following, :following_sibling,
- :ancestor, :ancestor_or_self, :descendant,
- :namespace, :preceding, :preceding_sibling
- string << "/" unless string.size == 0
- string << op.to_s.tr("_", "-")
- string << "::"
- when :qname
- prefix = path.shift
- name = path.shift
- string << prefix+":" if prefix.size > 0
- string << name
- when :predicate
- string << '['
- string << predicate_to_string( path.shift ) {|x| abbreviate( x ) }
- string << ']'
- when :document
- document = true
- when :function
- string << path.shift
- string << "( "
- string << predicate_to_string( path.shift[0] ) {|x| abbreviate( x )}
- string << " )"
- when :literal
- string << %Q{ "#{path.shift}" }
- else
- string << "/" unless string.size == 0
- string << "UNKNOWN("
- string << op.inspect
- string << ")"
- end
- end
- string = "/"+string if document
- return string
- end
-
- def expand( path )
- path = path.kind_of?(String) ? parse( path ) : path
- string = ""
- document = false
- while path.size > 0
- op = path.shift
- case op
- when :node
- string << "node()"
- when :attribute, :child, :following, :following_sibling,
- :ancestor, :ancestor_or_self, :descendant, :descendant_or_self,
- :namespace, :preceding, :preceding_sibling, :self, :parent
- string << "/" unless string.size == 0
- string << op.to_s.tr("_", "-")
- string << "::"
- when :any
- string << "*"
- when :qname
- prefix = path.shift
- name = path.shift
- string << prefix+":" if prefix.size > 0
- string << name
- when :predicate
- string << '['
- string << predicate_to_string( path.shift ) { |x| expand(x) }
- string << ']'
- when :document
- document = true
- else
- string << "/" unless string.size == 0
- string << "UNKNOWN("
- string << op.inspect
- string << ")"
- end
- end
- string = "/"+string if document
- return string
- end
-
- def predicate_to_string( path, &block )
- string = ""
- case path[0]
- when :and, :or, :mult, :plus, :minus, :neq, :eq, :lt, :gt, :lteq, :gteq, :div, :mod, :union
- op = path.shift
- case op
- when :eq
- op = "="
- when :lt
- op = "<"
- when :gt
- op = ">"
- when :lteq
- op = "<="
- when :gteq
- op = ">="
- when :neq
- op = "!="
- when :union
- op = "|"
- end
- left = predicate_to_string( path.shift, &block )
- right = predicate_to_string( path.shift, &block )
- string << " "
- string << left
- string << " "
- string << op.to_s
- string << " "
- string << right
- string << " "
- when :function
- path.shift
- name = path.shift
- string << name
- string << "( "
- string << predicate_to_string( path.shift, &block )
- string << " )"
- when :literal
- path.shift
- string << " "
- string << path.shift.inspect
- string << " "
- else
- string << " "
- string << yield( path )
- string << " "
- end
- return string.squeeze(" ")
- end
-
- private
- #LocationPath
- # | RelativeLocationPath
- # | '/' RelativeLocationPath?
- # | '//' RelativeLocationPath
- def LocationPath path, parsed
- path = path.lstrip
- if path[0] == ?/
- parsed << :document
- if path[1] == ?/
- parsed << :descendant_or_self
- parsed << :node
- path = path[2..-1]
- else
- path = path[1..-1]
- end
- end
- return RelativeLocationPath( path, parsed ) if path.size > 0
- end
-
- #RelativeLocationPath
- # | Step
- # | (AXIS_NAME '::' | '@' | '') AxisSpecifier
- # NodeTest
- # Predicate
- # | '.' | '..' AbbreviatedStep
- # | RelativeLocationPath '/' Step
- # | RelativeLocationPath '//' Step
- AXIS = /^(ancestor|ancestor-or-self|attribute|child|descendant|descendant-or-self|following|following-sibling|namespace|parent|preceding|preceding-sibling|self)::/
- def RelativeLocationPath path, parsed
- loop do
- original_path = path
- path = path.lstrip
-
- return original_path if path.empty?
-
- # (axis or @ or <child::>) nodetest predicate >
- # OR > / Step
- # (. or ..) >
- if path[0] == ?.
- if path[1] == ?.
- parsed << :parent
- parsed << :node
- path = path[2..-1]
- else
- parsed << :self
- parsed << :node
- path = path[1..-1]
- end
- else
- if path[0] == ?@
- parsed << :attribute
- path = path[1..-1]
- # Goto Nodetest
- elsif path =~ AXIS
- parsed << $1.tr('-','_').intern
- path = $'
- # Goto Nodetest
- else
- parsed << :child
- end
-
- n = []
- path = NodeTest( path, n)
-
- path = Predicate( path, n )
-
- parsed.concat(n)
- end
-
- original_path = path
- path = path.lstrip
- return original_path if path.empty?
-
- return original_path if path[0] != ?/
-
- if path[1] == ?/
- parsed << :descendant_or_self
- parsed << :node
- path = path[2..-1]
- else
- path = path[1..-1]
- end
- end
- end
-
- # Returns a 1-1 map of the nodeset
- # The contents of the resulting array are either:
- # true/false, if a positive match
- # String, if a name match
- #NodeTest
- # | ('*' | NCNAME ':' '*' | QNAME) NameTest
- # | '*' ':' NCNAME NameTest since XPath 2.0
- # | NODE_TYPE '(' ')' NodeType
- # | PI '(' LITERAL ')' PI
- # | '[' expr ']' Predicate
- PREFIX_WILDCARD = /^\*:(#{NCNAME_STR})/u
- LOCAL_NAME_WILDCARD = /^(#{NCNAME_STR}):\*/u
- QNAME = Namespace::NAMESPLIT
- NODE_TYPE = /^(comment|text|node)\(\s*\)/m
- PI = /^processing-instruction\(/
- def NodeTest path, parsed
- original_path = path
- path = path.lstrip
- case path
- when PREFIX_WILDCARD
- prefix = nil
- name = $1
- path = $'
- parsed << :qname
- parsed << prefix
- parsed << name
- when /^\*/
- path = $'
- parsed << :any
- when NODE_TYPE
- type = $1
- path = $'
- parsed << type.tr('-', '_').intern
- when PI
- path = $'
- literal = nil
- if path !~ /^\s*\)/
- path =~ LITERAL
- literal = $1
- path = $'
- raise ParseException.new("Missing ')' after processing instruction") if path[0] != ?)
- path = path[1..-1]
- end
- parsed << :processing_instruction
- parsed << (literal || '')
- when LOCAL_NAME_WILDCARD
- prefix = $1
- path = $'
- parsed << :namespace
- parsed << prefix
- when QNAME
- prefix = $1
- name = $2
- path = $'
- prefix = "" unless prefix
- parsed << :qname
- parsed << prefix
- parsed << name
- else
- path = original_path
- end
- return path
- end
-
- # Filters the supplied nodeset on the predicate(s)
- def Predicate path, parsed
- original_path = path
- path = path.lstrip
- return original_path unless path[0] == ?[
- predicates = []
- while path[0] == ?[
- path, expr = get_group(path)
- predicates << expr[1..-2] if expr
- end
- predicates.each{ |pred|
- preds = []
- parsed << :predicate
- parsed << preds
- OrExpr(pred, preds)
- }
- path
- end
-
- # The following return arrays of true/false, a 1-1 mapping of the
- # supplied nodeset, except for axe(), which returns a filtered
- # nodeset
-
- #| OrExpr S 'or' S AndExpr
- #| AndExpr
- def OrExpr path, parsed
- n = []
- rest = AndExpr( path, n )
- if rest != path
- while rest =~ /^\s*( or )/
- n = [ :or, n, [] ]
- rest = AndExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| AndExpr S 'and' S EqualityExpr
- #| EqualityExpr
- def AndExpr path, parsed
- n = []
- rest = EqualityExpr( path, n )
- if rest != path
- while rest =~ /^\s*( and )/
- n = [ :and, n, [] ]
- rest = EqualityExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| EqualityExpr ('=' | '!=') RelationalExpr
- #| RelationalExpr
- def EqualityExpr path, parsed
- n = []
- rest = RelationalExpr( path, n )
- if rest != path
- while rest =~ /^\s*(!?=)\s*/
- if $1[0] == ?!
- n = [ :neq, n, [] ]
- else
- n = [ :eq, n, [] ]
- end
- rest = RelationalExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| RelationalExpr ('<' | '>' | '<=' | '>=') AdditiveExpr
- #| AdditiveExpr
- def RelationalExpr path, parsed
- n = []
- rest = AdditiveExpr( path, n )
- if rest != path
- while rest =~ /^\s*([<>]=?)\s*/
- if $1[0] == ?<
- sym = "lt"
- else
- sym = "gt"
- end
- sym << "eq" if $1[-1] == ?=
- n = [ sym.intern, n, [] ]
- rest = AdditiveExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| AdditiveExpr ('+' | '-') MultiplicativeExpr
- #| MultiplicativeExpr
- def AdditiveExpr path, parsed
- n = []
- rest = MultiplicativeExpr( path, n )
- if rest != path
- while rest =~ /^\s*(\+|-)\s*/
- if $1[0] == ?+
- n = [ :plus, n, [] ]
- else
- n = [ :minus, n, [] ]
- end
- rest = MultiplicativeExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| MultiplicativeExpr ('*' | S ('div' | 'mod') S) UnaryExpr
- #| UnaryExpr
- def MultiplicativeExpr path, parsed
- n = []
- rest = UnaryExpr( path, n )
- if rest != path
- while rest =~ /^\s*(\*| div | mod )\s*/
- if $1[0] == ?*
- n = [ :mult, n, [] ]
- elsif $1.include?( "div" )
- n = [ :div, n, [] ]
- else
- n = [ :mod, n, [] ]
- end
- rest = UnaryExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace(n)
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| '-' UnaryExpr
- #| UnionExpr
- def UnaryExpr path, parsed
- path =~ /^(\-*)/
- path = $'
- if $1 and (($1.size % 2) != 0)
- mult = -1
- else
- mult = 1
- end
- parsed << :neg if mult < 0
-
- n = []
- path = UnionExpr( path, n )
- parsed.concat( n )
- path
- end
-
- #| UnionExpr '|' PathExpr
- #| PathExpr
- def UnionExpr path, parsed
- n = []
- rest = PathExpr( path, n )
- if rest != path
- while rest =~ /^\s*(\|)\s*/
- n = [ :union, n, [] ]
- rest = PathExpr( $', n[-1] )
- end
- end
- if parsed.size == 0 and n.size != 0
- parsed.replace( n )
- elsif n.size > 0
- parsed << n
- end
- rest
- end
-
- #| LocationPath
- #| FilterExpr ('/' | '//') RelativeLocationPath
- def PathExpr path, parsed
- path = path.lstrip
- n = []
- rest = FilterExpr( path, n )
- if rest != path
- if rest and rest[0] == ?/
- rest = RelativeLocationPath(rest, n)
- parsed.concat(n)
- return rest
- end
- end
- rest = LocationPath(rest, n) if rest =~ /\A[\/\.\@\[\w*]/
- parsed.concat(n)
- return rest
- end
-
- #| FilterExpr Predicate
- #| PrimaryExpr
- def FilterExpr path, parsed
- n = []
- path = PrimaryExpr( path, n )
- path = Predicate(path, n)
- parsed.concat(n)
- path
- end
-
- #| VARIABLE_REFERENCE
- #| '(' expr ')'
- #| LITERAL
- #| NUMBER
- #| FunctionCall
- VARIABLE_REFERENCE = /^\$(#{NAME_STR})/u
- NUMBER = /^(\d*\.?\d+)/
- NT = /^comment|text|processing-instruction|node$/
- def PrimaryExpr path, parsed
- case path
- when VARIABLE_REFERENCE
- varname = $1
- path = $'
- parsed << :variable
- parsed << varname
- #arry << @variables[ varname ]
- when /^(\w[-\w]*)(?:\()/
- fname = $1
- tmp = $'
- return path if fname =~ NT
- path = tmp
- parsed << :function
- parsed << fname
- path = FunctionCall(path, parsed)
- when NUMBER
- varname = $1.nil? ? $2 : $1
- path = $'
- parsed << :literal
- parsed << (varname.include?('.') ? varname.to_f : varname.to_i)
- when LITERAL
- varname = $1.nil? ? $2 : $1
- path = $'
- parsed << :literal
- parsed << varname
- when /^\(/ #/
- path, contents = get_group(path)
- contents = contents[1..-2]
- n = []
- OrExpr( contents, n )
- parsed.concat(n)
- end
- path
- end
-
- #| FUNCTION_NAME '(' ( expr ( ',' expr )* )? ')'
- def FunctionCall rest, parsed
- path, arguments = parse_args(rest)
- argset = []
- for argument in arguments
- args = []
- OrExpr( argument, args )
- argset << args
- end
- parsed << argset
- path
- end
-
- # get_group( '[foo]bar' ) -> ['bar', '[foo]']
- def get_group string
- ind = 0
- depth = 0
- st = string[0,1]
- en = (st == "(" ? ")" : "]")
- begin
- case string[ind,1]
- when st
- depth += 1
- when en
- depth -= 1
- end
- ind += 1
- end while depth > 0 and ind < string.length
- return nil unless depth==0
- [string[ind..-1], string[0..ind-1]]
- end
-
- def parse_args( string )
- arguments = []
- ind = 0
- inquot = false
- inapos = false
- depth = 1
- begin
- case string[ind]
- when ?"
- inquot = !inquot unless inapos
- when ?'
- inapos = !inapos unless inquot
- else
- unless inquot or inapos
- case string[ind]
- when ?(
- depth += 1
- if depth == 1
- string = string[1..-1]
- ind -= 1
- end
- when ?)
- depth -= 1
- if depth == 0
- s = string[0,ind].strip
- arguments << s unless s == ""
- string = string[ind+1..-1]
- end
- when ?,
- if depth == 1
- s = string[0,ind].strip
- arguments << s unless s == ""
- string = string[ind+1..-1]
- ind = -1
- end
- end
- end
- end
- ind += 1
- end while depth > 0 and ind < string.length
- return nil unless depth==0
- [string,arguments]
- end
- end
- end
-end
diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb
deleted file mode 100644
index a0466b25d9b..00000000000
--- a/lib/rexml/quickpath.rb
+++ /dev/null
@@ -1,266 +0,0 @@
-# frozen_string_literal: false
-require_relative 'functions'
-require_relative 'xmltokens'
-
-module REXML
- class QuickPath
- include Functions
- include XMLTokens
-
- # A base Hash object to be used when initializing a
- # default empty namespaces set.
- EMPTY_HASH = {}
-
- def QuickPath::first element, path, namespaces=EMPTY_HASH
- match(element, path, namespaces)[0]
- end
-
- def QuickPath::each element, path, namespaces=EMPTY_HASH, &block
- path = "*" unless path
- match(element, path, namespaces).each( &block )
- end
-
- def QuickPath::match element, path, namespaces=EMPTY_HASH
- raise "nil is not a valid xpath" unless path
- results = nil
- Functions::namespace_context = namespaces
- case path
- when /^\/([^\/]|$)/u
- # match on root
- path = path[1..-1]
- return [element.root.parent] if path == ''
- results = filter([element.root], path)
- when /^[-\w]*::/u
- results = filter([element], path)
- when /^\*/u
- results = filter(element.to_a, path)
- when /^[\[!\w:]/u
- # match on child
- children = element.to_a
- results = filter(children, path)
- else
- results = filter([element], path)
- end
- return results
- end
-
- # Given an array of nodes it filters the array based on the path. The
- # result is that when this method returns, the array will contain elements
- # which match the path
- def QuickPath::filter elements, path
- return elements if path.nil? or path == '' or elements.size == 0
- case path
- when /^\/\//u # Descendant
- return axe( elements, "descendant-or-self", $' )
- when /^\/?\b(\w[-\w]*)\b::/u # Axe
- return axe( elements, $1, $' )
- when /^\/(?=\b([:!\w][-\.\w]*:)?[-!\*\.\w]*\b([^:(]|$)|\*)/u # Child
- rest = $'
- results = []
- elements.each do |element|
- results |= filter( element.to_a, rest )
- end
- return results
- when /^\/?(\w[-\w]*)\(/u # / Function
- return function( elements, $1, $' )
- when Namespace::NAMESPLIT # Element name
- name = $2
- ns = $1
- rest = $'
- elements.delete_if do |element|
- !(element.kind_of? Element and
- (element.expanded_name == name or
- (element.name == name and
- element.namespace == Functions.namespace_context[ns])))
- end
- return filter( elements, rest )
- when /^\/\[/u
- matches = []
- elements.each do |element|
- matches |= predicate( element.to_a, path[1..-1] ) if element.kind_of? Element
- end
- return matches
- when /^\[/u # Predicate
- return predicate( elements, path )
- when /^\/?\.\.\./u # Ancestor
- return axe( elements, "ancestor", $' )
- when /^\/?\.\./u # Parent
- return filter( elements.collect{|e|e.parent}, $' )
- when /^\/?\./u # Self
- return filter( elements, $' )
- when /^\*/u # Any
- results = []
- elements.each do |element|
- results |= filter( [element], $' ) if element.kind_of? Element
- #if element.kind_of? Element
- # children = element.to_a
- # children.delete_if { |child| !child.kind_of?(Element) }
- # results |= filter( children, $' )
- #end
- end
- return results
- end
- return []
- end
-
- def QuickPath::axe( elements, axe_name, rest )
- matches = []
- matches = filter( elements.dup, rest ) if axe_name =~ /-or-self$/u
- case axe_name
- when /^descendant/u
- elements.each do |element|
- matches |= filter( element.to_a, "descendant-or-self::#{rest}" ) if element.kind_of? Element
- end
- when /^ancestor/u
- elements.each do |element|
- while element.parent
- matches << element.parent
- element = element.parent
- end
- end
- matches = filter( matches, rest )
- when "self"
- matches = filter( elements, rest )
- when "child"
- elements.each do |element|
- matches |= filter( element.to_a, rest ) if element.kind_of? Element
- end
- when "attribute"
- elements.each do |element|
- matches << element.attributes[ rest ] if element.kind_of? Element
- end
- when "parent"
- matches = filter(elements.collect{|element| element.parent}.uniq, rest)
- when "following-sibling"
- matches = filter(elements.collect{|element| element.next_sibling}.uniq,
- rest)
- when "previous-sibling"
- matches = filter(elements.collect{|element|
- element.previous_sibling}.uniq, rest )
- end
- return matches.uniq
- end
-
- OPERAND_ = '((?=(?:(?!and|or).)*[^\s<>=])[^\s<>=]+)'
- # A predicate filters a node-set with respect to an axis to produce a
- # new node-set. For each node in the node-set to be filtered, the
- # PredicateExpr is evaluated with that node as the context node, with
- # the number of nodes in the node-set as the context size, and with the
- # proximity position of the node in the node-set with respect to the
- # axis as the context position; if PredicateExpr evaluates to true for
- # that node, the node is included in the new node-set; otherwise, it is
- # not included.
- #
- # A PredicateExpr is evaluated by evaluating the Expr and converting
- # the result to a boolean. If the result is a number, the result will
- # be converted to true if the number is equal to the context position
- # and will be converted to false otherwise; if the result is not a
- # number, then the result will be converted as if by a call to the
- # boolean function. Thus a location path para[3] is equivalent to
- # para[position()=3].
- def QuickPath::predicate( elements, path )
- ind = 1
- bcount = 1
- while bcount > 0
- bcount += 1 if path[ind] == ?[
- bcount -= 1 if path[ind] == ?]
- ind += 1
- end
- ind -= 1
- predicate = path[1..ind-1]
- rest = path[ind+1..-1]
-
- # have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c'
- #
- predicate.gsub!(
- /#{OPERAND_}\s*([<>=])\s*#{OPERAND_}\s*([<>=])\s*#{OPERAND_}/u,
- '\1 \2 \3 and \3 \4 \5' )
- # Let's do some Ruby trickery to avoid some work:
- predicate.gsub!( /&/u, "&&" )
- predicate.gsub!( /=/u, "==" )
- predicate.gsub!( /@(\w[-\w.]*)/u, 'attribute("\1")' )
- predicate.gsub!( /\bmod\b/u, "%" )
- predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
- fname = $1
- fname.gsub( /-/u, "_" )
- }
-
- Functions.pair = [ 0, elements.size ]
- results = []
- elements.each do |element|
- Functions.pair[0] += 1
- Functions.node = element
- res = eval( predicate )
- case res
- when true
- results << element
- when Integer
- results << element if Functions.pair[0] == res
- when String
- results << element
- end
- end
- return filter( results, rest )
- end
-
- def QuickPath::attribute( name )
- return Functions.node.attributes[name] if Functions.node.kind_of? Element
- end
-
- def QuickPath::name()
- return Functions.node.name if Functions.node.kind_of? Element
- end
-
- def QuickPath::method_missing( id, *args )
- begin
- Functions.send( id.id2name, *args )
- rescue Exception
- raise "METHOD: #{id.id2name}(#{args.join ', '})\n#{$!.message}"
- end
- end
-
- def QuickPath::function( elements, fname, rest )
- args = parse_args( elements, rest )
- Functions.pair = [0, elements.size]
- results = []
- elements.each do |element|
- Functions.pair[0] += 1
- Functions.node = element
- res = Functions.send( fname, *args )
- case res
- when true
- results << element
- when Integer
- results << element if Functions.pair[0] == res
- end
- end
- return results
- end
-
- def QuickPath::parse_args( element, string )
- # /.*?(?:\)|,)/
- arguments = []
- buffer = ""
- while string and string != ""
- c = string[0]
- string.sub!(/^./u, "")
- case c
- when ?,
- # if depth = 1, then we start a new argument
- arguments << evaluate( buffer )
- #arguments << evaluate( string[0..count] )
- when ?(
- # start a new method call
- function( element, buffer, string )
- buffer = ""
- when ?)
- # close the method call and return arguments
- return arguments
- else
- buffer << c
- end
- end
- ""
- end
- end
-end
diff --git a/lib/rexml/rexml.gemspec b/lib/rexml/rexml.gemspec
deleted file mode 100644
index 263f013aae7..00000000000
--- a/lib/rexml/rexml.gemspec
+++ /dev/null
@@ -1,84 +0,0 @@
-begin
- require_relative "lib/rexml/rexml"
-rescue LoadError
- # for Ruby core repository
- require_relative "rexml"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "rexml"
- spec.version = REXML::VERSION
- spec.authors = ["Kouhei Sutou"]
- spec.email = ["kou@cozmixng.org"]
-
- spec.summary = %q{An XML toolkit for Ruby}
- spec.description = %q{An XML toolkit for Ruby}
- spec.homepage = "https://github.com/ruby/rexml"
- spec.license = "BSD-2-Clause"
-
- spec.files = [
- ".gitignore",
- ".travis.yml",
- "Gemfile",
- "LICENSE.txt",
- "NEWS.md",
- "README.md",
- "Rakefile",
- "lib/rexml/attlistdecl.rb",
- "lib/rexml/attribute.rb",
- "lib/rexml/cdata.rb",
- "lib/rexml/child.rb",
- "lib/rexml/comment.rb",
- "lib/rexml/doctype.rb",
- "lib/rexml/document.rb",
- "lib/rexml/dtd/attlistdecl.rb",
- "lib/rexml/dtd/dtd.rb",
- "lib/rexml/dtd/elementdecl.rb",
- "lib/rexml/dtd/entitydecl.rb",
- "lib/rexml/dtd/notationdecl.rb",
- "lib/rexml/element.rb",
- "lib/rexml/encoding.rb",
- "lib/rexml/entity.rb",
- "lib/rexml/formatters/default.rb",
- "lib/rexml/formatters/pretty.rb",
- "lib/rexml/formatters/transitive.rb",
- "lib/rexml/functions.rb",
- "lib/rexml/instruction.rb",
- "lib/rexml/light/node.rb",
- "lib/rexml/namespace.rb",
- "lib/rexml/node.rb",
- "lib/rexml/output.rb",
- "lib/rexml/parent.rb",
- "lib/rexml/parseexception.rb",
- "lib/rexml/parsers/baseparser.rb",
- "lib/rexml/parsers/lightparser.rb",
- "lib/rexml/parsers/pullparser.rb",
- "lib/rexml/parsers/sax2parser.rb",
- "lib/rexml/parsers/streamparser.rb",
- "lib/rexml/parsers/treeparser.rb",
- "lib/rexml/parsers/ultralightparser.rb",
- "lib/rexml/parsers/xpathparser.rb",
- "lib/rexml/quickpath.rb",
- "lib/rexml/rexml.rb",
- "lib/rexml/sax2listener.rb",
- "lib/rexml/security.rb",
- "lib/rexml/source.rb",
- "lib/rexml/streamlistener.rb",
- "lib/rexml/text.rb",
- "lib/rexml/undefinednamespaceexception.rb",
- "lib/rexml/validation/relaxng.rb",
- "lib/rexml/validation/validation.rb",
- "lib/rexml/validation/validationexception.rb",
- "lib/rexml/xmldecl.rb",
- "lib/rexml/xmltokens.rb",
- "lib/rexml/xpath.rb",
- "lib/rexml/xpath_parser.rb",
- "rexml.gemspec",
- ]
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
deleted file mode 100644
index 944d88a869f..00000000000
--- a/lib/rexml/rexml.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-# frozen_string_literal: false
-# REXML is an XML toolkit for Ruby[http://www.ruby-lang.org], in Ruby.
-#
-# REXML is a _pure_ Ruby, XML 1.0 conforming,
-# non-validating[http://www.w3.org/TR/2004/REC-xml-20040204/#sec-conformance]
-# toolkit with an intuitive API. REXML passes 100% of the non-validating Oasis
-# tests[http://www.oasis-open.org/committees/xml-conformance/xml-test-suite.shtml],
-# and provides tree, stream, SAX2, pull, and lightweight APIs. REXML also
-# includes a full XPath[http://www.w3c.org/tr/xpath] 1.0 implementation. Since
-# Ruby 1.8, REXML is included in the standard Ruby distribution.
-#
-# Main page:: http://www.germane-software.com/software/rexml
-# Author:: Sean Russell <serATgermaneHYPHENsoftwareDOTcom>
-# Date:: 2008/019
-# Version:: 3.1.7.3
-#
-# This API documentation can be downloaded from the REXML home page, or can
-# be accessed online[http://www.germane-software.com/software/rexml_doc]
-#
-# A tutorial is available in the REXML distribution in docs/tutorial.html,
-# or can be accessed
-# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
-module REXML
- COPYRIGHT = "Copyright 息 2001-2008 Sean Russell <ser@germane-software.com>"
- DATE = "2008/019"
- VERSION = "3.2.3"
- REVISION = ""
-
- Copyright = COPYRIGHT
- Version = VERSION
-end
diff --git a/lib/rexml/sax2listener.rb b/lib/rexml/sax2listener.rb
deleted file mode 100644
index 5afdc80890e..00000000000
--- a/lib/rexml/sax2listener.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-# frozen_string_literal: false
-module REXML
- # A template for stream parser listeners.
- # Note that the declarations (attlistdecl, elementdecl, etc) are trivially
- # processed; REXML doesn't yet handle doctype entity declarations, so you
- # have to parse them out yourself.
- # === Missing methods from SAX2
- # ignorable_whitespace
- # === Methods extending SAX2
- # +WARNING+
- # These methods are certainly going to change, until DTDs are fully
- # supported. Be aware of this.
- # start_document
- # end_document
- # doctype
- # elementdecl
- # attlistdecl
- # entitydecl
- # notationdecl
- # cdata
- # xmldecl
- # comment
- module SAX2Listener
- def start_document
- end
- def end_document
- end
- def start_prefix_mapping prefix, uri
- end
- def end_prefix_mapping prefix
- end
- def start_element uri, localname, qname, attributes
- end
- def end_element uri, localname, qname
- end
- def characters text
- end
- def processing_instruction target, data
- end
- # Handles a doctype declaration. Any attributes of the doctype which are
- # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar">
- # @p name the name of the doctype; EG, "me"
- # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC"
- # @p long_name the supplied long name, or nil. EG, "foo"
- # @p uri the uri of the doctype, or nil. EG, "bar"
- def doctype name, pub_sys, long_name, uri
- end
- # If a doctype includes an ATTLIST declaration, it will cause this
- # method to be called. The content is the declaration itself, unparsed.
- # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
- # attr CDATA #REQUIRED". This is the same for all of the .*decl
- # methods.
- def attlistdecl(element, pairs, contents)
- end
- # <!ELEMENT ...>
- def elementdecl content
- end
- # <!ENTITY ...>
- # The argument passed to this method is an array of the entity
- # declaration. It can be in a number of formats, but in general it
- # returns (example, result):
- # <!ENTITY % YN '"Yes"'>
- # ["%", "YN", "\"Yes\""]
- # <!ENTITY % YN 'Yes'>
- # ["%", "YN", "Yes"]
- # <!ENTITY WhatHeSaid "He said %YN;">
- # ["WhatHeSaid", "He said %YN;"]
- # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
- # ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
- # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
- # ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
- # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
- # ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "NDATA", "gif"]
- def entitydecl declaration
- end
- # <!NOTATION ...>
- def notationdecl name, public_or_system, public_id, system_id
- end
- # Called when <![CDATA[ ... ]]> is encountered in a document.
- # @p content "..."
- def cdata content
- end
- # Called when an XML PI is encountered in the document.
- # EG: <?xml version="1.0" encoding="utf"?>
- # @p version the version attribute value. EG, "1.0"
- # @p encoding the encoding attribute value, or nil. EG, "utf"
- # @p standalone the standalone attribute value, or nil. EG, nil
- # @p spaced the declaration is followed by a line break
- def xmldecl version, encoding, standalone
- end
- # Called when a comment is encountered.
- # @p comment The content of the comment
- def comment comment
- end
- def progress position
- end
- end
-end
diff --git a/lib/rexml/security.rb b/lib/rexml/security.rb
deleted file mode 100644
index 99b74607728..00000000000
--- a/lib/rexml/security.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: false
-module REXML
- module Security
- @@entity_expansion_limit = 10_000
-
- # Set the entity expansion limit. By default the limit is set to 10000.
- def self.entity_expansion_limit=( val )
- @@entity_expansion_limit = val
- end
-
- # Get the entity expansion limit. By default the limit is set to 10000.
- def self.entity_expansion_limit
- return @@entity_expansion_limit
- end
-
- @@entity_expansion_text_limit = 10_240
-
- # Set the entity expansion limit. By default the limit is set to 10240.
- def self.entity_expansion_text_limit=( val )
- @@entity_expansion_text_limit = val
- end
-
- # Get the entity expansion limit. By default the limit is set to 10240.
- def self.entity_expansion_text_limit
- return @@entity_expansion_text_limit
- end
- end
-end
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
deleted file mode 100644
index 90b370b989d..00000000000
--- a/lib/rexml/source.rb
+++ /dev/null
@@ -1,298 +0,0 @@
-# coding: US-ASCII
-# frozen_string_literal: false
-require_relative 'encoding'
-
-module REXML
- # Generates Source-s. USE THIS CLASS.
- class SourceFactory
- # Generates a Source object
- # @param arg Either a String, or an IO
- # @return a Source, or nil if a bad argument was given
- def SourceFactory::create_from(arg)
- if arg.respond_to? :read and
- arg.respond_to? :readline and
- arg.respond_to? :nil? and
- arg.respond_to? :eof?
- IOSource.new(arg)
- elsif arg.respond_to? :to_str
- require 'stringio'
- IOSource.new(StringIO.new(arg))
- elsif arg.kind_of? Source
- arg
- else
- raise "#{arg.class} is not a valid input stream. It must walk \n"+
- "like either a String, an IO, or a Source."
- end
- end
- end
-
- # A Source can be searched for patterns, and wraps buffers and other
- # objects and provides consumption of text
- class Source
- include Encoding
- # The current buffer (what we're going to read next)
- attr_reader :buffer
- # The line number of the last consumed text
- attr_reader :line
- attr_reader :encoding
-
- # Constructor
- # @param arg must be a String, and should be a valid XML document
- # @param encoding if non-null, sets the encoding of the source to this
- # value, overriding all encoding detection
- def initialize(arg, encoding=nil)
- @orig = @buffer = arg
- if encoding
- self.encoding = encoding
- else
- detect_encoding
- end
- @line = 0
- end
-
-
- # Inherited from Encoding
- # Overridden to support optimized en/decoding
- def encoding=(enc)
- return unless super
- encoding_updated
- end
-
- # Scans the source for a given pattern. Note, that this is not your
- # usual scan() method. For one thing, the pattern argument has some
- # requirements; for another, the source can be consumed. You can easily
- # confuse this method. Originally, the patterns were easier
- # to construct and this method more robust, because this method
- # generated search regexps on the fly; however, this was
- # computationally expensive and slowed down the entire REXML package
- # considerably, since this is by far the most commonly called method.
- # @param pattern must be a Regexp, and must be in the form of
- # /^\s*(#{your pattern, with no groups})(.*)/. The first group
- # will be returned; the second group is used if the consume flag is
- # set.
- # @param consume if true, the pattern returned will be consumed, leaving
- # everything after it in the Source.
- # @return the pattern, if found, or nil if the Source is empty or the
- # pattern is not found.
- def scan(pattern, cons=false)
- return nil if @buffer.nil?
- rv = @buffer.scan(pattern)
- @buffer = $' if cons and rv.size>0
- rv
- end
-
- def read
- end
-
- def consume( pattern )
- @buffer = $' if pattern.match( @buffer )
- end
-
- def match_to( char, pattern )
- return pattern.match(@buffer)
- end
-
- def match_to_consume( char, pattern )
- md = pattern.match(@buffer)
- @buffer = $'
- return md
- end
-
- def match(pattern, cons=false)
- md = pattern.match(@buffer)
- @buffer = $' if cons and md
- return md
- end
-
- # @return true if the Source is exhausted
- def empty?
- @buffer == ""
- end
-
- def position
- @orig.index( @buffer )
- end
-
- # @return the current line in the source
- def current_line
- lines = @orig.split
- res = lines.grep @buffer[0..30]
- res = res[-1] if res.kind_of? Array
- lines.index( res ) if res
- end
-
- private
- def detect_encoding
- buffer_encoding = @buffer.encoding
- detected_encoding = "UTF-8"
- begin
- @buffer.force_encoding("ASCII-8BIT")
- if @buffer[0, 2] == "\xfe\xff"
- @buffer[0, 2] = ""
- detected_encoding = "UTF-16BE"
- elsif @buffer[0, 2] == "\xff\xfe"
- @buffer[0, 2] = ""
- detected_encoding = "UTF-16LE"
- elsif @buffer[0, 3] == "\xef\xbb\xbf"
- @buffer[0, 3] = ""
- detected_encoding = "UTF-8"
- end
- ensure
- @buffer.force_encoding(buffer_encoding)
- end
- self.encoding = detected_encoding
- end
-
- def encoding_updated
- if @encoding != 'UTF-8'
- @buffer = decode(@buffer)
- @to_utf = true
- else
- @to_utf = false
- @buffer.force_encoding ::Encoding::UTF_8
- end
- end
- end
-
- # A Source that wraps an IO. See the Source class for method
- # documentation
- class IOSource < Source
- #attr_reader :block_size
-
- # block_size has been deprecated
- def initialize(arg, block_size=500, encoding=nil)
- @er_source = @source = arg
- @to_utf = false
- @pending_buffer = nil
-
- if encoding
- super("", encoding)
- else
- super(@source.read(3) || "")
- end
-
- if !@to_utf and
- @buffer.respond_to?(:force_encoding) and
- @source.respond_to?(:external_encoding) and
- @source.external_encoding != ::Encoding::UTF_8
- @force_utf8 = true
- else
- @force_utf8 = false
- end
- end
-
- def scan(pattern, cons=false)
- rv = super
- # You'll notice that this next section is very similar to the same
- # section in match(), but just a liiittle different. This is
- # because it is a touch faster to do it this way with scan()
- # than the way match() does it; enough faster to warrant duplicating
- # some code
- if rv.size == 0
- until @buffer =~ pattern or @source.nil?
- begin
- @buffer << readline
- rescue Iconv::IllegalSequence
- raise
- rescue
- @source = nil
- end
- end
- rv = super
- end
- rv.taint if RUBY_VERSION < '2.7'
- rv
- end
-
- def read
- begin
- @buffer << readline
- rescue Exception, NameError
- @source = nil
- end
- end
-
- def consume( pattern )
- match( pattern, true )
- end
-
- def match( pattern, cons=false )
- rv = pattern.match(@buffer)
- @buffer = $' if cons and rv
- while !rv and @source
- begin
- @buffer << readline
- rv = pattern.match(@buffer)
- @buffer = $' if cons and rv
- rescue
- @source = nil
- end
- end
- rv.taint if RUBY_VERSION < '2.7'
- rv
- end
-
- def empty?
- super and ( @source.nil? || @source.eof? )
- end
-
- def position
- @er_source.pos rescue 0
- end
-
- # @return the current line in the source
- def current_line
- begin
- pos = @er_source.pos # The byte position in the source
- lineno = @er_source.lineno # The XML < position in the source
- @er_source.rewind
- line = 0 # The \r\n position in the source
- begin
- while @er_source.pos < pos
- @er_source.readline
- line += 1
- end
- rescue
- end
- @er_source.seek(pos)
- rescue IOError
- pos = -1
- line = -1
- end
- [pos, lineno, line]
- end
-
- private
- def readline
- str = @source.readline(@line_break)
- if @pending_buffer
- if str.nil?
- str = @pending_buffer
- else
- str = @pending_buffer + str
- end
- @pending_buffer = nil
- end
- return nil if str.nil?
-
- if @to_utf
- decode(str)
- else
- str.force_encoding(::Encoding::UTF_8) if @force_utf8
- str
- end
- end
-
- def encoding_updated
- case @encoding
- when "UTF-16BE", "UTF-16LE"
- @source.binmode
- @source.set_encoding(@encoding, @encoding)
- end
- @line_break = encode(">")
- @pending_buffer, @buffer = @buffer, ""
- @pending_buffer.force_encoding(@encoding)
- super
- end
- end
-end
diff --git a/lib/rexml/streamlistener.rb b/lib/rexml/streamlistener.rb
deleted file mode 100644
index 30c89451795..00000000000
--- a/lib/rexml/streamlistener.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-# frozen_string_literal: false
-module REXML
- # A template for stream parser listeners.
- # Note that the declarations (attlistdecl, elementdecl, etc) are trivially
- # processed; REXML doesn't yet handle doctype entity declarations, so you
- # have to parse them out yourself.
- module StreamListener
- # Called when a tag is encountered.
- # @p name the tag name
- # @p attrs an array of arrays of attribute/value pairs, suitable for
- # use with assoc or rassoc. IE, <tag attr1="value1" attr2="value2">
- # will result in
- # tag_start( "tag", # [["attr1","value1"],["attr2","value2"]])
- def tag_start name, attrs
- end
- # Called when the end tag is reached. In the case of <tag/>, tag_end
- # will be called immediately after tag_start
- # @p the name of the tag
- def tag_end name
- end
- # Called when text is encountered in the document
- # @p text the text content.
- def text text
- end
- # Called when an instruction is encountered. EG: <?xsl sheet='foo'?>
- # @p name the instruction name; in the example, "xsl"
- # @p instruction the rest of the instruction. In the example,
- # "sheet='foo'"
- def instruction name, instruction
- end
- # Called when a comment is encountered.
- # @p comment The content of the comment
- def comment comment
- end
- # Handles a doctype declaration. Any attributes of the doctype which are
- # not supplied will be nil. # EG, <!DOCTYPE me PUBLIC "foo" "bar">
- # @p name the name of the doctype; EG, "me"
- # @p pub_sys "PUBLIC", "SYSTEM", or nil. EG, "PUBLIC"
- # @p long_name the supplied long name, or nil. EG, "foo"
- # @p uri the uri of the doctype, or nil. EG, "bar"
- def doctype name, pub_sys, long_name, uri
- end
- # Called when the doctype is done
- def doctype_end
- end
- # If a doctype includes an ATTLIST declaration, it will cause this
- # method to be called. The content is the declaration itself, unparsed.
- # EG, <!ATTLIST el attr CDATA #REQUIRED> will come to this method as "el
- # attr CDATA #REQUIRED". This is the same for all of the .*decl
- # methods.
- def attlistdecl element_name, attributes, raw_content
- end
- # <!ELEMENT ...>
- def elementdecl content
- end
- # <!ENTITY ...>
- # The argument passed to this method is an array of the entity
- # declaration. It can be in a number of formats, but in general it
- # returns (example, result):
- # <!ENTITY % YN '"Yes"'>
- # ["YN", "\"Yes\"", "%"]
- # <!ENTITY % YN 'Yes'>
- # ["YN", "Yes", "%"]
- # <!ENTITY WhatHeSaid "He said %YN;">
- # ["WhatHeSaid", "He said %YN;"]
- # <!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
- # ["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
- # <!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
- # ["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
- # <!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
- # ["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "gif"]
- def entitydecl content
- end
- # <!NOTATION ...>
- def notationdecl content
- end
- # Called when %foo; is encountered in a doctype declaration.
- # @p content "foo"
- def entity content
- end
- # Called when <![CDATA[ ... ]]> is encountered in a document.
- # @p content "..."
- def cdata content
- end
- # Called when an XML PI is encountered in the document.
- # EG: <?xml version="1.0" encoding="utf"?>
- # @p version the version attribute value. EG, "1.0"
- # @p encoding the encoding attribute value, or nil. EG, "utf"
- # @p standalone the standalone attribute value, or nil. EG, nil
- def xmldecl version, encoding, standalone
- end
- end
-end
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
deleted file mode 100644
index 050b09c97ee..00000000000
--- a/lib/rexml/text.rb
+++ /dev/null
@@ -1,424 +0,0 @@
-# frozen_string_literal: false
-require_relative 'security'
-require_relative 'entity'
-require_relative 'doctype'
-require_relative 'child'
-require_relative 'doctype'
-require_relative 'parseexception'
-
-module REXML
- # Represents text nodes in an XML document
- class Text < Child
- include Comparable
- # The order in which the substitutions occur
- SPECIALS = [ /&(?!#?[\w-]+;)/u, /</u, />/u, /"/u, /'/u, /\r/u ]
- SUBSTITUTES = ['&amp;', '&lt;', '&gt;', '&quot;', '&apos;', '&#13;']
- # Characters which are substituted in written strings
- SLAICEPS = [ '<', '>', '"', "'", '&' ]
- SETUTITSBUS = [ /&lt;/u, /&gt;/u, /&quot;/u, /&apos;/u, /&amp;/u ]
-
- # If +raw+ is true, then REXML leaves the value alone
- attr_accessor :raw
-
- NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
- NUMERICENTITY = /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/
- VALID_CHAR = [
- 0x9, 0xA, 0xD,
- (0x20..0xD7FF),
- (0xE000..0xFFFD),
- (0x10000..0x10FFFF)
- ]
-
- if String.method_defined? :encode
- VALID_XML_CHARS = Regexp.new('^['+
- VALID_CHAR.map { |item|
- case item
- when Integer
- [item].pack('U').force_encoding('utf-8')
- when Range
- [item.first, '-'.ord, item.last].pack('UUU').force_encoding('utf-8')
- end
- }.join +
- ']*$')
- else
- VALID_XML_CHARS = /^(
- [\x09\x0A\x0D\x20-\x7E] # ASCII
- | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
- | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
- | [\xE1-\xEC\xEE][\x80-\xBF]{2} # straight 3-byte
- | \xEF[\x80-\xBE]{2} #
- | \xEF\xBF[\x80-\xBD] # excluding U+fffe and U+ffff
- | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
- | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
- | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
- | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
- )*$/nx;
- end
-
- # Constructor
- # +arg+ if a String, the content is set to the String. If a Text,
- # the object is shallowly cloned.
- #
- # +respect_whitespace+ (boolean, false) if true, whitespace is
- # respected
- #
- # +parent+ (nil) if this is a Parent object, the parent
- # will be set to this.
- #
- # +raw+ (nil) This argument can be given three values.
- # If true, then the value of used to construct this object is expected to
- # contain no unescaped XML markup, and REXML will not change the text. If
- # this value is false, the string may contain any characters, and REXML will
- # escape any and all defined entities whose values are contained in the
- # text. If this value is nil (the default), then the raw value of the
- # parent will be used as the raw value for this node. If there is no raw
- # value for the parent, and no value is supplied, the default is false.
- # Use this field if you have entities defined for some text, and you don't
- # want REXML to escape that text in output.
- # Text.new( "<&", false, nil, false ) #-> "&lt;&amp;"
- # Text.new( "&lt;&amp;", false, nil, false ) #-> "&amp;lt;&amp;amp;"
- # Text.new( "<&", false, nil, true ) #-> Parse exception
- # Text.new( "&lt;&amp;", false, nil, true ) #-> "&lt;&amp;"
- # # Assume that the entity "s" is defined to be "sean"
- # # and that the entity "r" is defined to be "russell"
- # Text.new( "sean russell" ) #-> "&s; &r;"
- # Text.new( "sean russell", false, nil, true ) #-> "sean russell"
- #
- # +entity_filter+ (nil) This can be an array of entities to match in the
- # supplied text. This argument is only useful if +raw+ is set to false.
- # Text.new( "sean russell", false, nil, false, ["s"] ) #-> "&s; russell"
- # Text.new( "sean russell", false, nil, true, ["s"] ) #-> "sean russell"
- # In the last example, the +entity_filter+ argument is ignored.
- #
- # +illegal+ INTERNAL USE ONLY
- def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
- entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK )
-
- @raw = false
- @parent = nil
- @entity_filter = nil
-
- if parent
- super( parent )
- @raw = parent.raw
- end
-
- if arg.kind_of? String
- @string = arg.dup
- elsif arg.kind_of? Text
- @string = arg.instance_variable_get(:@string).dup
- @raw = arg.raw
- @entity_filter = arg.instance_variable_get(:@entity_filter)
- else
- raise "Illegal argument of type #{arg.type} for Text constructor (#{arg})"
- end
-
- @string.squeeze!(" \n\t") unless respect_whitespace
- @string.gsub!(/\r\n?/, "\n")
- @raw = raw unless raw.nil?
- @entity_filter = entity_filter if entity_filter
- clear_cache
-
- Text.check(@string, illegal, doctype) if @raw
- end
-
- def parent= parent
- super(parent)
- Text.check(@string, NEEDS_A_SECOND_CHECK, doctype) if @raw and @parent
- end
-
- # check for illegal characters
- def Text.check string, pattern, doctype
-
- # illegal anywhere
- if string !~ VALID_XML_CHARS
- if String.method_defined? :encode
- string.chars.each do |c|
- case c.ord
- when *VALID_CHAR
- else
- raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
- end
- end
- else
- string.scan(/[\x00-\x7F]|[\x80-\xBF][\xC0-\xF0]*|[\xC0-\xF0]/n) do |c|
- case c.unpack('U')
- when *VALID_CHAR
- else
- raise "Illegal character #{c.inspect} in raw string #{string.inspect}"
- end
- end
- end
- end
-
- # context sensitive
- string.scan(pattern) do
- if $1[-1] != ?;
- raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
- elsif $1[0] == ?&
- if $5 and $5[0] == ?#
- case ($5[1] == ?x ? $5[2..-1].to_i(16) : $5[1..-1].to_i)
- when *VALID_CHAR
- else
- raise "Illegal character #{$1.inspect} in raw string #{string.inspect}"
- end
- # FIXME: below can't work but this needs API change.
- # elsif @parent and $3 and !SUBSTITUTES.include?($1)
- # if !doctype or !doctype.entities.has_key?($3)
- # raise "Undeclared entity '#{$1}' in raw string \"#{string}\""
- # end
- end
- end
- end
- end
-
- def node_type
- :text
- end
-
- def empty?
- @string.size==0
- end
-
-
- def clone
- return Text.new(self, true)
- end
-
-
- # Appends text to this text node. The text is appended in the +raw+ mode
- # of this text node.
- #
- # +returns+ the text itself to enable method chain like
- # 'text << "XXX" << "YYY"'.
- def <<( to_append )
- @string << to_append.gsub( /\r\n?/, "\n" )
- clear_cache
- self
- end
-
-
- # +other+ a String or a Text
- # +returns+ the result of (to_s <=> arg.to_s)
- def <=>( other )
- to_s() <=> other.to_s
- end
-
- def doctype
- if @parent
- doc = @parent.document
- doc.doctype if doc
- end
- end
-
- REFERENCE = /#{Entity::REFERENCE}/
- # Returns the string value of this text node. This string is always
- # escaped, meaning that it is a valid XML text node string, and all
- # entities that can be escaped, have been inserted. This method respects
- # the entity filter set in the constructor.
- #
- # # Assume that the entity "s" is defined to be "sean", and that the
- # # entity "r" is defined to be "russell"
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
- # t.to_s #-> "&lt; &amp; &s; russell"
- # t = Text.new( "< & &s; russell", false, nil, false )
- # t.to_s #-> "&lt; &amp; &s; russell"
- # u = Text.new( "sean russell", false, nil, true )
- # u.to_s #-> "sean russell"
- def to_s
- return @string if @raw
- @normalized ||= Text::normalize( @string, doctype, @entity_filter )
- end
-
- def inspect
- @string.inspect
- end
-
- # Returns the string value of this text. This is the text without
- # entities, as it might be used programmatically, or printed to the
- # console. This ignores the 'raw' attribute setting, and any
- # entity_filter.
- #
- # # Assume that the entity "s" is defined to be "sean", and that the
- # # entity "r" is defined to be "russell"
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
- # t.value #-> "< & sean russell"
- # t = Text.new( "< & &s; russell", false, nil, false )
- # t.value #-> "< & sean russell"
- # u = Text.new( "sean russell", false, nil, true )
- # u.value #-> "sean russell"
- def value
- @unnormalized ||= Text::unnormalize( @string, doctype )
- end
-
- # Sets the contents of this text node. This expects the text to be
- # unnormalized. It returns self.
- #
- # e = Element.new( "a" )
- # e.add_text( "foo" ) # <a>foo</a>
- # e[0].value = "bar" # <a>bar</a>
- # e[0].value = "<a>" # <a>&lt;a&gt;</a>
- def value=( val )
- @string = val.gsub( /\r\n?/, "\n" )
- clear_cache
- @raw = false
- end
-
- def wrap(string, width, addnewline=false)
- # Recursively wrap string at width.
- return string if string.length <= width
- place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
- if addnewline then
- return "\n" + string[0,place] + "\n" + wrap(string[place+1..-1], width)
- else
- return string[0,place] + "\n" + wrap(string[place+1..-1], width)
- end
- end
-
- def indent_text(string, level=1, style="\t", indentfirstline=true)
- return string if level < 0
- new_string = ''
- string.each_line { |line|
- indent_string = style * level
- new_line = (indent_string + line).sub(/[\s]+$/,'')
- new_string << new_line
- }
- new_string.strip! unless indentfirstline
- return new_string
- end
-
- # == DEPRECATED
- # See REXML::Formatters
- #
- def write( writer, indent=-1, transitive=false, ie_hack=false )
- Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters", uplevel: 1)
- formatter = if indent > -1
- REXML::Formatters::Pretty.new( indent )
- else
- REXML::Formatters::Default.new
- end
- formatter.write( self, writer )
- end
-
- # FIXME
- # This probably won't work properly
- def xpath
- path = @parent.xpath
- path += "/text()"
- return path
- end
-
- # Writes out text, substituting special characters beforehand.
- # +out+ A String, IO, or any other object supporting <<( String )
- # +input+ the text to substitute and the write out
- #
- # z=utf8.unpack("U*")
- # ascOut=""
- # z.each{|r|
- # if r < 0x100
- # ascOut.concat(r.chr)
- # else
- # ascOut.concat(sprintf("&#x%x;", r))
- # end
- # }
- # puts ascOut
- def write_with_substitution out, input
- copy = input.clone
- # Doing it like this rather than in a loop improves the speed
- copy.gsub!( SPECIALS[0], SUBSTITUTES[0] )
- copy.gsub!( SPECIALS[1], SUBSTITUTES[1] )
- copy.gsub!( SPECIALS[2], SUBSTITUTES[2] )
- copy.gsub!( SPECIALS[3], SUBSTITUTES[3] )
- copy.gsub!( SPECIALS[4], SUBSTITUTES[4] )
- copy.gsub!( SPECIALS[5], SUBSTITUTES[5] )
- out << copy
- end
-
- private
- def clear_cache
- @normalized = nil
- @unnormalized = nil
- end
-
- # Reads text, substituting entities
- def Text::read_with_substitution( input, illegal=nil )
- copy = input.clone
-
- if copy =~ illegal
- raise ParseException.new( "malformed text: Illegal character #$& in \"#{copy}\"" )
- end if illegal
-
- copy.gsub!( /\r\n?/, "\n" )
- if copy.include? ?&
- copy.gsub!( SETUTITSBUS[0], SLAICEPS[0] )
- copy.gsub!( SETUTITSBUS[1], SLAICEPS[1] )
- copy.gsub!( SETUTITSBUS[2], SLAICEPS[2] )
- copy.gsub!( SETUTITSBUS[3], SLAICEPS[3] )
- copy.gsub!( SETUTITSBUS[4], SLAICEPS[4] )
- copy.gsub!( /&#0*((?:\d+)|(?:x[a-f0-9]+));/ ) {
- m=$1
- #m='0' if m==''
- m = "0#{m}" if m[0] == ?x
- [Integer(m)].pack('U*')
- }
- end
- copy
- end
-
- EREFERENCE = /&(?!#{Entity::NAME};)/
- # Escapes all possible entities
- def Text::normalize( input, doctype=nil, entity_filter=nil )
- copy = input.to_s
- # Doing it like this rather than in a loop improves the speed
- #copy = copy.gsub( EREFERENCE, '&amp;' )
- copy = copy.gsub( "&", "&amp;" )
- if doctype
- # Replace all ampersands that aren't part of an entity
- doctype.entities.each_value do |entity|
- copy = copy.gsub( entity.value,
- "&#{entity.name};" ) if entity.value and
- not( entity_filter and entity_filter.include?(entity.name) )
- end
- else
- # Replace all ampersands that aren't part of an entity
- DocType::DEFAULT_ENTITIES.each_value do |entity|
- copy = copy.gsub(entity.value, "&#{entity.name};" )
- end
- end
- copy
- end
-
- # Unescapes all possible entities
- def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil )
- sum = 0
- string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) {
- s = Text.expand($&, doctype, filter)
- if sum + s.bytesize > Security.entity_expansion_text_limit
- raise "entity expansion has grown too large"
- else
- sum += s.bytesize
- end
- s
- }
- end
-
- def Text.expand(ref, doctype, filter)
- if ref[1] == ?#
- if ref[2] == ?x
- [ref[3...-1].to_i(16)].pack('U*')
- else
- [ref[2...-1].to_i].pack('U*')
- end
- elsif ref == '&amp;'
- '&'
- elsif filter and filter.include?( ref[1...-1] )
- ref
- elsif doctype
- doctype.entity( ref[1...-1] ) or ref
- else
- entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ]
- entity_value ? entity_value.value : ref
- end
- end
- end
-end
diff --git a/lib/rexml/undefinednamespaceexception.rb b/lib/rexml/undefinednamespaceexception.rb
deleted file mode 100644
index 492a098183e..00000000000
--- a/lib/rexml/undefinednamespaceexception.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: false
-require_relative 'parseexception'
-module REXML
- class UndefinedNamespaceException < ParseException
- def initialize( prefix, source, parser )
- super( "Undefined prefix #{prefix} found" )
- end
- end
-end
diff --git a/lib/rexml/validation/relaxng.rb b/lib/rexml/validation/relaxng.rb
deleted file mode 100644
index f29a2c05e57..00000000000
--- a/lib/rexml/validation/relaxng.rb
+++ /dev/null
@@ -1,539 +0,0 @@
-# frozen_string_literal: false
-require_relative "validation"
-require_relative "../parsers/baseparser"
-
-module REXML
- module Validation
- # Implemented:
- # * empty
- # * element
- # * attribute
- # * text
- # * optional
- # * choice
- # * oneOrMore
- # * zeroOrMore
- # * group
- # * value
- # * interleave
- # * mixed
- # * ref
- # * grammar
- # * start
- # * define
- #
- # Not implemented:
- # * data
- # * param
- # * include
- # * externalRef
- # * notAllowed
- # * anyName
- # * nsName
- # * except
- # * name
- class RelaxNG
- include Validator
-
- INFINITY = 1.0 / 0.0
- EMPTY = Event.new( nil )
- TEXT = [:start_element, "text"]
- attr_accessor :current
- attr_accessor :count
- attr_reader :references
-
- # FIXME: Namespaces
- def initialize source
- parser = REXML::Parsers::BaseParser.new( source )
-
- @count = 0
- @references = {}
- @root = @current = Sequence.new(self)
- @root.previous = true
- states = [ @current ]
- begin
- event = parser.pull
- case event[0]
- when :start_element
- case event[1]
- when "empty"
- when "element", "attribute", "text", "value"
- states[-1] << event
- when "optional"
- states << Optional.new( self )
- states[-2] << states[-1]
- when "choice"
- states << Choice.new( self )
- states[-2] << states[-1]
- when "oneOrMore"
- states << OneOrMore.new( self )
- states[-2] << states[-1]
- when "zeroOrMore"
- states << ZeroOrMore.new( self )
- states[-2] << states[-1]
- when "group"
- states << Sequence.new( self )
- states[-2] << states[-1]
- when "interleave"
- states << Interleave.new( self )
- states[-2] << states[-1]
- when "mixed"
- states << Interleave.new( self )
- states[-2] << states[-1]
- states[-1] << TEXT
- when "define"
- states << [ event[2]["name"] ]
- when "ref"
- states[-1] << Ref.new( event[2]["name"] )
- when "anyName"
- states << AnyName.new( self )
- states[-2] << states[-1]
- when "nsName"
- when "except"
- when "name"
- when "data"
- when "param"
- when "include"
- when "grammar"
- when "start"
- when "externalRef"
- when "notAllowed"
- end
- when :end_element
- case event[1]
- when "element", "attribute"
- states[-1] << event
- when "zeroOrMore", "oneOrMore", "choice", "optional",
- "interleave", "group", "mixed"
- states.pop
- when "define"
- ref = states.pop
- @references[ ref.shift ] = ref
- #when "empty"
- end
- when :end_document
- states[-1] << event
- when :text
- states[-1] << event
- end
- end while event[0] != :end_document
- end
-
- def receive event
- validate( event )
- end
- end
-
- class State
- def initialize( context )
- @previous = []
- @events = []
- @current = 0
- @count = context.count += 1
- @references = context.references
- @value = false
- end
-
- def reset
- return if @current == 0
- @current = 0
- @events.each {|s| s.reset if s.kind_of? State }
- end
-
- def previous=( previous )
- @previous << previous
- end
-
- def next( event )
- #print "In next with #{event.inspect}. "
- #p @previous
- return @previous.pop.next( event ) if @events[@current].nil?
- expand_ref_in( @events, @current ) if @events[@current].class == Ref
- if ( @events[@current].kind_of? State )
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1].next( event )
- end
- if ( @events[@current].matches?(event) )
- @current += 1
- if @events[@current].nil?
- return @previous.pop
- elsif @events[@current].kind_of? State
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1]
- else
- return self
- end
- else
- return nil
- end
- end
-
- def to_s
- # Abbreviated:
- self.class.name =~ /(?:::)(\w)\w+$/
- # Full:
- #self.class.name =~ /(?:::)(\w+)$/
- "#$1.#@count"
- end
-
- def inspect
- "< #{to_s} #{@events.collect{|e|
- pre = e == @events[@current] ? '#' : ''
- pre + e.inspect unless self == e
- }.join(', ')} >"
- end
-
- def expected
- return [@events[@current]]
- end
-
- def <<( event )
- add_event_to_arry( @events, event )
- end
-
-
- protected
- def expand_ref_in( arry, ind )
- new_events = []
- @references[ arry[ind].to_s ].each{ |evt|
- add_event_to_arry(new_events,evt)
- }
- arry[ind,1] = new_events
- end
-
- def add_event_to_arry( arry, evt )
- evt = generate_event( evt )
- if evt.kind_of? String
- arry[-1].event_arg = evt if arry[-1].kind_of? Event and @value
- @value = false
- else
- arry << evt
- end
- end
-
- def generate_event( event )
- return event if event.kind_of? State or event.class == Ref
- evt = nil
- arg = nil
- case event[0]
- when :start_element
- case event[1]
- when "element"
- evt = :start_element
- arg = event[2]["name"]
- when "attribute"
- evt = :start_attribute
- arg = event[2]["name"]
- when "text"
- evt = :text
- when "value"
- evt = :text
- @value = true
- end
- when :text
- return event[1]
- when :end_document
- return Event.new( event[0] )
- else # then :end_element
- case event[1]
- when "element"
- evt = :end_element
- when "attribute"
- evt = :end_attribute
- end
- end
- return Event.new( evt, arg )
- end
- end
-
-
- class Sequence < State
- def matches?(event)
- @events[@current].matches?( event )
- end
- end
-
-
- class Optional < State
- def next( event )
- if @current == 0
- rv = super
- return rv if rv
- @prior = @previous.pop
- return @prior.next( event )
- end
- super
- end
-
- def matches?(event)
- @events[@current].matches?(event) ||
- (@current == 0 and @previous[-1].matches?(event))
- end
-
- def expected
- return [ @prior.expected, @events[0] ].flatten if @current == 0
- return [@events[@current]]
- end
- end
-
-
- class ZeroOrMore < Optional
- def next( event )
- expand_ref_in( @events, @current ) if @events[@current].class == Ref
- if ( @events[@current].matches?(event) )
- @current += 1
- if @events[@current].nil?
- @current = 0
- return self
- elsif @events[@current].kind_of? State
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1]
- else
- return self
- end
- else
- @prior = @previous.pop
- return @prior.next( event ) if @current == 0
- return nil
- end
- end
-
- def expected
- return [ @prior.expected, @events[0] ].flatten if @current == 0
- return [@events[@current]]
- end
- end
-
-
- class OneOrMore < State
- def initialize context
- super
- @ord = 0
- end
-
- def reset
- super
- @ord = 0
- end
-
- def next( event )
- expand_ref_in( @events, @current ) if @events[@current].class == Ref
- if ( @events[@current].matches?(event) )
- @current += 1
- @ord += 1
- if @events[@current].nil?
- @current = 0
- return self
- elsif @events[@current].kind_of? State
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1]
- else
- return self
- end
- else
- return @previous.pop.next( event ) if @current == 0 and @ord > 0
- return nil
- end
- end
-
- def matches?( event )
- @events[@current].matches?(event) ||
- (@current == 0 and @ord > 0 and @previous[-1].matches?(event))
- end
-
- def expected
- if @current == 0 and @ord > 0
- return [@previous[-1].expected, @events[0]].flatten
- else
- return [@events[@current]]
- end
- end
- end
-
-
- class Choice < State
- def initialize context
- super
- @choices = []
- end
-
- def reset
- super
- @events = []
- @choices.each { |c| c.each { |s| s.reset if s.kind_of? State } }
- end
-
- def <<( event )
- add_event_to_arry( @choices, event )
- end
-
- def next( event )
- # Make the choice if we haven't
- if @events.size == 0
- c = 0 ; max = @choices.size
- while c < max
- if @choices[c][0].class == Ref
- expand_ref_in( @choices[c], 0 )
- @choices += @choices[c]
- @choices.delete( @choices[c] )
- max -= 1
- else
- c += 1
- end
- end
- @events = @choices.find { |evt| evt[0].matches? event }
- # Remove the references
- # Find the events
- end
- unless @events
- @events = []
- return nil
- end
- super
- end
-
- def matches?( event )
- return @events[@current].matches?( event ) if @events.size > 0
- !@choices.find{|evt| evt[0].matches?(event)}.nil?
- end
-
- def expected
- return [@events[@current]] if @events.size > 0
- return @choices.collect do |x|
- if x[0].kind_of? State
- x[0].expected
- else
- x[0]
- end
- end.flatten
- end
-
- def inspect
- "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' or ')} >"
- end
-
- protected
- def add_event_to_arry( arry, evt )
- if evt.kind_of? State or evt.class == Ref
- arry << [evt]
- elsif evt[0] == :text
- if arry[-1] and
- arry[-1][-1].kind_of?( Event ) and
- arry[-1][-1].event_type == :text and @value
-
- arry[-1][-1].event_arg = evt[1]
- @value = false
- end
- else
- arry << [] if evt[0] == :start_element
- arry[-1] << generate_event( evt )
- end
- end
- end
-
-
- class Interleave < Choice
- def initialize context
- super
- @choice = 0
- end
-
- def reset
- @choice = 0
- end
-
- def next_current( event )
- # Expand references
- c = 0 ; max = @choices.size
- while c < max
- if @choices[c][0].class == Ref
- expand_ref_in( @choices[c], 0 )
- @choices += @choices[c]
- @choices.delete( @choices[c] )
- max -= 1
- else
- c += 1
- end
- end
- @events = @choices[@choice..-1].find { |evt| evt[0].matches? event }
- @current = 0
- if @events
- # reorder the choices
- old = @choices[@choice]
- idx = @choices.index( @events )
- @choices[@choice] = @events
- @choices[idx] = old
- @choice += 1
- end
-
- @events = [] unless @events
- end
-
-
- def next( event )
- # Find the next series
- next_current(event) unless @events[@current]
- return nil unless @events[@current]
-
- expand_ref_in( @events, @current ) if @events[@current].class == Ref
- if ( @events[@current].kind_of? State )
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1].next( event )
- end
- return @previous.pop.next( event ) if @events[@current].nil?
- if ( @events[@current].matches?(event) )
- @current += 1
- if @events[@current].nil?
- return self unless @choices[@choice].nil?
- return @previous.pop
- elsif @events[@current].kind_of? State
- @current += 1
- @events[@current-1].previous = self
- return @events[@current-1]
- else
- return self
- end
- else
- return nil
- end
- end
-
- def matches?( event )
- return @events[@current].matches?( event ) if @events[@current]
- !@choices[@choice..-1].find{|evt| evt[0].matches?(event)}.nil?
- end
-
- def expected
- return [@events[@current]] if @events[@current]
- return @choices[@choice..-1].collect do |x|
- if x[0].kind_of? State
- x[0].expected
- else
- x[0]
- end
- end.flatten
- end
-
- def inspect
- "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' and ')} >"
- end
- end
-
- class Ref
- def initialize value
- @value = value
- end
- def to_s
- @value
- end
- def inspect
- "{#{to_s}}"
- end
- end
- end
-end
diff --git a/lib/rexml/validation/validation.rb b/lib/rexml/validation/validation.rb
deleted file mode 100644
index 0ad6ada4277..00000000000
--- a/lib/rexml/validation/validation.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-# frozen_string_literal: false
-require_relative 'validationexception'
-
-module REXML
- module Validation
- module Validator
- NILEVENT = [ nil ]
- def reset
- @current = @root
- @root.reset
- @root.previous = true
- @attr_stack = []
- self
- end
- def dump
- puts @root.inspect
- end
- def validate( event )
- @attr_stack = [] unless defined? @attr_stack
- match = @current.next(event)
- raise ValidationException.new( "Validation error. Expected: "+
- @current.expected.join( " or " )+" from #{@current.inspect} "+
- " but got #{Event.new( event[0], event[1] ).inspect}" ) unless match
- @current = match
-
- # Check for attributes
- case event[0]
- when :start_element
- @attr_stack << event[2]
- begin
- sattr = [:start_attribute, nil]
- eattr = [:end_attribute]
- text = [:text, nil]
- k, = event[2].find { |key,value|
- sattr[1] = key
- m = @current.next( sattr )
- if m
- # If the state has text children...
- if m.matches?( eattr )
- @current = m
- else
- text[1] = value
- m = m.next( text )
- text[1] = nil
- return false unless m
- @current = m if m
- end
- m = @current.next( eattr )
- if m
- @current = m
- true
- else
- false
- end
- else
- false
- end
- }
- event[2].delete(k) if k
- end while k
- when :end_element
- attrs = @attr_stack.pop
- raise ValidationException.new( "Validation error. Illegal "+
- " attributes: #{attrs.inspect}") if attrs.length > 0
- end
- end
- end
-
- class Event
- def initialize(event_type, event_arg=nil )
- @event_type = event_type
- @event_arg = event_arg
- end
-
- attr_reader :event_type
- attr_accessor :event_arg
-
- def done?
- @done
- end
-
- def single?
- return (@event_type != :start_element and @event_type != :start_attribute)
- end
-
- def matches?( event )
- return false unless event[0] == @event_type
- case event[0]
- when nil
- return true
- when :start_element
- return true if event[1] == @event_arg
- when :end_element
- return true
- when :start_attribute
- return true if event[1] == @event_arg
- when :end_attribute
- return true
- when :end_document
- return true
- when :text
- return (@event_arg.nil? or @event_arg == event[1])
-=begin
- when :processing_instruction
- false
- when :xmldecl
- false
- when :start_doctype
- false
- when :end_doctype
- false
- when :externalentity
- false
- when :elementdecl
- false
- when :entity
- false
- when :attlistdecl
- false
- when :notationdecl
- false
- when :end_doctype
- false
-=end
- else
- false
- end
- end
-
- def ==( other )
- return false unless other.kind_of? Event
- @event_type == other.event_type and @event_arg == other.event_arg
- end
-
- def to_s
- inspect
- end
-
- def inspect
- "#{@event_type.inspect}( #@event_arg )"
- end
- end
- end
-end
diff --git a/lib/rexml/validation/validationexception.rb b/lib/rexml/validation/validationexception.rb
deleted file mode 100644
index 78cd63fd046..00000000000
--- a/lib/rexml/validation/validationexception.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: false
-module REXML
- module Validation
- class ValidationException < RuntimeError
- def initialize msg
- super
- end
- end
- end
-end
diff --git a/lib/rexml/xmldecl.rb b/lib/rexml/xmldecl.rb
deleted file mode 100644
index d19407cefdd..00000000000
--- a/lib/rexml/xmldecl.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-# frozen_string_literal: false
-
-require_relative 'encoding'
-require_relative 'source'
-
-module REXML
- # NEEDS DOCUMENTATION
- class XMLDecl < Child
- include Encoding
-
- DEFAULT_VERSION = "1.0"
- DEFAULT_ENCODING = "UTF-8"
- DEFAULT_STANDALONE = "no"
- START = "<?xml"
- STOP = "?>"
-
- attr_accessor :version, :standalone
- attr_reader :writeencoding, :writethis
-
- def initialize(version=DEFAULT_VERSION, encoding=nil, standalone=nil)
- @writethis = true
- @writeencoding = !encoding.nil?
- if version.kind_of? XMLDecl
- super()
- @version = version.version
- self.encoding = version.encoding
- @writeencoding = version.writeencoding
- @standalone = version.standalone
- @writethis = version.writethis
- else
- super()
- @version = version
- self.encoding = encoding
- @standalone = standalone
- end
- @version = DEFAULT_VERSION if @version.nil?
- end
-
- def clone
- XMLDecl.new(self)
- end
-
- # indent::
- # Ignored. There must be no whitespace before an XML declaration
- # transitive::
- # Ignored
- # ie_hack::
- # Ignored
- def write(writer, indent=-1, transitive=false, ie_hack=false)
- return nil unless @writethis or writer.kind_of? Output
- writer << START
- writer << " #{content encoding}"
- writer << STOP
- end
-
- def ==( other )
- other.kind_of?(XMLDecl) and
- other.version == @version and
- other.encoding == self.encoding and
- other.standalone == @standalone
- end
-
- def xmldecl version, encoding, standalone
- @version = version
- self.encoding = encoding
- @standalone = standalone
- end
-
- def node_type
- :xmldecl
- end
-
- alias :stand_alone? :standalone
- alias :old_enc= :encoding=
-
- def encoding=( enc )
- if enc.nil?
- self.old_enc = "UTF-8"
- @writeencoding = false
- else
- self.old_enc = enc
- @writeencoding = true
- end
- self.dowrite
- end
-
- # Only use this if you do not want the XML declaration to be written;
- # this object is ignored by the XML writer. Otherwise, instantiate your
- # own XMLDecl and add it to the document.
- #
- # Note that XML 1.1 documents *must* include an XML declaration
- def XMLDecl.default
- rv = XMLDecl.new( "1.0" )
- rv.nowrite
- rv
- end
-
- def nowrite
- @writethis = false
- end
-
- def dowrite
- @writethis = true
- end
-
- def inspect
- "#{START} ... #{STOP}"
- end
-
- private
- def content(enc)
- context = nil
- context = parent.context if parent
- if context and context[:prologue_quote] == :quote
- quote = "\""
- else
- quote = "'"
- end
-
- rv = "version=#{quote}#{@version}#{quote}"
- if @writeencoding or enc !~ /\Autf-8\z/i
- rv << " encoding=#{quote}#{enc}#{quote}"
- end
- if @standalone
- rv << " standalone=#{quote}#{@standalone}#{quote}"
- end
- rv
- end
- end
-end
diff --git a/lib/rexml/xmltokens.rb b/lib/rexml/xmltokens.rb
deleted file mode 100644
index 392b47b1d33..00000000000
--- a/lib/rexml/xmltokens.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# frozen_string_literal: false
-module REXML
- # Defines a number of tokens used for parsing XML. Not for general
- # consumption.
- module XMLTokens
- # From http://www.w3.org/TR/REC-xml/#sec-common-syn
- #
- # [4] NameStartChar ::=
- # ":" |
- # [A-Z] |
- # "_" |
- # [a-z] |
- # [#xC0-#xD6] |
- # [#xD8-#xF6] |
- # [#xF8-#x2FF] |
- # [#x370-#x37D] |
- # [#x37F-#x1FFF] |
- # [#x200C-#x200D] |
- # [#x2070-#x218F] |
- # [#x2C00-#x2FEF] |
- # [#x3001-#xD7FF] |
- # [#xF900-#xFDCF] |
- # [#xFDF0-#xFFFD] |
- # [#x10000-#xEFFFF]
- name_start_chars = [
- ":",
- "A-Z",
- "_",
- "a-z",
- "\\u00C0-\\u00D6",
- "\\u00D8-\\u00F6",
- "\\u00F8-\\u02FF",
- "\\u0370-\\u037D",
- "\\u037F-\\u1FFF",
- "\\u200C-\\u200D",
- "\\u2070-\\u218F",
- "\\u2C00-\\u2FEF",
- "\\u3001-\\uD7FF",
- "\\uF900-\\uFDCF",
- "\\uFDF0-\\uFFFD",
- "\\u{10000}-\\u{EFFFF}",
- ]
- # From http://www.w3.org/TR/REC-xml/#sec-common-syn
- #
- # [4a] NameChar ::=
- # NameStartChar |
- # "-" |
- # "." |
- # [0-9] |
- # #xB7 |
- # [#x0300-#x036F] |
- # [#x203F-#x2040]
- name_chars = name_start_chars + [
- "\\-",
- "\\.",
- "0-9",
- "\\u00B7",
- "\\u0300-\\u036F",
- "\\u203F-\\u2040",
- ]
- NAME_START_CHAR = "[#{name_start_chars.join('')}]"
- NAME_CHAR = "[#{name_chars.join('')}]"
- NAMECHAR = NAME_CHAR # deprecated. Use NAME_CHAR instead.
-
- # From http://www.w3.org/TR/xml-names11/#NT-NCName
- #
- # [6] NCNameStartChar ::= NameStartChar - ':'
- ncname_start_chars = name_start_chars - [":"]
- # From http://www.w3.org/TR/xml-names11/#NT-NCName
- #
- # [5] NCNameChar ::= NameChar - ':'
- ncname_chars = name_chars - [":"]
- NCNAME_STR = "[#{ncname_start_chars.join('')}][#{ncname_chars.join('')}]*"
- NAME_STR = "(?:#{NCNAME_STR}:)?#{NCNAME_STR}"
-
- NAME = "(#{NAME_START_CHAR}#{NAME_CHAR}*)"
- NMTOKEN = "(?:#{NAME_CHAR})+"
- NMTOKENS = "#{NMTOKEN}(\\s+#{NMTOKEN})*"
- REFERENCE = "(?:&#{NAME};|&#\\d+;|&#x[0-9a-fA-F]+;)"
-
- #REFERENCE = "(?:#{ENTITYREF}|#{CHARREF})"
- #ENTITYREF = "&#{NAME};"
- #CHARREF = "&#\\d+;|&#x[0-9a-fA-F]+;"
- end
-end
diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb
deleted file mode 100644
index a0921bd8e10..00000000000
--- a/lib/rexml/xpath.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: false
-require_relative 'functions'
-require_relative 'xpath_parser'
-
-module REXML
- # Wrapper class. Use this class to access the XPath functions.
- class XPath
- include Functions
- # A base Hash object, supposing to be used when initializing a
- # default empty namespaces set, but is currently unused.
- # TODO: either set the namespaces=EMPTY_HASH, or deprecate this.
- EMPTY_HASH = {}
-
- # Finds and returns the first node that matches the supplied xpath.
- # element::
- # The context element
- # path::
- # The xpath to search for. If not supplied or nil, returns the first
- # node matching '*'.
- # namespaces::
- # If supplied, a Hash which defines a namespace mapping.
- # variables::
- # If supplied, a Hash which maps $variables in the query
- # to values. This can be used to avoid XPath injection attacks
- # or to automatically handle escaping string values.
- #
- # XPath.first( node )
- # XPath.first( doc, "//b"} )
- # XPath.first( node, "a/x:b", { "x"=>"http://doofus" } )
- # XPath.first( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"})
- def XPath::first(element, path=nil, namespaces=nil, variables={}, options={})
- raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
- raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
- parser = XPathParser.new(**options)
- parser.namespaces = namespaces
- parser.variables = variables
- path = "*" unless path
- element = [element] unless element.kind_of? Array
- parser.parse(path, element).flatten[0]
- end
-
- # Iterates over nodes that match the given path, calling the supplied
- # block with the match.
- # element::
- # The context element
- # path::
- # The xpath to search for. If not supplied or nil, defaults to '*'
- # namespaces::
- # If supplied, a Hash which defines a namespace mapping
- # variables::
- # If supplied, a Hash which maps $variables in the query
- # to values. This can be used to avoid XPath injection attacks
- # or to automatically handle escaping string values.
- #
- # XPath.each( node ) { |el| ... }
- # XPath.each( node, '/*[@attr='v']' ) { |el| ... }
- # XPath.each( node, 'ancestor::x' ) { |el| ... }
- # XPath.each( node, '/book/publisher/text()=$publisher', {}, {"publisher"=>"O'Reilly"}) \
- # {|el| ... }
- def XPath::each(element, path=nil, namespaces=nil, variables={}, options={}, &block)
- raise "The namespaces argument, if supplied, must be a hash object." unless namespaces.nil? or namespaces.kind_of?(Hash)
- raise "The variables argument, if supplied, must be a hash object." unless variables.kind_of?(Hash)
- parser = XPathParser.new(**options)
- parser.namespaces = namespaces
- parser.variables = variables
- path = "*" unless path
- element = [element] unless element.kind_of? Array
- parser.parse(path, element).each( &block )
- end
-
- # Returns an array of nodes matching a given XPath.
- def XPath::match(element, path=nil, namespaces=nil, variables={}, options={})
- parser = XPathParser.new(**options)
- parser.namespaces = namespaces
- parser.variables = variables
- path = "*" unless path
- element = [element] unless element.kind_of? Array
- parser.parse(path,element)
- end
- end
-end
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
deleted file mode 100644
index b9897254032..00000000000
--- a/lib/rexml/xpath_parser.rb
+++ /dev/null
@@ -1,968 +0,0 @@
-# frozen_string_literal: false
-
-require "pp"
-
-require_relative 'namespace'
-require_relative 'xmltokens'
-require_relative 'attribute'
-require_relative 'parsers/xpathparser'
-
-class Object
- # provides a unified +clone+ operation, for REXML::XPathParser
- # to use across multiple Object types
- def dclone
- clone
- end
-end
-class Symbol
- # provides a unified +clone+ operation, for REXML::XPathParser
- # to use across multiple Object types
- def dclone ; self ; end
-end
-class Integer
- # provides a unified +clone+ operation, for REXML::XPathParser
- # to use across multiple Object types
- def dclone ; self ; end
-end
-class Float
- # provides a unified +clone+ operation, for REXML::XPathParser
- # to use across multiple Object types
- def dclone ; self ; end
-end
-class Array
- # provides a unified +clone+ operation, for REXML::XPathParser
- # to use across multiple Object+ types
- def dclone
- klone = self.clone
- klone.clear
- self.each{|v| klone << v.dclone}
- klone
- end
-end
-
-module REXML
- # You don't want to use this class. Really. Use XPath, which is a wrapper
- # for this class. Believe me. You don't want to poke around in here.
- # There is strange, dark magic at work in this code. Beware. Go back! Go
- # back while you still can!
- class XPathParser
- include XMLTokens
- LITERAL = /^'([^']*)'|^"([^"]*)"/u
-
- DEBUG = (ENV["REXML_XPATH_PARSER_DEBUG"] == "true")
-
- def initialize(strict: false)
- @debug = DEBUG
- @parser = REXML::Parsers::XPathParser.new
- @namespaces = nil
- @variables = {}
- @nest = 0
- @strict = strict
- end
-
- def namespaces=( namespaces={} )
- Functions::namespace_context = namespaces
- @namespaces = namespaces
- end
-
- def variables=( vars={} )
- Functions::variables = vars
- @variables = vars
- end
-
- def parse path, nodeset
- path_stack = @parser.parse( path )
- match( path_stack, nodeset )
- end
-
- def get_first path, nodeset
- path_stack = @parser.parse( path )
- first( path_stack, nodeset )
- end
-
- def predicate path, nodeset
- path_stack = @parser.parse( path )
- match( path_stack, nodeset )
- end
-
- def []=( variable_name, value )
- @variables[ variable_name ] = value
- end
-
-
- # Performs a depth-first (document order) XPath search, and returns the
- # first match. This is the fastest, lightest way to return a single result.
- #
- # FIXME: This method is incomplete!
- def first( path_stack, node )
- return nil if path.size == 0
-
- case path[0]
- when :document
- # do nothing
- return first( path[1..-1], node )
- when :child
- for c in node.children
- r = first( path[1..-1], c )
- return r if r
- end
- when :qname
- name = path[2]
- if node.name == name
- return node if path.size == 3
- return first( path[3..-1], node )
- else
- return nil
- end
- when :descendant_or_self
- r = first( path[1..-1], node )
- return r if r
- for c in node.children
- r = first( path, c )
- return r if r
- end
- when :node
- return first( path[1..-1], node )
- when :any
- return first( path[1..-1], node )
- end
- return nil
- end
-
-
- def match(path_stack, nodeset)
- nodeset = nodeset.collect.with_index do |node, i|
- position = i + 1
- XPathNode.new(node, position: position)
- end
- result = expr(path_stack, nodeset)
- case result
- when Array # nodeset
- unnode(result)
- else
- [result]
- end
- end
-
- private
- def strict?
- @strict
- end
-
- # Returns a String namespace for a node, given a prefix
- # The rules are:
- #
- # 1. Use the supplied namespace mapping first.
- # 2. If no mapping was supplied, use the context node to look up the namespace
- def get_namespace( node, prefix )
- if @namespaces
- return @namespaces[prefix] || ''
- else
- return node.namespace( prefix ) if node.node_type == :element
- return ''
- end
- end
-
-
- # Expr takes a stack of path elements and a set of nodes (either a Parent
- # or an Array and returns an Array of matching nodes
- def expr( path_stack, nodeset, context=nil )
- enter(:expr, path_stack, nodeset) if @debug
- return nodeset if path_stack.length == 0 || nodeset.length == 0
- while path_stack.length > 0
- trace(:while, path_stack, nodeset) if @debug
- if nodeset.length == 0
- path_stack.clear
- return []
- end
- op = path_stack.shift
- case op
- when :document
- first_raw_node = nodeset.first.raw_node
- nodeset = [XPathNode.new(first_raw_node.root_node, position: 1)]
- when :self
- nodeset = step(path_stack) do
- [nodeset]
- end
- when :child
- nodeset = step(path_stack) do
- child(nodeset)
- end
- when :literal
- trace(:literal, path_stack, nodeset) if @debug
- return path_stack.shift
- when :attribute
- nodeset = step(path_stack, any_type: :attribute) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.node_type == :element
- attributes = raw_node.attributes
- next if attributes.empty?
- nodesets << attributes.each_attribute.collect.with_index do |attribute, i|
- XPathNode.new(attribute, position: i + 1)
- end
- end
- nodesets
- end
- when :namespace
- pre_defined_namespaces = {
- "xml" => "http://www.w3.org/XML/1998/namespace",
- }
- nodeset = step(path_stack, any_type: :namespace) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- if @namespaces
- nodesets << pre_defined_namespaces.merge(@namespaces)
- else
- nodesets << pre_defined_namespaces.merge(raw_node.namespaces)
- end
- when :attribute
- if @namespaces
- nodesets << pre_defined_namespaces.merge(@namespaces)
- else
- nodesets << pre_defined_namespaces.merge(raw_node.element.namespaces)
- end
- end
- end
- nodesets
- end
- when :parent
- nodeset = step(path_stack) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- if raw_node.node_type == :attribute
- parent = raw_node.element
- else
- parent = raw_node.parent
- end
- nodesets << [XPathNode.new(parent, position: 1)] if parent
- end
- nodesets
- end
- when :ancestor
- nodeset = step(path_stack) do
- nodesets = []
- # new_nodes = {}
- nodeset.each do |node|
- raw_node = node.raw_node
- new_nodeset = []
- while raw_node.parent
- raw_node = raw_node.parent
- # next if new_nodes.key?(node)
- new_nodeset << XPathNode.new(raw_node,
- position: new_nodeset.size + 1)
- # new_nodes[node] = true
- end
- nodesets << new_nodeset unless new_nodeset.empty?
- end
- nodesets
- end
- when :ancestor_or_self
- nodeset = step(path_stack) do
- nodesets = []
- # new_nodes = {}
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.node_type == :element
- new_nodeset = [XPathNode.new(raw_node, position: 1)]
- # new_nodes[node] = true
- while raw_node.parent
- raw_node = raw_node.parent
- # next if new_nodes.key?(node)
- new_nodeset << XPathNode.new(raw_node,
- position: new_nodeset.size + 1)
- # new_nodes[node] = true
- end
- nodesets << new_nodeset unless new_nodeset.empty?
- end
- nodesets
- end
- when :descendant_or_self
- nodeset = step(path_stack) do
- descendant(nodeset, true)
- end
- when :descendant
- nodeset = step(path_stack) do
- descendant(nodeset, false)
- end
- when :following_sibling
- nodeset = step(path_stack) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.respond_to?(:parent)
- next if raw_node.parent.nil?
- all_siblings = raw_node.parent.children
- current_index = all_siblings.index(raw_node)
- following_siblings = all_siblings[(current_index + 1)..-1]
- next if following_siblings.empty?
- nodesets << following_siblings.collect.with_index do |sibling, i|
- XPathNode.new(sibling, position: i + 1)
- end
- end
- nodesets
- end
- when :preceding_sibling
- nodeset = step(path_stack, order: :reverse) do
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- next unless raw_node.respond_to?(:parent)
- next if raw_node.parent.nil?
- all_siblings = raw_node.parent.children
- current_index = all_siblings.index(raw_node)
- preceding_siblings = all_siblings[0, current_index].reverse
- next if preceding_siblings.empty?
- nodesets << preceding_siblings.collect.with_index do |sibling, i|
- XPathNode.new(sibling, position: i + 1)
- end
- end
- nodesets
- end
- when :preceding
- nodeset = step(path_stack, order: :reverse) do
- unnode(nodeset) do |node|
- preceding(node)
- end
- end
- when :following
- nodeset = step(path_stack) do
- unnode(nodeset) do |node|
- following(node)
- end
- end
- when :variable
- var_name = path_stack.shift
- return [@variables[var_name]]
-
- when :eq, :neq, :lt, :lteq, :gt, :gteq
- left = expr( path_stack.shift, nodeset.dup, context )
- right = expr( path_stack.shift, nodeset.dup, context )
- res = equality_relational_compare( left, op, right )
- trace(op, left, right, res) if @debug
- return res
-
- when :or
- left = expr(path_stack.shift, nodeset.dup, context)
- return true if Functions.boolean(left)
- right = expr(path_stack.shift, nodeset.dup, context)
- return Functions.boolean(right)
-
- when :and
- left = expr(path_stack.shift, nodeset.dup, context)
- return false unless Functions.boolean(left)
- right = expr(path_stack.shift, nodeset.dup, context)
- return Functions.boolean(right)
-
- when :div, :mod, :mult, :plus, :minus
- left = expr(path_stack.shift, nodeset, context)
- right = expr(path_stack.shift, nodeset, context)
- left = unnode(left) if left.is_a?(Array)
- right = unnode(right) if right.is_a?(Array)
- left = Functions::number(left)
- right = Functions::number(right)
- case op
- when :div
- return left / right
- when :mod
- return left % right
- when :mult
- return left * right
- when :plus
- return left + right
- when :minus
- return left - right
- else
- raise "[BUG] Unexpected operator: <#{op.inspect}>"
- end
- when :union
- left = expr( path_stack.shift, nodeset, context )
- right = expr( path_stack.shift, nodeset, context )
- left = unnode(left) if left.is_a?(Array)
- right = unnode(right) if right.is_a?(Array)
- return (left | right)
- when :neg
- res = expr( path_stack, nodeset, context )
- res = unnode(res) if res.is_a?(Array)
- return -Functions.number(res)
- when :not
- when :function
- func_name = path_stack.shift.tr('-','_')
- arguments = path_stack.shift
-
- if nodeset.size != 1
- message = "[BUG] Node set size must be 1 for function call: "
- message += "<#{func_name}>: <#{nodeset.inspect}>: "
- message += "<#{arguments.inspect}>"
- raise message
- end
-
- node = nodeset.first
- if context
- target_context = context
- else
- target_context = {:size => nodeset.size}
- if node.is_a?(XPathNode)
- target_context[:node] = node.raw_node
- target_context[:index] = node.position
- else
- target_context[:node] = node
- target_context[:index] = 1
- end
- end
- args = arguments.dclone.collect do |arg|
- result = expr(arg, nodeset, target_context)
- result = unnode(result) if result.is_a?(Array)
- result
- end
- Functions.context = target_context
- return Functions.send(func_name, *args)
-
- else
- raise "[BUG] Unexpected path: <#{op.inspect}>: <#{path_stack.inspect}>"
- end
- end # while
- return nodeset
- ensure
- leave(:expr, path_stack, nodeset) if @debug
- end
-
- def step(path_stack, any_type: :element, order: :forward)
- nodesets = yield
- begin
- enter(:step, path_stack, nodesets) if @debug
- nodesets = node_test(path_stack, nodesets, any_type: any_type)
- while path_stack[0] == :predicate
- path_stack.shift # :predicate
- predicate_expression = path_stack.shift.dclone
- nodesets = evaluate_predicate(predicate_expression, nodesets)
- end
- if nodesets.size == 1
- ordered_nodeset = nodesets[0]
- else
- raw_nodes = []
- nodesets.each do |nodeset|
- nodeset.each do |node|
- if node.respond_to?(:raw_node)
- raw_nodes << node.raw_node
- else
- raw_nodes << node
- end
- end
- end
- ordered_nodeset = sort(raw_nodes, order)
- end
- new_nodeset = []
- ordered_nodeset.each do |node|
- # TODO: Remove duplicated
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- new_nodeset
- ensure
- leave(:step, path_stack, new_nodeset) if @debug
- end
- end
-
- def node_test(path_stack, nodesets, any_type: :element)
- enter(:node_test, path_stack, nodesets) if @debug
- operator = path_stack.shift
- case operator
- when :qname
- prefix = path_stack.shift
- name = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- if prefix.nil?
- raw_node.name == name
- elsif prefix.empty?
- if strict?
- raw_node.name == name and raw_node.namespace == ""
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- when :attribute
- if prefix.nil?
- raw_node.name == name
- elsif prefix.empty?
- raw_node.name == name and raw_node.namespace == ""
- else
- # FIXME: This DOUBLES the time XPath searches take
- ns = get_namespace(raw_node.element, prefix)
- raw_node.name == name and raw_node.namespace == ns
- end
- else
- false
- end
- end
- end
- when :namespace
- prefix = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- case raw_node.node_type
- when :element
- namespaces = @namespaces || raw_node.namespaces
- raw_node.namespace == namespaces[prefix]
- when :attribute
- namespaces = @namespaces || raw_node.element.namespaces
- raw_node.namespace == namespaces[prefix]
- else
- false
- end
- end
- end
- when :any
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == any_type
- end
- end
- when :comment
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == :comment
- end
- end
- when :text
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- raw_node.node_type == :text
- end
- end
- when :processing_instruction
- target = path_stack.shift
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- raw_node = node.raw_node
- (raw_node.node_type == :processing_instruction) and
- (target.empty? or (raw_node.target == target))
- end
- end
- when :node
- new_nodesets = nodesets.collect do |nodeset|
- filter_nodeset(nodeset) do |node|
- true
- end
- end
- else
- message = "[BUG] Unexpected node test: " +
- "<#{operator.inspect}>: <#{path_stack.inspect}>"
- raise message
- end
- new_nodesets
- ensure
- leave(:node_test, path_stack, new_nodesets) if @debug
- end
-
- def filter_nodeset(nodeset)
- new_nodeset = []
- nodeset.each do |node|
- next unless yield(node)
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- new_nodeset
- end
-
- def evaluate_predicate(expression, nodesets)
- enter(:predicate, expression, nodesets) if @debug
- new_nodesets = nodesets.collect do |nodeset|
- new_nodeset = []
- subcontext = { :size => nodeset.size }
- nodeset.each_with_index do |node, index|
- if node.is_a?(XPathNode)
- subcontext[:node] = node.raw_node
- subcontext[:index] = node.position
- else
- subcontext[:node] = node
- subcontext[:index] = index + 1
- end
- result = expr(expression.dclone, [node], subcontext)
- trace(:predicate_evaluate, expression, node, subcontext, result) if @debug
- result = result[0] if result.kind_of? Array and result.length == 1
- if result.kind_of? Numeric
- if result == node.position
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- elsif result.instance_of? Array
- if result.size > 0 and result.inject(false) {|k,s| s or k}
- if result.size > 0
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- end
- else
- if result
- new_nodeset << XPathNode.new(node, position: new_nodeset.size + 1)
- end
- end
- end
- new_nodeset
- end
- new_nodesets
- ensure
- leave(:predicate, new_nodesets) if @debug
- end
-
- def trace(*args)
- indent = " " * @nest
- PP.pp(args, "").each_line do |line|
- puts("#{indent}#{line}")
- end
- end
-
- def enter(tag, *args)
- trace(:enter, tag, *args)
- @nest += 1
- end
-
- def leave(tag, *args)
- @nest -= 1
- trace(:leave, tag, *args)
- end
-
- # Reorders an array of nodes so that they are in document order
- # It tries to do this efficiently.
- #
- # FIXME: I need to get rid of this, but the issue is that most of the XPath
- # interpreter functions as a filter, which means that we lose context going
- # in and out of function calls. If I knew what the index of the nodes was,
- # I wouldn't have to do this. Maybe add a document IDX for each node?
- # Problems with mutable documents. Or, rewrite everything.
- def sort(array_of_nodes, order)
- new_arry = []
- array_of_nodes.each { |node|
- node_idx = []
- np = node.node_type == :attribute ? node.element : node
- while np.parent and np.parent.node_type == :element
- node_idx << np.parent.index( np )
- np = np.parent
- end
- new_arry << [ node_idx.reverse, node ]
- }
- ordered = new_arry.sort_by do |index, node|
- if order == :forward
- index
- else
- -index
- end
- end
- ordered.collect do |_index, node|
- node
- end
- end
-
- def descendant(nodeset, include_self)
- nodesets = []
- nodeset.each do |node|
- new_nodeset = []
- new_nodes = {}
- descendant_recursive(node.raw_node, new_nodeset, new_nodes, include_self)
- nodesets << new_nodeset unless new_nodeset.empty?
- end
- nodesets
- end
-
- def descendant_recursive(raw_node, new_nodeset, new_nodes, include_self)
- if include_self
- return if new_nodes.key?(raw_node)
- new_nodeset << XPathNode.new(raw_node, position: new_nodeset.size + 1)
- new_nodes[raw_node] = true
- end
-
- node_type = raw_node.node_type
- if node_type == :element or node_type == :document
- raw_node.children.each do |child|
- descendant_recursive(child, new_nodeset, new_nodes, true)
- end
- end
- end
-
- # Builds a nodeset of all of the preceding nodes of the supplied node,
- # in reverse document order
- # preceding:: includes every element in the document that precedes this node,
- # except for ancestors
- def preceding(node)
- ancestors = []
- parent = node.parent
- while parent
- ancestors << parent
- parent = parent.parent
- end
-
- precedings = []
- preceding_node = preceding_node_of(node)
- while preceding_node
- if ancestors.include?(preceding_node)
- ancestors.delete(preceding_node)
- else
- precedings << XPathNode.new(preceding_node,
- position: precedings.size + 1)
- end
- preceding_node = preceding_node_of(preceding_node)
- end
- precedings
- end
-
- def preceding_node_of( node )
- psn = node.previous_sibling_node
- if psn.nil?
- if node.parent.nil? or node.parent.class == Document
- return nil
- end
- return node.parent
- #psn = preceding_node_of( node.parent )
- end
- while psn and psn.kind_of? Element and psn.children.size > 0
- psn = psn.children[-1]
- end
- psn
- end
-
- def following(node)
- followings = []
- following_node = next_sibling_node(node)
- while following_node
- followings << XPathNode.new(following_node,
- position: followings.size + 1)
- following_node = following_node_of(following_node)
- end
- followings
- end
-
- def following_node_of( node )
- if node.kind_of? Element and node.children.size > 0
- return node.children[0]
- end
- return next_sibling_node(node)
- end
-
- def next_sibling_node(node)
- psn = node.next_sibling_node
- while psn.nil?
- if node.parent.nil? or node.parent.class == Document
- return nil
- end
- node = node.parent
- psn = node.next_sibling_node
- end
- return psn
- end
-
- def child(nodeset)
- nodesets = []
- nodeset.each do |node|
- raw_node = node.raw_node
- node_type = raw_node.node_type
- # trace(:child, node_type, node)
- case node_type
- when :element
- nodesets << raw_node.children.collect.with_index do |child_node, i|
- XPathNode.new(child_node, position: i + 1)
- end
- when :document
- new_nodeset = []
- raw_node.children.each do |child|
- case child
- when XMLDecl, Text
- # Ignore
- else
- new_nodeset << XPathNode.new(child, position: new_nodeset.size + 1)
- end
- end
- nodesets << new_nodeset unless new_nodeset.empty?
- end
- end
- nodesets
- end
-
- def norm b
- case b
- when true, false
- return b
- when 'true', 'false'
- return Functions::boolean( b )
- when /^\d+(\.\d+)?$/, Numeric
- return Functions::number( b )
- else
- return Functions::string( b )
- end
- end
-
- def equality_relational_compare(set1, op, set2)
- set1 = unnode(set1) if set1.is_a?(Array)
- set2 = unnode(set2) if set2.is_a?(Array)
-
- if set1.kind_of? Array and set2.kind_of? Array
- # If both objects to be compared are node-sets, then the
- # comparison will be true if and only if there is a node in the
- # first node-set and a node in the second node-set such that the
- # result of performing the comparison on the string-values of
- # the two nodes is true.
- set1.product(set2).any? do |node1, node2|
- node_string1 = Functions.string(node1)
- node_string2 = Functions.string(node2)
- compare(node_string1, op, node_string2)
- end
- elsif set1.kind_of? Array or set2.kind_of? Array
- # If one is nodeset and other is number, compare number to each item
- # in nodeset s.t. number op number(string(item))
- # If one is nodeset and other is string, compare string to each item
- # in nodeset s.t. string op string(item)
- # If one is nodeset and other is boolean, compare boolean to each item
- # in nodeset s.t. boolean op boolean(item)
- if set1.kind_of? Array
- a = set1
- b = set2
- else
- a = set2
- b = set1
- end
-
- case b
- when true, false
- each_unnode(a).any? do |unnoded|
- compare(Functions.boolean(unnoded), op, b)
- end
- when Numeric
- each_unnode(a).any? do |unnoded|
- compare(Functions.number(unnoded), op, b)
- end
- when /\A\d+(\.\d+)?\z/
- b = Functions.number(b)
- each_unnode(a).any? do |unnoded|
- compare(Functions.number(unnoded), op, b)
- end
- else
- b = Functions::string(b)
- each_unnode(a).any? do |unnoded|
- compare(Functions::string(unnoded), op, b)
- end
- end
- else
- # If neither is nodeset,
- # If op is = or !=
- # If either boolean, convert to boolean
- # If either number, convert to number
- # Else, convert to string
- # Else
- # Convert both to numbers and compare
- compare(set1, op, set2)
- end
- end
-
- def value_type(value)
- case value
- when true, false
- :boolean
- when Numeric
- :number
- when String
- :string
- else
- raise "[BUG] Unexpected value type: <#{value.inspect}>"
- end
- end
-
- def normalize_compare_values(a, operator, b)
- a_type = value_type(a)
- b_type = value_type(b)
- case operator
- when :eq, :neq
- if a_type == :boolean or b_type == :boolean
- a = Functions.boolean(a) unless a_type == :boolean
- b = Functions.boolean(b) unless b_type == :boolean
- elsif a_type == :number or b_type == :number
- a = Functions.number(a) unless a_type == :number
- b = Functions.number(b) unless b_type == :number
- else
- a = Functions.string(a) unless a_type == :string
- b = Functions.string(b) unless b_type == :string
- end
- when :lt, :lteq, :gt, :gteq
- a = Functions.number(a) unless a_type == :number
- b = Functions.number(b) unless b_type == :number
- else
- message = "[BUG] Unexpected compare operator: " +
- "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>"
- raise message
- end
- [a, b]
- end
-
- def compare(a, operator, b)
- a, b = normalize_compare_values(a, operator, b)
- case operator
- when :eq
- a == b
- when :neq
- a != b
- when :lt
- a < b
- when :lteq
- a <= b
- when :gt
- a > b
- when :gteq
- a >= b
- else
- message = "[BUG] Unexpected compare operator: " +
- "<#{operator.inspect}>: <#{a.inspect}>: <#{b.inspect}>"
- raise message
- end
- end
-
- def each_unnode(nodeset)
- return to_enum(__method__, nodeset) unless block_given?
- nodeset.each do |node|
- if node.is_a?(XPathNode)
- unnoded = node.raw_node
- else
- unnoded = node
- end
- yield(unnoded)
- end
- end
-
- def unnode(nodeset)
- each_unnode(nodeset).collect do |unnoded|
- unnoded = yield(unnoded) if block_given?
- unnoded
- end
- end
- end
-
- # @private
- class XPathNode
- attr_reader :raw_node, :context
- def initialize(node, context=nil)
- if node.is_a?(XPathNode)
- @raw_node = node.raw_node
- else
- @raw_node = node
- end
- @context = context || {}
- end
-
- def position
- @context[:position]
- end
- end
-end
diff --git a/test/rexml/data/LostineRiver.kml.gz b/test/rexml/data/LostineRiver.kml.gz
deleted file mode 100644
index 68a00c51db2..00000000000
--- a/test/rexml/data/LostineRiver.kml.gz
+++ /dev/null
Binary files differ
diff --git a/test/rexml/data/ProductionSupport.xml b/test/rexml/data/ProductionSupport.xml
deleted file mode 100644
index 083cf64a6e8..00000000000
--- a/test/rexml/data/ProductionSupport.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-
-<ProductionSupport version="1.1" >
- <Errors>
- <CommonErrors>
- <CommonError>
- <Key><![CDATA[RoyUpdatePolicyBusReq(Object)>>#error:]]></Key>
- <Patterns>
- <Pattern><![CDATA[The error code is '9997']]></Pattern>
- </Patterns>
- <Message>
- <String>Update Policy request 9997: Please check CICS log</String>
- </Message>
- <BackendSupport/>
- </CommonError>
- <CommonError>
- <Key>MotorInsuranceContract(Object)>>#error:</Key>
- <Patterns>
- <Pattern>Have not got a complete</Pattern>
- </Patterns>
- <Message>
- <String>Have not got a complete and consistent set of price matrices for policy period - ask back-end prod supp to sort out</String>
- </Message>
- <BackendSupport/>
- </CommonError>
-</CommonErrors>
-</Errors>
-</ProductionSupport>
diff --git a/test/rexml/data/axis.xml b/test/rexml/data/axis.xml
deleted file mode 100644
index bc996c571d4..00000000000
--- a/test/rexml/data/axis.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-
-<root>
-
- <a>
- <a.1/>
- <a.2/>
- <a.3/>
- <a.4/>
- <a.5/>
- </a>
-
- <b>
- <b.1/>
- <b.2/>
- <b.3/>
- <b.4/>
- <b.5/>
- <b.6/>
- <b.7/>
- <b.8/>
- <b.9/>
- </b>
-
-</root>
diff --git a/test/rexml/data/bad.xml b/test/rexml/data/bad.xml
deleted file mode 100644
index 18786f2b436..00000000000
--- a/test/rexml/data/bad.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<a>
- Here is an XML document.
- <b>
- It has some elements, but it also has a hidden < error! (or two)
- </a>
diff --git a/test/rexml/data/basic.xml b/test/rexml/data/basic.xml
deleted file mode 100644
index 88385fb6e16..00000000000
--- a/test/rexml/data/basic.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<foo>
- <bar>
- <baz/>
- <cheese/>
- <baz/>
- <cheese/>
- <baz/>
- </bar>
-</foo>
diff --git a/test/rexml/data/basicupdate.xml b/test/rexml/data/basicupdate.xml
deleted file mode 100644
index 57d458cf2aa..00000000000
--- a/test/rexml/data/basicupdate.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<xu:modifications xmlns:xu="http://www.xmldb.org/xupdate">
-
- <xu:append select="/foo/bar/cheese[1]">
- Goudse kaas
- <edam type="jong belegen">Rond</edam>
- </xu:append>
-
- <xu:remove select="/foo/bar/baz[2]"/>
-
- <xu:if test="/foo">
- <xu:insert-before select="/foo/bar/baz[2]">
- <cheese>More cheese!</cheese>
- </xu:insert-before>
- </xu:if>
-
- <xu:insert-before select="/foo/bar/baz[2]">
- <cheese>Even more cheese!</cheese>
- </xu:insert-before>
-
- <xu:if test="/bar">
- <xu:insert-before select="/foo/bar/baz[2]">
- <sausages>No sausages today</sausages>
- </xu:insert-before>
- </xu:if>
-
- <xu:variable
- xmlns:private="http://www.jaxen.org/private"
- name="private:twice">
- <cracker/>
- <!-- champagne -->
- <?oisters with a bit of lemon?>
- </xu:variable>
-
- <xu:variable name="twice" select="'Twice'"/>
-
- <xu:insert-after
- select="/foo/bar"
- xmlns:private="http://www.jaxen.org/private"
- >
- <xu:value-of select="$private:twice"/>
- <xu:value-of select="$private:twice"/>
- <xu:value-of select="$twice"/>
- </xu:insert-after>
-
-</xu:modifications>
diff --git a/test/rexml/data/broken.rss b/test/rexml/data/broken.rss
deleted file mode 100644
index d5f29e5d1f1..00000000000
--- a/test/rexml/data/broken.rss
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE rdf:RDF [
- <!ENTITY % HTMLlat1 PUBLIC
- "-//W3C//ENTITIES Latin 1 for XHTML//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
- %HTMLlat1;
-]>
-
-<rdf:RDF
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:on="http://www.oreillynet.com/csrss/"
- xmlns="http://purl.org/rss/1.0/"
->
-
- <channel rdf:about="http://www.oreillynet.com/">
- <title>O'Reilly Network Articles</title>
- <link>http://www.oreillynet.com/</link>
- </channel>
-</rdf:RDF>
diff --git a/test/rexml/data/contents.xml b/test/rexml/data/contents.xml
deleted file mode 100644
index 35e3ac70445..00000000000
--- a/test/rexml/data/contents.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0"?>
-
-<?xml-stylesheet href="XSL\JavaXML.html.xsl" type="text/xsl"?>
-<?xml-stylesheet href="XSL\JavaXML.wml.xsl" type="text/xsl"
- media="wap"?>
-<?cocoon-process type="xslt"?>
-
-<!-- Java and XML -->
-<JavaXML:Book xmlns:JavaXML="http://www.oreilly.com/catalog/javaxml/"
- xmlns:ora="http://www.oreilly.com"
- xmlns:unused="http://www.unused.com"
- ora:category="Java"
->
- <!-- comment one -->
- <!-- comment two -->
-
- <JavaXML:Title>Java and XML</JavaXML:Title>
- <JavaXML:Contents xmlns:topic="http://www.oreilly.com/topics">
- <JavaXML:Chapter topic:focus="XML">
- <JavaXML:Heading>Introduction</JavaXML:Heading>
- <JavaXML:Topic subSections="7">
- What Is It?
- </JavaXML:Topic>
- <JavaXML:Topic subSections="3">
- How Do I Use It?
- </JavaXML:Topic>
- <JavaXML:Topic subSections="4">
- Why Should I Use It?
- </JavaXML:Topic>
- <JavaXML:Topic subSections="0">
- What's Next?
- </JavaXML:Topic>
- </JavaXML:Chapter>
-
- <JavaXML:Chapter topic:focus="XML">
- <JavaXML:Heading>Creating XML</JavaXML:Heading>
- <JavaXML:Topic subSections="0">An XML Document</JavaXML:Topic>
- <JavaXML:Topic subSections="2">The Header</JavaXML:Topic>
- <JavaXML:Topic subSections="6">The Content</JavaXML:Topic>
- <JavaXML:Topic subSections="1">What's Next?</JavaXML:Topic>
- </JavaXML:Chapter>
-
- <JavaXML:Chapter topic:focus="Java">
- <JavaXML:Heading>Parsing XML</JavaXML:Heading>
- <JavaXML:Topic subSections="3">Getting Prepared</JavaXML:Topic>
- <JavaXML:Topic subSections="3">SAX Readers</JavaXML:Topic>
- <JavaXML:Topic subSections="9">Content Handlers</JavaXML:Topic>
- <JavaXML:Topic subSections="4">Error Handlers</JavaXML:Topic>
- <JavaXML:Topic subSections="0">
- A Better Way to Load a Parser
- </JavaXML:Topic>
- <JavaXML:Topic subSections="4">"Gotcha!"</JavaXML:Topic>
- <JavaXML:Topic subSections="0">What's Next?</JavaXML:Topic>
- </JavaXML:Chapter>
-
- <JavaXML:SectionBreak/>
-
- <JavaXML:Chapter topic:focus="Java">
- <JavaXML:Heading>Web Publishing Frameworks</JavaXML:Heading>
- <JavaXML:Topic subSections="4">Selecting a Framework</JavaXML:Topic>
- <JavaXML:Topic subSections="4">Installation</JavaXML:Topic>
- <JavaXML:Topic subSections="3">
- Using a Publishing Framework
- </JavaXML:Topic>
- <JavaXML:Topic subSections="2">XSP</JavaXML:Topic>
- <JavaXML:Topic subSections="3">Cocoon 2.0 and Beyond</JavaXML:Topic>
- <JavaXML:Topic subSections="0">What's Next?</JavaXML:Topic>
- </JavaXML:Chapter>
- </JavaXML:Contents>
-</JavaXML:Book>
diff --git a/test/rexml/data/dash.xml b/test/rexml/data/dash.xml
deleted file mode 100644
index e1be6557504..00000000000
--- a/test/rexml/data/dash.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<content-repository>
- <content-repository-child-1>
- <content-1>content-1-text</content-1>
- </content-repository-child-1>
- <content-repository-child-2>
- <content-2>content-2-text</content-2>
- </content-repository-child-2>
- <content-repository-child-3>
- <content-3>content-3-text</content-3>
- </content-repository-child-3>
-</content-repository>
diff --git a/test/rexml/data/defaultNamespace.xml b/test/rexml/data/defaultNamespace.xml
deleted file mode 100644
index 1e32981506f..00000000000
--- a/test/rexml/data/defaultNamespace.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0"?>
-<a xmlns="http://dummyNamespace/">
- <b>
- <c>Hello</c>
- </b>
-</a>
diff --git a/test/rexml/data/doctype_test.xml b/test/rexml/data/doctype_test.xml
deleted file mode 100644
index a690cab99dd..00000000000
--- a/test/rexml/data/doctype_test.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE internationalization SYSTEM "l10n.dtd" [
-<!ENTITY af SYSTEM "af.xml">
-<!ENTITY ca SYSTEM "ca.xml">
-<!ENTITY cs SYSTEM "cs.xml">
-<!ENTITY da SYSTEM "da.xml">
-<!ENTITY de SYSTEM "de.xml">
-<!ENTITY el SYSTEM "el.xml">
-<!ENTITY en SYSTEM "en.xml">
-<!ENTITY es SYSTEM "es.xml">
-<!ENTITY et SYSTEM "et.xml">
-<!ENTITY fi SYSTEM "fi.xml">
-<!ENTITY fr SYSTEM "fr.xml">
-<!ENTITY hu SYSTEM "hu.xml">
-<!ENTITY id SYSTEM "id.xml">
-<!ENTITY it SYSTEM "it.xml">
-<!ENTITY ja SYSTEM "ja.xml">
-<!ENTITY ko SYSTEM "ko.xml">
-<!ENTITY nl SYSTEM "nl.xml">
-<!ENTITY no SYSTEM "no.xml">
-<!ENTITY no_ny SYSTEM "no_ny.xml">
-<!ENTITY pl SYSTEM "pl.xml">
-<!ENTITY pt SYSTEM "pt.xml">
-<!ENTITY pt_br SYSTEM "pt_br.xml">
-<!ENTITY ro SYSTEM "ro.xml">
-<!ENTITY ru SYSTEM "ru.xml">
-<!ENTITY sk SYSTEM "sk.xml">
-<!ENTITY sl SYSTEM "sl.xml">
-<!ENTITY sr SYSTEM "sr.xml">
-<!ENTITY sv SYSTEM "sv.xml">
-<!ENTITY tr SYSTEM "tr.xml">
-<!ENTITY zh_cn SYSTEM "zh_cn.xml">
-<!ENTITY zh_tw SYSTEM "zh_tw.xml">
-]>
-<x/>
diff --git a/test/rexml/data/documentation.xml b/test/rexml/data/documentation.xml
deleted file mode 100644
index a1ad6e878b5..00000000000
--- a/test/rexml/data/documentation.xml
+++ /dev/null
@@ -1,542 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet type="text/css" href="http://www.germane-software.com/repositories/public/documentation/documentation.css"?>
-<?xml-stylesheet alternative="yes" type="text/css" href="file:/home/ser/Work/documentation/documentation.css"?>
-<?xml-stylesheet alternative="yes" type="text/xsl" href="http://www.germane-software.com/repositories/public/documentation/paged.xsl"?>
-<!DOCTYPE documentation SYSTEM "http://www.germane-software.com/repositories/public/documentation/documentation.dtd">
-<documentation>
- <head>
- <title>REXML</title>
-
- <banner href="img/rexml.png" />
-
- <version>@ANT_VERSION@</version>
-
- <date>@ANT_DATE@</date>
-
- <home>http://www.germane-software.com/software/rexml</home>
-
- <base>rexml</base>
-
- <language>ruby</language>
-
- <author email="ser@germane-software.com"
- href="http://www.ser1.net/" jabber="seanerussell@gmail.com">Sean
- Russell</author>
- </head>
-
- <overview>
- <purpose lang="en">
- <p>REXML is a conformant XML processor for the Ruby programming
- language. REXML passes 100% of the Oasis non-validating tests and
- includes full XPath support. It is reasonably fast, and is implemented
- in pure Ruby. Best of all, it has a clean, intuitive API. REXML is
- included in the standard library of Ruby</p>
-
- <p>This software is distribute under the <link href="LICENSE.txt">Ruby
- license</link>.</p>
- </purpose>
-
- <general>
- <p>REXML arose out of a desire for a straightforward XML API, and is an
- attempt at an API that doesn't require constant referencing of
- documentation to do common tasks. "Keep the common case simple, and the
- uncommon, possible."</p>
-
- <p>REXML avoids The DOM API, which violates the maxim of simplicity. It
- does provide <em>a</em> DOM model, but one that is Ruby-ized. It is an
- XML API oriented for Ruby programmers, not for XML programmers coming
- from Java.</p>
-
- <p>Some of the common differences are that the Ruby API relies on block
- enumerations, rather than iterators. For example, the Java code:</p>
-
- <example>for (Enumeration e=parent.getChildren(); e.hasMoreElements(); ) {
- Element child = (Element)e.nextElement(); // Do something with child
-}</example>
-
- <p>in Ruby becomes:</p>
-
- <example>parent.each_child{ |child| # Do something with child }</example>
-
- <p>Can't you feel the peace and contentment in this block of code? Ruby
- is the language Buddha would have programmed in.</p>
-
- <p>One last thing. If you use and like this software, and you're in a
- position of power in a company in Western Europe and are looking for a
- software architect or developer, drop me a line. I took a lot of French
- classes in college (all of which I've forgotten), and I lived in Munich
- long enough that I was pretty fluent by the time I left, and I'd love to
- get back over there.</p>
- </general>
-
- <features lang="en">
- <item>Four intuitive parsing APIs.</item>
-
- <item>Intuitive, powerful, and reasonably fast tree parsing API (a-la
- DOM</item>
-
- <item>Fast stream parsing API (a-la SAX)<footnote>This is not a SAX
- API.</footnote></item>
-
- <item>SAX2-based API<footnote>In addition to the native REXML streaming
- API. This is slower than the native REXML API, but does a lot more work
- for you.</footnote></item>
-
- <item>Pull parsing API.</item>
-
- <item>Small</item>
-
- <item>Reasonably fast (for interpreted code)</item>
-
- <item>Native Ruby</item>
-
- <item>Full XPath support<footnote>Currently only available for the tree
- API</footnote></item>
-
- <item>XML 1.0 conformant<footnote>REXML passes all of the non-validating
- OASIS tests. There are probably places where REXML isn't conformant, but
- I try to fix them as they're reported.</footnote></item>
-
- <item>ISO-8859-1, UNILE, UTF-16 and UTF-8 input and output; also,
- support for any encoding the iconv supports.</item>
-
- <item>Documentation</item>
- </features>
- </overview>
-
- <operation lang="en">
- <subsection title="Installation">
- <p>You don't <em>have</em> to install anything; if you're running a
- version of Ruby greater than 1.8, REXML is included. However, if you
- choose to upgrade from the REXML distribution, run the command:
- <code>ruby bin/install.rb</code>. By the way, you really should look at
- these sorts of files before you run them as root. They could contain
- anything, and since (in Ruby, at least) they tend to be mercifully
- short, it doesn't hurt to glance over them. If you want to uninstall
- REXML, run <code>ruby bin/install.rb -u</code>.</p>
- </subsection>
-
- <subsection title="Unit tests">
- <p>If you have Test::Unit installed, you can run the unit test cases.
- Run the command: <code>ruby bin/suite.rb</code>; it runs against the
- distribution, not against the installed version.</p>
- </subsection>
-
- <subsection title="Benchmarks">
- <p>There is a benchmark suite in <code>benchmarks/</code>. To run the
- benchmarks, change into that directory and run <code>ruby
- comparison.rb</code>. If you have nothing else installed, only the
- benchmarks for REXML will be run. However, if you have any of the
- following installed, benchmarks for those tools will also be run:</p>
-
- <list>
- <item>NQXML</item>
-
- <item>XMLParser</item>
-
- <item>Electric XML (you must copy <code>EXML.jar</code> into the
- <code>benchmarks</code> directory and compile
- <code>flatbench.java</code> before running the test)</item>
- </list>
-
- <p>The results will be written to <code>index.html</code>.</p>
- </subsection>
-
- <subsection title="General Usage">
- <p>Please see <link href="docs/tutorial.html">the Tutorial</link>.</p>
-
- <p>The API documentation is available <link
- href="http://www.germane-software.com/software/XML/rexml/doc">on-line</link>,
- or it can be downloaded as an archive <link
- href="http://www.germane-software.com/software/archives/rexml_api_@ANT_VERSION@.tgz">in
- tgz format (~70Kb)</link> or (if you're a masochist) <link
- href="http://www.germane-software.com/software/archives/rexml_api_@ANT_VERSION@.zip">in
- zip format (~280Kb)</link>. The best solution is to download and install
- Dave Thomas' most excellent <link
- href="http://rdoc.sourceforge.net">rdoc</link> and generate the API docs
- yourself; then you'll be sure to have the latest API docs and won't have
- to keep downloading the doc archive.</p>
-
- <p>The unit tests in <code>test/</code> and the benchmarking code in
- <code>benchmark/</code> provide additional examples of using REXML. The
- Tutorial provides examples with commentary. The documentation unpacks
- into <link href="doc/index.html"><code>rexml/doc</code></link>.</p>
-
- <p>Kouhei Sutou maintains a <link
- href="http://www.germane-software.com/software/rexml_doc_ja/current/index.html">Japanese
- version</link> of the REXML API docs. <link
- href="http://www.germane-software.com/software/rexml_doc_ja/current/japanese_documentation.html">Kou's
- documentation page</link> contains links to binary archives for various
- versions of the documentation.</p>
- </subsection>
- </operation>
-
- <status>
- <subsection title="Speed and Completeness">
- <p>Unfortunately, NQXML is the only package REXML can be compared
- against; XMLParser uses expat, which is a native library, and really is
- a different beast altogether. So in comparing NQXML and REXML you can
- look at four things: speed, size, completeness, and API.</p>
-
- <p><link href="benchmarks/index.html">Benchmarks</link></p>
-
- <p>REXML is faster than NQXML in some things, and slower than NQXML in a
- couple of things. You can see this for yourself by running the supplied
- benchmarks. Most of the places where REXML are slower are because of the
- convenience methods<footnote>For example,
- <code>element.elements[index]</code> isn't really an array operation;
- index can be an Integer or an XPath, and this feature is relatively time
- expensive.</footnote>. On the positive side, most of the convenience
- methods can be bypassed if you know what you are doing. Check the <link
- href="benchmarks/index.html"> benchmark comparison page</link> for a
- <em>general</em> comparison. You can look at the benchmark code yourself
- to decide how much salt to take with them.</p>
-
- <p>The sizes of the XML parsers are close<footnote>As measured with
- <code>ruby -nle 'print unless /^\s*(#.*|)$/' *.rb | wc -l</code>
- </footnote>. NQXML 1.1.3 has 1580 non-blank, non-comment lines of code;
- REXML 2.0 has 2340<footnote>REXML started out with about 1200, but that
- number has been steadily increasing as features are added. XPath
- accounts for 541 lines of that code, so the core REXML has about 1800
- LOC.</footnote>.</p>
-
- <p>REXML is a conformant XML 1.0 parser. It supports multiple language
- encodings, and internal processing uses the required UTF-8 and UTF-16
- encodings. It passes 100% of the Oasis non-validating tests.
- Furthermore, it provides a full implementation of XPath, a SAX2 and a
- PullParser API.</p>
- </subsection>
-
- <subsection title="XPath">
- <p>As of release 2.0, XPath 1.0 is fully implemented.</p>
-
- <p>I fully expect bugs to crop up from time to time, so if you see any
- bogus XPath results, please let me know. That said, since I'm now
- following the XPath grammar and spec fairly closely, I suspect that you
- won't be surprised by REXML's XPath very often, and it should become
- rock solid fairly quickly.</p>
-
- <p>Check the "bugs" section for known problems; there are little bits of
- XPath here and there that are not yet implemented, but I'll get to them
- soon.</p>
-
- <p>Namespace support is rather odd, but it isn't my fault. I can only do
- so much and still conform to the specs. In particular, XPath attempts to
- help as much as possible. Therefore, in the trivial cases, you can pass
- namespace prefixes to Element.elements[...] and so on -- in these cases,
- XPath will use the namespace environment of the base element you're
- starting your XPath search from. However, if you want to do something
- more complex, like pass in your own namespace environment, you have to
- use the XPath first(), each(), and match() methods. Also, default
- namespaces <em>force</em> you to use the XPath methods, rather than the
- convenience methods, because there is no way for XPath to know what the
- mappings for the default namespaces should be. This is exactly why I
- loath namespaces -- a pox on the person(s) who thought them up!</p>
- </subsection>
-
- <subsection title="Namespaces">
- <p>Namespace support is now fairly stable. One thing to be aware of is
- that REXML is not (yet) a validating parser. This means that some
- invalid namespace declarations are not caught.</p>
- </subsection>
-
- <subsection title="Mailing list">
- <p>There is a low-volume mailing list dedicated to REXML. To subscribe,
- send an empty email to <link
- href="mailto:ser-rexml-subscribe@germane-software.com">ser-rexml-subscribe@germane-software.com</link>.
- This list is more or less spam proof. To unsubscribe, similarly send a
- message to <link
- href="mailto:ser-rexml-unsubscribe@germane-software.com">ser-rexml-unsubscribe@germane-software.com</link>.</p>
- </subsection>
-
- <subsection title="RSS">
- <p>An <link
- href="http://www.germane-software.com/projects/rexml/timeline?ticket=on&amp;max=50&amp;daysback=90&amp;format=rss">RSS
- file</link> for REXML is now being generated from the change log. This
- allows you to be alerted of bug fixes and feature additions via "pull".
- <link href="http://www.germane-software.com/software/rexml/rss.xml">Another
- RSS</link> is available which contains a single item: the release notice
- for the most recent release. This is an abuse of the RSS
- mechanism, which was intended to be a distribution system for headlines
- linked back to full articles, but it works. The headline for REXML is
- the version number, and the description is the change log. The links all
- link back to the REXML home page. The URL for the RSS itself is
- http://www.germane-software.com/software/rexml/rss.xml.</p>
-
- <p>The <link href="release.html">changelog itself is here</link>.</p>
-
- <p>For those who are interested, there's a <link
- href="docs/sloccount.txt">SLOCCount</link> (by David A. Wheeler) file
- with stats on the REXML sourcecode. Note that the SLOCCount output
- includes the files in the test/, benchmarks/, and bin/ directories, as
- well as the main sourcecode for REXML itself.</p>
- </subsection>
-
- <subsection title="Applications that use REXML">
- <list>
- <item><link
- href="http://www.pablotron.org/software/raggle/">Raggle</link> is a
- console-based RSS aggregator.</item>
-
- <item><link
- href="http://www.zweknu.org/technical/index.rhtml?s=p|10/">getrss</link>
- is an RSS aggregator</item>
-
- <item>Ned Konz's <link
- href="http://www.bikenomad.microship.com/ruby/">ruby-htmltools</link>
- uses REXML</item>
-
- <item>Hiroshi NAKAMURA's <link
- href="http://www.ruby-lang.org/en/raa-list.rhtml?name=SOAP4R">SOAP4R</link>
- package can use REXML as the XML processor.</item>
-
- <item>Chris Morris' <link href="http://clabs.org/clxmlserial.htm">XML
- Serializer</link>. XML Serializer provides a serialization mechanism
- for Ruby that provides a bidirectional mapping between Ruby classes
- and XML documents.</item>
-
- <item>Much of the <link href="http://www.rubyxml.com">RubyXML</link>
- site is generated with scripts that use REXML. RubyXML is a great
- place to find information about th intersection between Ruby and
- XML.</item>
- </list>
- </subsection>
-
- <bugs lang="en">
- <p>You can submit bug reports and feature requests, and view the list of
- known bugs, at the <link
- href="http://www.germane-software.com/projects/rexml">REXML bug report
- page.</link> Please do submit bug reports. If you really want your bug
- fixed fast, include an runit or Test::Unit method (or methods) that
- illustrates the problem. At the very least, send me some XML that REXML
- doesn't process properly.</p>
-
- <p>You don't have to send an entire test suite -- just the unit test
- methods. If you don't send me a unit test, I'll have to write one
- myself, which will mean that your bug will take longer to fix.</p>
-
- <p>When submitting bug reports, please include the version of Ruby and
- of REXML that you're using, and the operating system you're running on.
- Just run: <code>ruby -vrrexml/rexml -e 'p
- REXML::VERSION,PLATFORM'</code> and paste the results in your bug
- report. Include your email if you want a response about the bug.</p>
-
- <item>Attributes are not handled internally as nodes, so you can't
- perform node functions on them. This will have to change. It'll also
- probably mean that, rather than returning attribute values, XPath will
- return the Attribute nodes.</item>
-
- <item>Some of the XPath <em>functions</em> are untested<footnote>Mike
- Stok has been testing, debugging, and implementing some of these
- Functions (and he's been doing a good job) so there's steady improvement
- in this area.</footnote>. Any XPath functions that don't work are also
- bugs... please report them. If you send a unit test that illustrates the
- problem, I'll try to fix the problem within a couple of days (if I can)
- and send you a patch, personally.</item>
-
- <item>Accessing prefixes for which there is no defined namespace in an
- XPath should throw an exception. It currently doesn't -- it just fails
- to match.</item>
- </bugs>
-
- <todo lang="en">
- <item>Reparsing a tree with a pull/SAX parser</item>
-
- <item>Better namespace support in SAX</item>
-
- <item>Lazy tree parsing</item>
-
- <item>Segregate parsers, for optimized minimal distributions</item>
-
- <item>XML &lt;-&gt; Ruby</item>
-
- <item>Validation support</item>
-
- <item>True XML character support</item>
-
- <item>Add XPath support for streaming APIs</item>
-
- <item status="request">XQuery support</item>
-
- <item status="request">XUpdate support</item>
-
- <item>Make sure namespaces are supported in pull parser</item>
-
- <item status="request">Add document start and entity replacement events
- in pull parser</item>
-
- <item>Better stream parsing exception handling</item>
-
- <item>I'd like to hack XMLRPC4R to use REXML, for my own
- purposes.</item>
- </todo>
- </status>
-
- <faq>
- <q>REXML is hanging while parsing one of my XML files.</q>
-
- <a>Your XML is probably malformed. Some malformed XML, especially XML that
- contains literal '&lt;' embedded in the document, causes REXML to hang.
- REXML should be throwing an exception, but it doesn't; this is a bug. I'm
- aware that it is an extremely annoying bug, and it is one I'm trying to
- solve in a way that doesn't significantly reduce REXML's parsing
- speed.</a>
-
- <q>I'm using the XPath '//foo' on an XML branch node X, and keep getting
- all of the 'foo' elements in the entire document. Why? Shouldn't it return
- only the 'foo' element descendants of X?</q>
-
- <a>No. XPath specifies that '/' returns the document root, regardless of
- the context node. '//' also starts at the document root. If you want to
- limit your search to a branch, you need to use the self:: axe. EG,
- 'self::node()//foo', or the shorthand './/foo'.</a>
-
- <q>I want to parse a document both as a tree, and as a stream. Can I do
- this?</q>
-
- <a>Yes, and no. There is no mechanism that directly supports this in
- REXML. However, aside from writing your own traversal layer, there is a
- way of doing this. To turn a tree into a stream, just turn the branch you
- want to process as a stream back into a string, and re-parse it with your
- preferred API. EG: pp = PullParser.new( some_element.to_s ). The other
- direction is more difficult; you basically have to build a tree from the
- events. REXML will have one of these builders, eventually, but it doesn't
- currently exist.</a>
-
- <q>Why is Element.elements indexed off of '1' instead of '0'?</q>
-
- <a>Because of XPath. The XPath specification states that the index of the
- first child node is '1'. Although it may be counter-intuitive to base
- elements on 1, it is more undesireable to have element.elements[0] ==
- element.elements[ 'node()[1]' ]. Since I can't change the XPath
- specification, the result is that Element.elements[1] is the first child
- element.</a>
-
- <q>Why isn't REXML a validating parser?</q>
-
- <a>Because validating parsers must include code that parses and interprets
- DTDs. I hate DTDs. REXML supports the barest minimum of DTD parsing, and
- even that isn't complete. There is DTD parsing code in the works, but I
- only work on it when I'm really, really bored. Rumor has it that a
- contributor is working on a DTD parser for REXML; rest assured that any
- such contribution will be included with REXML as soon as it is
- available.</a>
-
- <q>I'm trying to create an ISO-8859-1 document, but when I add text to the
- document it isn't being properly encoded.</q>
-
- <a>Regardless of what the encoding of your document is, when you add text
- programmatically to a REXML document you <em>must</em> ensure that you are
- only adding UTF-8 to the tree. In particular, you can't add ISO-8859-1
- encoded text that contains characters above 0x80 to REXML trees -- you
- must convert it to UTF-8 before doing so. Luckily, this is easy:
- <code>text.unpack('C*').pack('U*')</code> will do the trick. 7-bit ASCII
- is identical to UTF-8, so you probably won't need to worry about this.</a>
-
- <q>How do I get the tag name of an Element?</q>
-
- <a>You take a look at the APIs, and notice that <code>Element</code>
- includes <code>Namespace</code>. Then you click on the
- <code>Namespace</code> link and look at the methods that
- <code>Element</code> includes from <code>Namespace</code>. One of these is
- <code>name()</code>. Another is <code>expanded_name()</code>. Yet another
- is <code>prefix()</code>. Then, you email the author of rdoc and ask him
- to extend rdoc so that it lists methods in the API that are included from
- other files, so that you don't have to do all of that looking around for
- your method.</a>
- </faq>
-
- <credits>
- <p>I've had help from a number of resources; if I haven't listed you here,
- it means that I just haven't gotten around to adding you, or that I'm a
- dork and have forgotten. In either case, feel free to write me and
- complain.</p>
-
- <list>
- <item>Mike Stok has been very active, sending not only fixes for bugs
- (especially in Functions), but also by providing unit tests and making
- sure REXML runs under Ruby 1.7. He also sent the most awesome hand
- knitted tea cozy, with "REXML" and the Ruby knitted into it.</item>
-
- <item>Kouhei Sutou translated the REXML API documentation to Japanese!
- Links are in the API docs section of the main documentation. He has also
- contributed a large number of bug reports and patches to fix bugs in
- REXML.</item>
-
- <item>Erik Terpstra heard my pleas and submitted several logos for
- REXML. After sagely procrastinating for several weeks, I finally forced
- my poor slave of a wife to pick one (this is what we call "delegation").
- She did, with caveats; Erik quickly made the changes, and the result is
- what you now see at the top of this page. He also supplied a <link
- href="img/rexml_50p.png">smaller version</link> that you can include
- with your projects that use REXML, if you'd like.</item>
-
- <item>Ernest Ellingson contributed the sourcecode for turning UTF16 and
- UNILE encodings into UTF8, which allowed REXML to get the 100% OASIS
- valid tests rating.</item>
-
- <item>Ian Macdonald provided me with a comprehensive, well written RPM
- spec file.</item>
-
- <item>Oliver M . Bolzer is maintaining a Debian package distribution of
- REXML. He also has provided good feedback and bug reports about
- namespace support.</item>
-
- <item>Michael Granger supplied a patch for REXML that make the unit
- tests pass under Ruby 1.7.</item>
-
- <item>James Britt contributed code that makes using
- Document.parse_stream easier to use by allowing it to be passed either a
- Source, File, or String.</item>
-
- <item>Tobias Reif: Numerous bug reports, and suggestions for
- improvement.</item>
-
- <item>Stefan Scholl, who provided a lot of feedback and bug reports
- while I was trying to get ISO-8859-1 support working.</item>
-
- <item>Steven E Lumos for volunteering information about XPath
- particulars.</item>
-
- <item>Fumitoshi UKAI provided some bug fixes for CData metacharacter
- quoting.</item>
-
- <item>TAKAHASHI Masayoshi, for information on UTF</item>
-
- <item>Robert Feldt: Bug reports and suggestions/recommendations about
- improving REXML. Testing is one of the most important aspects of
- software development.</item>
-
- <item><link
- href="http://www.themindelectric.com/exml/index.html">Electric
- XML</link>: This was, after all, the inspiration for REXML. Originally,
- I was just going to do a straight port, and although REXML doesn't in
- any way, shape or form resemble Electric XML, still the basic framework
- and philosophy was inspired by E-XML. And I still use E-XML in my Java
- projects.</item>
-
- <item><link
- href="http://www.io.com/~jimm/downloads/nqxml/index.html">NQXML</link>:
- While I may complain about the NQXML API, I wrote a few applications
- using it that wouldn't have been written otherwise, and it was very
- useful to me. It also encouraged me to write REXML. Never complain about
- free software *slap*.</item>
-
- <item>See my <link
- href="http://www.germane-software.com/~ser/technology.html">technologies
- page</link> for a more comprehensive list of computer technologies that
- I depend on for my day-to-day work.</item>
-
- <item>rdoc, an excellent JavaDoc analog<footnote>When I was first
- working on REXML, rdoc wasn't, IMO, very good, so I wrote API2XML.
- API2XML was good enough for a while, and then there was a flurry of work
- on rdoc, and it quickly surpassed API2XML in features. Since I was never
- really interested in maintaining a JavaDoc analog, I stopped support of
- API2XML, and am now recommending that people use
- rdoc.</footnote>.</item>
-
- <item>Many, many other people who've submitted bug reports, suggestions,
- and positive feedback. You're all co-developers!</item>
- </list>
- </credits>
-</documentation>
diff --git a/test/rexml/data/euc.xml b/test/rexml/data/euc.xml
deleted file mode 100644
index a3c3419498e..00000000000
--- a/test/rexml/data/euc.xml
+++ /dev/null
@@ -1,296 +0,0 @@
-<?xml version="1.0" encoding="euc-jp"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN">
-<html xml:lang="ja">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=euc-jp" />
-<meta http-equiv="Content-Style-Type" content="text/css" />
-<meta name="author" content="U.Nakamura" />
-<link rev="made" href="mailto:usa@ruby-lang.org" />
-<link rel="StyleSheet" href="./ruby.css" type="text/css" />
-<title>Ruby-mswin32</title>
-</head>
-<body>
-
-<h1><a id="top">Ruby-mswin32</a></h1>
-<p>あるいは、Windowsとの終わりなき戦い ;-(</p>
-<p>[日本語 / <a href="./index_en.html">English</a>]</p>
-
-
-
-<h2><a id="menu">▼ 目次</a></h2>
-<ul>
-<li><a href="#remark">注意事項</a></li>
-<li><a href="#ruby">Rubyとは?</a></li>
-<li><a href="#mswin32">mswin32版rubyとは?</a></li>
-<li><a href="#download">バイナリ ダウンロード</a></li>
-<li><a href="#install">インストール</a></li>
-<li><a href="#recent">最近の出来事</a></li>
-<li><a href="#link">リンク</a></li>
-</ul>
-
-
-
-<h2><a id="remark">▼ 注意事項</a></h2>
-<p>このページでは、mswin32版rubyの配布と変更状況のお知らせを行っています。</p>
-<p>ここは別に公式ページでもなんでもなくて、私が勝手に書いてるページです。ここで入手できるプログラム・情報(無いに等しいけど)については、各自の判断でご利用ください。<br />
-問い合わせは<a href="mailto:usa@ruby-lang.org">私</a>へ。間違っても他の人に迷惑をかけるようなことはしないでね。</p>
-
-
-
-<h2><a id="ruby">▼ Rubyとは?</a></h2>
-<p><a href="http://www.ruby-lang.org/ja/">Rubyのサイト</a>をご覧下さい。</p>
-
-
-
-<h2><a id="mswin32">▼ mswin32版rubyとは?</a></h2>
-<p>mswin32版rubyとは、32bit版Windows(Windows95・Windows98・WindowsMe・Windows NT・Windows 2000・WindowsXP・Windows 2003 Server、以下Windowsと表記)上で動作するRubyのバイナリの一つです。<br />
-Windows上で動作するRubyとしては、現在、5種類のバイナリが存在します。これらはそれぞれmswin32版・cygwin版・mingw32版・bccwin32版・djgpp版と呼ばれています。<br />
-それぞれの違いをまとめると以下のようになります(事実誤認があればお知らせください)。</p>
-<dl>
-<dt><a id="label:1">mswin32版</a></dt><dd>
-<p>VC++でコンパイルされる。Windowsから見ればもっとも「普通」のバイナリと言えるが、反面、Rubyが持つUNIXで特徴的な機能の一部が使用できない。1.7.3以降はmingw32版と拡張ライブラリについてはバイナリ互換性がある。<br />
-RUBY_PLATFORMは*-mswin32。</p>
-</dd>
-<dt><a id="label:2">cygwin版</a></dt><dd>
-<p>gccでコンパイルされ、<a href="http://sources.redhat.com/cygwin/">cygwin</a>環境で動作する。cygwin環境がUNIXライクな環境をWindows上で構築するものであるので、当然、cygwin版rubyは一般のUNIX用のものとだいたい同じように動作する(ことが期待できる)。<br />
-RUBY_PLATFORMは*-cygwin。</p>
-</dd>
-<dt><a id="label:3">mingw32版</a></dt><dd>
-<p>gccでコンパイルされる。ソースはほとんどmswin32版と共通であり、ランタイムライブラリも共通(MSVCRT.dll)なので、動作も(おそらく)mswin32版とほぼ同じ。1.7.3以降はmswin32版と拡張ライブラリについてはバイナリ互換性がある。<br />
-RUBY_PLATFORMは*-mingw32。</p>
-</dd>
-<dt><a id="label:4">bccwin32版</a></dt><dd>
-<p>BC++でコンパイルされる。ソースはかなりの部分がmswin32版と共通ではあるが、ランタイムライブラリが異なるので、細かいところで挙動がmswin32版とは異なる(はず)。1.7以降でサポートされる。<br />
-RUBY_PLATFORMは*-bccwin32。</p>
-</dd>
-<dt><a id="label:5">djgpp版</a></dt><dd>
-<p>DJGPPでコンパイルされる。DOS用のバイナリなので、もちろんDOSでも動作する。反面、WindowsにあってDOSにない機能の多くが使えない(ネットワーク関連など)。<br />
-RUBY_PLATFORMは*-msdosdjgpp。</p>
-</dd>
-</dl>
-<p>このページでは、上記のうちmswin32版のみを扱っています。<br />
-なお、cygwin版・mingw32版・djgpp版についてはわたなべさんの<a href="http://www.os.rim.or.jp/~eban/">Ruby binaries</a>から入手可能です。また、bccwin32版については小西さんの<a href="http://www001.upp.so-net.ne.jp/konishi/ruby/index.htm">Ruby</a>から入手可能です。</p>
-
-
-
-<h2><a id="download">▼ バイナリ ダウンロード</a></h2>
-<p>現在配布中の全てのバイナリはVC++ 5.0(Version 11.00.7022 for 80x86)でmakeしたものです。ruby自体に関しては、<a href="http://www.ruby-lang.org/ja/download.html">標準配布のソース</a>(または<a href="http://www.ruby-lang.org/~knu/cvsrepo-guide.html">CVS</a>のソース)からそのまま作成しています。拡張ライブラリについては各々のリンク先を参照してください。<br />
-いずれのバイナリもzip形式でアーカイブされています。</p>
-<p>md5sumのチェック方法ですが、例えばrubyがインストールされているなら下記のような方法があります。<br />
-<code>ruby -r md5 -e "puts MD5.new(File.open('filename', 'rb').read).hexdigest"</code></p>
-
-
-
-<h3><a id="release">Release</a></h3>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.8.1-i386-mswin32.zip">ruby-1.8.1-i386-mswin32.zip</a> (3,764KB) <em>最新Release版</em><br />
- ruby 1.8.1 (2003-12-25) [i386-mswin32]<br />
- md5sum : 6bbdabeb29f1a15fa69901e87d1108ac</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.8.0-i386-mswin32.zip">ruby-1.8.0-i386-mswin32.zip</a> (2,507KB)<br />
- ruby 1.8.0 (2003-08-04) [i386-mswin32]<br />
- md5sum : eaf9263062429fd4f722d9a70a38a9dc</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.8-i586-mswin32.zip">ruby-1.6.8-i586-mswin32.zip</a> (1,964KB)<br />
- ruby 1.6.8 (2002-12-24) [i586-mswin32]<br />
- md5sum : f704f1248ec25b96e3e1f3070afa915e</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.7-i586-mswin32.zip">ruby-1.6.7-i586-mswin32.zip</a> (1,972KB)<br />
- ruby 1.6.7 (2002-03-01) [i586-mswin32]<br />
- md5sum : ddedc40d0fc3b0ea1d6ac74f4976bfc6</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.6-i586-mswin32.zip">ruby-1.6.6-i586-mswin32.zip</a> (1,944KB)<br />
- ruby 1.6.6 (2001-12-26) [i586-mswin32]<br />
- md5sum : 96e0d1d19a37e5e7e50ae7ce99e34636</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.5-i586-mswin32.zip">ruby-1.6.5-i586-mswin32.zip</a> (1,896KB)<br />
- ruby 1.6.5 (2001-09-19) [i586-mswin32]<br />
- md5sum : c708ae98a05df2ff8dea5a70e3791bfa</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.4-i586-mswin32.zip">ruby-1.6.4-i586-mswin32.zip</a> (1,821KB)<br />
- ruby 1.6.4 (2001-06-04) [i586-mswin32]<br />
- md5sum : cf813ca19e40be164057b3562575e4da</li>
-</ul>
-
-
-
-
-
-
-
-<h3><a id="develop">Developing versions snapshots</a></h3>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.9.0-20040126-i386-mswin32.zip">ruby-1.9.0-20040126-i386-mswin32.zip</a> (3,849KB)<br />
- ruby 1.9.0 (2004-01-26) [i386-mswin32]<br />
- md5sum : fffafbf881cb6a85982220eae5a5b4f5</li>
-</ul>
-
-
-
-<h3><a id="stable">Stable versions snapshots</a></h3>
-<h4><a id="stable">1.8.0</a></h4>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.8.1-20040127-i386-mswin32.zip">ruby-1.8.1-20040127-i386-mswin32.zip</a> (3,822KB)<br />
- ruby 1.8.1 (2004-01-27) [i386-mswin32]<br />
- md5sum : 1fc0d5f53f0a75d0c6d1ca5d21082089</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.8.1-20031027-i386-mswin32.zip">ruby-1.8.1-20031027-i386-mswin32.zip</a> (3,075KB)<br />
- ruby 1.8.1 (2003-10-27) [i386-mswin32]<br />
- md5sum : 9dbdc644c529d207d0bda5d64478a5c4</li>
-</ul>
-<h4><a id="stable">1.6.8</a></h4>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.8-20030727-i586-mswin32.zip">ruby-1.6.8-20030727-i586-mswin32.zip</a> (2,093KB)<br />
- ruby 1.6.8 (2003-07-27) [i586-mswin32]<br />
- md5sum : 28c3b92b162319b3d6bc99c9996cad15</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ruby-1.6.8-20030515-i586-mswin32.zip">ruby-1.6.8-20030515-i586-mswin32.zip</a> (2,091KB)<br />
- ruby 1.6.8 (2003-05-15) [i586-mswin32]<br />
- md5sum : e5f6558de261d111add4f657ad5e345f</li>
-</ul>
-
-
-
-<h3><a id="ext">Extension libraries</a></h3>
-<h4><a id="ext">1.8.0</a></h4>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/racc-1.4.4-all-i386-mswin32-1.8.zip">racc-1.4.4-all-i386-mswin32-1.8.zip</a> (70KB)<br />
- <a href="http://www.loveruby.net/en/racc.html">racc</a> 1.4.4-all (for ruby 1.8.1)<br />
- md5sum : 46c4d48b714fb1ded880e7e7af456b28</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/vrswin-030906-i386-mswin32-1.8.zip">vrswin-030906-i386-mswin32-1.8.zip</a> (54KB)<br />
- <a href="http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html">VisualuRuby (swin)</a> 030906 (for ruby 1.8.0)<br />
- md5sum : 11c2d30e2a05e9ea7e097ec7b066cedf</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/vruby-030906-i386-mswin32-1.8.zip">vruby-030906-i386-mswin32-1.8.zip</a> (96KB)<br />
- <a href="http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html">VisualuRuby (vruby)</a> 030906 (for ruby 1.8.0)<br />
- md5sum : 77a42995e42e869932f5fb282cc297ea</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/eruby-1.0.4-i386-mswin32-1.8.zip">eruby-1.0.4-i386-mswin32-1.8.zip</a> (75KB)<br />
- <a href="http://www.modruby.net/">eruby</a> 1.0.4 (for ruby 1.8.0)<br />
- md5sum : de7282647f015b1d20a28dcf7c2b8715</li>
-</ul>
-<h4><a id="ext">1.6.8</a></h4>
-<ul>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/vrswin-030521-i586-mswin32-1.6.zip">vrswin-030521-i586-mswin32-1.6.zip</a> (55KB)<br />
- <a href="http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html">VisualuRuby (swin)</a> 030521 (for ruby 1.6.8)<br />
- md5sum : eae3284c6f79be7a119858ff9e940985</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/vruby-030517-i586-mswin32-1.6.zip">vruby-030517-i586-mswin32-1.6.zip</a> (95KB)<br />
- <a href="http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html">VisualuRuby (vruby)</a> 030517 (for ruby 1.6.8)<br />
- md5sum : a32af752428cf3aa03000d66d8deca33</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/tmail-0.10.7-i586-mswin32-1.6.zip">tmail-0.10.7-i586-mswin32-1.6.zip</a> (160KB)<br />
- <a href="http://www.loveruby.net/en/tmail.html">TMail</a> 0.10.7 (for ruby 1.6.8)<br />
- md5sum : 74351ed81550dfbf3bfaf8252c316326</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/eruby-1.0.3-i586-mswin32-1.6.zip">eruby-1.0.3-i586-mswin32-1.6.zip</a> (74KB)<br />
- <a href="http://www.modruby.net/">eruby</a> 1.0.3 (for ruby 1.6.8)<br />
- md5sum : e05d654128422846f86ca84f55bf7bcb</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/rubywin-0.0.4.3-i586-mswin32-1.6.zip">rubywin-0.0.4.3-i586-mswin32-1.6.zip</a> (286KB)<br />
- <a href="http://homepage1.nifty.com/markey/ruby/rubywin/index_e.html">RubyWin</a> 0.0.4.3 (for ruby 1.6.8)<br />
- md5sum : 3f2226ef0c6e41b31c2f337f778e3e18</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/shim-20021224-i586-mswin32-1.6.zip">shim-20021224-i586-mswin32-1.6.zip</a> (138KB)<br />
- <a href="http://www.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/shim/">Ruby Shim</a> 20021224 (for ruby 1.6.8)<br />
- md5sum : 7ee4363195973a1df0584cb467e5ce82</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/racc-1.4.3-all-i586-mswin32-1.6.zip">racc-1.4.3-all-i586-mswin32-1.6.zip</a> (124KB)<br />
- <a href="http://www.loveruby.net/en/racc.html">racc</a> 1.4.3-all (for ruby 1.6.8)<br />
- md5sum : 1f093aabb464bef3074112949228a8c6</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/win32ole-0.5.2-i586-mswin32-1.6.zip">win32ole-0.5.2-i586-mswin32-1.6.zip</a> (59KB)<br />
- <a href="http://homepage1.nifty.com/markey/ruby/win32ole/index_e.html">Win32OLE</a> 0.5.2 (for ruby 1.6.8)&lt;<br />
- md5sum : 960f7205923a9243cff567d291b254ad</li>
-<li><a href="ftp://ftp.ruby-lang.org/pub/ruby/binaries/mswin32/ext/uconv-0.4.11-i586-mswin32-1.6.zip">uconv-0.4.11-i586-mswin32-1.6.zip</a> (110KB)<br />
- <a href="http://www.yoshidam.net/Ruby.html#uconv">uconv</a> 0.4.11 (for ruby 1.6.8)<br />
- md5sum : c08f3662abee8e7186283741f89b88d7</li>
-</ul>
-
-
-
-<h2><a id="install">▼ インストール</a></h2>
-<p>上記のバイナリをインストールする場合は、お好みのディレクトリ(以下<code>$TOPDIR</code>と記述)に展開してください。ディレクトリ付きで圧縮されてますので、展開時にはディレクトリ付きで展開するのを忘れずに(意味がわからない人は気にしなくていいです)。<br />
-展開後は、<code>$TOPDIR\bin</code>に<code>PATH</code>を通しておいてください。</p>
-<p>なお、以下の拡張ライブラリは、この配布物に含まれない外部のライブラリに依存しています。</p>
-<ul>
-<li>curses.so : PDCursesに依存しています。</li>
-<li>dbm.so : GDBMに依存しています。</li>
-<li>gdbm.so : GDBMに依存しています。</li>
-<li>iconv.so : Iconvに依存しています。</li>
-<li>openssl.so : OpenSSLに依存しています。</li>
-<li>readline.so : readlineに依存しています。</li>
-<li>tcltklib.so : Tcl/Tkに依存しています。</li>
-<li>zlib.so : Zlibに依存しています。</li>
-</ul>
-<p>上記のうち、PDCurses・GDBM・OpenSSL・readline・Zlibについては、<a href="http://jarp.jin.gr.jp/win32/">Porting Libraries to Win32</a>にバイナリが存在します。<br />
-Iconvについては、Meadowy.orgで配布されている<a href="http://www.meadowy.org/meadow/dists/snapshot/iconv-1.8.win32.zip">iconv-1.8.win32.zip</a>を利用しています。<br />
-Tcl/Tkについては、<a href="http://www.activestate.com/">ActiveState</a>で配布されている<a href="http://www.activestate.com/Products/ActiveTcl/">ActiveTcl</a>を利用しています。</p>
-
-
-
-<h2><a id="recent">▼ 最近の出来事</a></h2>
-
-
-
-<h3><a id="d20040127">2004-01-27</a></h3>
-<p>あけましておめでとうございます。って遅いよ!</p>
-<p>ruby-1.8.1-20040127とruby-1.9.0-20040126を置きました。<br />
-前者は主に1.8.1リリース版で発見された不具合の修正です。後者は開発版。</p>
-
-<h3><a id="d20031225">2003-12-25</a></h3>
-<p>メリークリスマス! ruby-1.8.1がリリースされました!<br />
-(previewを一つ飛ばしちゃいました、ごめんなさい...)</p>
-
-<h3><a id="d20031206">2003-12-06</a></h3>
-<p>ruby-1.8.1-preview3を置きました。思いのほか間が空いちゃいましたね。</p>
-
-<h3><a id="d20031101">2003-11-01</a></h3>
-<p>ruby-1.8.1-preview2を置きました。</p>
-
-<h3><a id="d20031028">2003-10-28</a></h3>
-<p>ruby-1.8.1-20031027を置きました。<br />
-racc-1.4.4-allを置きました。</p>
-
-<h3><a id="d20030907">2003-09-07</a></h3>
-<p>eruby-1.0.4・vrswin-030906・vruby-030906を置きました。</p>
-
-<h3><a id="d20030812">2003-08-12</a></h3>
-<p>ruby-1.8.0-20030812を置きました。</p>
-<p>vrswin-030811・vruby-030811を置きました。今回から置く拡張ライブラリは全て1.8用になります。</p>
-
-<h3><a id="d20030804">2003-08-04</a></h3>
-<p>ruby-1.8.0を置きました。Ruby 1.8系最初のリリースとなります。<br />
-1.6系からの変更点については、<a href="ftp://ftp.ruby-lang.org/pub/ruby/1.8/changes.1.8.0">changes.1.8.0</a>などをご覧ください。</p>
-
-<h3><a id="d20030731">2003-07-31</a></h3>
-<p>ruby-1.8.0-preview6を置きました。えーと、これを含めてあと2回previewが出る模様です :)</p>
-
-<h3><a id="d20030728">2003-07-28</a></h3>
-<p>ruby-1.8.0-preview5を置きました。おそらくこれが1.8.0の最後のpreviewになるでしょう。<br />
-ruby-1.6.8-20030727を置きました。</p>
-
-
-
-<h3><a id="old">かつての出来事</a></h3>
-<p><a href="./old.html">こちら</a>をどうぞ。</p>
-
-
-
-<h2><a id="link">▼ リンク</a></h2>
-<p>mswin32版に関する(と思われる)リンクです。勝手に張ってますので、不都合があれば<a href="mailto:usa@osb.att.ne.jp">私</a>までご連絡ください。</p>
-<ul>
-<li><a href="http://www.ruby-lang.org/">Ruby Home Page</a> (<a href="http://www.ruby-lang.org/ja/">日本語</a> / <a href="http://www.ruby-lang.org/en/">English</a>)<br />
- 言わずとしれた、本家サイト。</li>
-<li>雑記帳 (<a href="http://homepage1.nifty.com/markey/">日本語</a> / <a href="http://homepage1.nifty.com/markey/index_e.html">English</a>)<br />
- 助田さんのページ。<a href="http://homepage1.nifty.com/markey/ruby/rubywin/index.html">RubWin</a>・<a href="http://homepage1.nifty.com/markey/ruby/win32ole/index.html">Win32OLE</a>などがあります。</li>
-<li><a href="http://www.moonwolf.com/ruby/">Script/Ruby</a> (日本語)<br />
- MoonWolfさんのページ。Win32Moduleなどがあります。</li>
-<li>ActiveScriptRuby (<a href="http://www.geocities.co.jp/SiliconValley-PaloAlto/9251/ruby/index.html">日本語</a> / <a href="http://www.geocities.co.jp/SiliconValley-PaloAlto/9251/ruby/main.html">English</a>)<br />
- artonさんのページ。Windows版Rubyの未来はここにあるのかも。</li>
-<li>VisualuRuby計画(仮称) (<a href="http://www.osk.3web.ne.jp/~nyasu/software/vrproject.html">日本語</a> / <a href="http://www.osk.3web.ne.jp/~nyasu/vruby/vrproject-e.html">English</a>)<br />
- nyasuさんのページ。VisualuRubyなどがあります(ってこれもそのまんま)。WindowsでRubyを使うための<a href="http://www.osk.3web.ne.jp/~nyasu/software/rubyonwin.html">リンク集</a>が充実してます。ちなみに、当サイトのデザインはこちらのパクリです。多謝!</li>
-<li>Ruby (<a href="http://www.yoshidam.net/Ruby_ja.html">日本語</a> / <a href="http://www.yoshidam.net/Ruby.html">English</a>)<br />
- よしだむさんのページ。<a href="http://www.yoshidam.net/Ruby_ja.html#susie">Susieプラグインライブラリ</a>や<a href="http://www.yoshidam.net/Ruby_ja.html#rddraw">DirectDraw for Ruby</a>などがあります。</li>
-<li><a href="http://homepage2.nifty.com/sakazuki/rde.html">RDE(Ruby Development Environment)</a> (日本語)<br />
- sakazukiさんのページ。mswin32版ユーザなら必見です。推奨環境はartonさんとこのActiveScriptRubyですが (^^; ここの配布物を使っても問題なく動作します。</li>
-</ul>
-
-
-
-<p class="footer">
-[<a href="../">戻る</a>]
-</p>
-<address>written by <a href="mailto:usa@ruby-lang.org">U.Nakamura</a></address>
-<p class="versions">
-ruby 1.9.0 (2004-01-13)<br />
-ERb 2.0.4<br />
-RDtool 0.6.11<br />
-rublog 0.0.2
-</p>
-
-</body>
-</html>
diff --git a/test/rexml/data/evaluate.xml b/test/rexml/data/evaluate.xml
deleted file mode 100644
index 90d06bd6527..00000000000
--- a/test/rexml/data/evaluate.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<evaluate>
- <data>
- <jumps>
- <subject>
- <the/>
- <fox color="brown"/>
- <speed category="quick"/>
- </subject>
- <over/>
- <object>
- <the/>
- <dog color="unspecified"/>
- <speed category="lazy"/>
- </object>
- </jumps>
- </data>
-
- <!-- there is one element with attribute color="brown" should this
- meta-test should succeed -->
-
- <metatest select="//@color">brown</metatest>
-
- <!-- there is no element with attribute category="moderate" -->
- <metatest select="//speed/@category">moderate</metatest>
-
-</evaluate>
diff --git a/test/rexml/data/fibo.xml b/test/rexml/data/fibo.xml
deleted file mode 100644
index 9b5d0ecd870..00000000000
--- a/test/rexml/data/fibo.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Fibonacci_Numbers>
- <fibonacci index="0">0</fibonacci>
- <fibonacci index="1">1</fibonacci>
- <fibonacci index="2">1</fibonacci>
- <fibonacci index="3">2</fibonacci>
- <fibonacci index="4">3</fibonacci>
- <fibonacci index="5">5</fibonacci>
- <fibonacci index="6">8</fibonacci>
- <fibonacci index="7">13</fibonacci>
- <fibonacci index="8">21</fibonacci>
- <fibonacci index="9">34</fibonacci>
- <fibonacci index="10">55</fibonacci>
- <fibonacci index="11">89</fibonacci>
- <fibonacci index="12">144</fibonacci>
- <fibonacci index="13">233</fibonacci>
- <fibonacci index="14">377</fibonacci>
- <fibonacci index="15">610</fibonacci>
- <fibonacci index="16">987</fibonacci>
- <fibonacci index="17">1597</fibonacci>
- <fibonacci index="18">2584</fibonacci>
- <fibonacci index="19">4181</fibonacci>
- <fibonacci index="20">6765</fibonacci>
- <fibonacci index="21">10946</fibonacci>
- <fibonacci index="22">17711</fibonacci>
- <fibonacci index="23">28657</fibonacci>
- <fibonacci index="24">46368</fibonacci>
- <fibonacci index="25">75025</fibonacci>
-</Fibonacci_Numbers>
diff --git a/test/rexml/data/foo.xml b/test/rexml/data/foo.xml
deleted file mode 100644
index 53b9a4e0039..00000000000
--- a/test/rexml/data/foo.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE schema SYSTEM "foo.dtd" [
-<!ATTLIST root-el
- xmlns:human CDATA #FIXED "http://www.foo.com/human">
-]>
-<root-el xmlns="http://www.bar.com/doc"
- xmlns:table="http://www.foo.com/table">
- <human:leg>human leg</human:leg>
- <table:leg>table leg</table:leg>
-</root-el>
diff --git a/test/rexml/data/google.2.xml b/test/rexml/data/google.2.xml
deleted file mode 100644
index a1df93b107b..00000000000
--- a/test/rexml/data/google.2.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<form xmlns='http://www.w3.org/1999/xhtml'
- enctype='application/x-www-form-urlencoded' class='rollover'
- action='ModifyCampaign' method='POST'
- onsubmit='return beforeRolloverSubmit(this, &apos;No campaigns selected.&apos;);'>
- <a name='campaigns' shape='rect'/>
- <tr bgcolor='#dbe6de'>
- <th class='boxcolumn' rowspan='1' align='left' colspan='1'
- width='1%'>
- <script type='text/javascript'>document.write(" &lt;input
- type\u003d\"checkbox\" name\u003d\"toggleAll\"
- onclick\u003d\"rowToggleAll(this);\" title\u003d\"Select or
- de-select all campaigns on this page\"&gt; ");</script>
- </th>
- <th bgcolor='#dbe6de' title='Sort by campaign name' nowrap='nowrap'
- rowspan='1' align='left' colspan='1'>
- <b>
- <a href='CampaignSummary?campaignsummaryt=0%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Campaign Name</a>
- </b>
- </th>
- <th bgcolor='#dbe6de' title='Sort by campaign status'
- nowrap='nowrap' rowspan='1' align='left' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=1%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Current Status</a>
- </th>
- <th bgcolor='#dbe6de'
- title='Sort by daily budget (maximum spending per day)'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=2%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Current Budget</a>
- <span style='white-space: nowrap'>
- <a href='/support/bin/answer.py?answer=6312&amp;hl=en_US'
- shape='rect' id='' onclick='return helpPopUp(this);' style=''
- target='google_popup'>[?]</a>
- </span>
- </th>
- <th bgcolor='#c6d7cf' title='Sort by clicks on your ads'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=-3%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Clicks</a>
- <a href='CampaignSummary?campaignsummaryt=-3%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- shape='rect' style='text-decoration:none;'>
- <img src='/select/images/sortdown.gif' border='0' alt=''/>
- </a>
- </th>
- <th bgcolor='#dbe6de' title='Sort by ad impressions served'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=4%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Impr.</a>
- </th>
- <th bgcolor='#dbe6de' title='Sort by CTR (clickthrough rate)'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=5%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>CTR</a>
- </th>
- <th bgcolor='#dbe6de' title='Sort by average cost per click (USD)'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=6%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Avg. CPC</a>
- </th>
- <th bgcolor='#dbe6de' class='' title='Sort by total cost (USD)'
- nowrap='nowrap' rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=8%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Cost</a>
- </th>
- <th bgcolor='#dbe6de' title='Conversion Rate' nowrap='nowrap'
- rowspan='1' align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=11%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Conv. Rate</a>
- </th>
- <th bgcolor='#dbe6de' class='rightcolumn'
- title='Cost per Conversion' nowrap='nowrap' rowspan='1'
- align='right' colspan='1'>
- <a href='CampaignSummary?campaignsummaryt=12%3Aa&amp;gsessionid=ezmXK9aaXnI#campaigns'
- class='bluelink' shape='rect'>Cost/Conv.</a>
- </th>
- </tr>
- <tr onmouseover='ron(3527627);' id='tr_3527627'
- onmouseout='roff(3527627);'>
- <td class='boxcolumn' rowspan='1' onclick='rowToggle(3527627);'
- colspan='1'>
- <input name='campaignid' type='checkbox' id='box_3527627'
- value='3527627' onclick='toggleRow(this);'/>
- </td>
- <td rowspan='1' colspan='1'>
- <a href='CampaignManagement?campaignid=3527627#a' shape='rect'>Test</a>
- </td>
- <td rowspan='1' colspan='1'>
- <b>
- <font size='-1' color='#b98b00'>Paused</font>
- </b>
- </td>
- <td class='r' rowspan='1' colspan='1'>
- <font color='#666666'>Test</font>
- </td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='' rowspan='1' align='right' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='rightcolumn' rowspan='1' align='right' colspan='1'>1</td>
- </tr>
- <tr onmouseover='ron(7680287);' id='tr_7680287'
- onmouseout='roff(7680287);'>
- <td class='boxcolumn' rowspan='1' onclick='rowToggle(7680287);'
- colspan='1'>
- <input name='campaignid' type='checkbox' id='box_7680287'
- value='7680287' onclick='toggleRow(this);'/>
- </td>
- <td rowspan='1' colspan='1'>
- <a href='CampaignManagement?campaignid=7680287#a' shape='rect'>Test</a>
- </td>
- <td rowspan='1' colspan='1'>
- <b>
- <font size='-1' color='#b98b00'>Paused</font>
- </b>
- </td>
- <td class='r' rowspan='1' colspan='1'>
- <font color='#666666'>Test</font>
- </td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='' rowspan='1' align='right' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='rightcolumn' rowspan='1' align='right' colspan='1'>1</td>
- </tr>
- <tr onmouseover='ron(6747347);' id='tr_6747347'
- onmouseout='roff(6747347);'>
- <td class='boxcolumn' rowspan='1' onclick='rowToggle(6747347);'
- colspan='1'>
- <input name='campaignid' type='checkbox' id='box_6747347'
- value='6747347' onclick='toggleRow(this);'/>
- </td>
- <td rowspan='1' colspan='1'>
- <a href='CampaignManagement?campaignid=6747347#a' shape='rect'>Test</a>
- </td>
- <td rowspan='1' colspan='1'>
- <b>
- <font size='-1' color='#b98b00'>Test</font>
- </b>
- </td>
- <td class='r' rowspan='1' colspan='1'>
- <font color='#666666'>Test</font>
- </td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='' rowspan='1' align='right' colspan='1'>1</td>
- <td class='r' rowspan='1' colspan='1'>1</td>
- <td class='rightcolumn' rowspan='1' align='right' colspan='1'>1</td>
- </tr>
-</form>
diff --git a/test/rexml/data/id.xml b/test/rexml/data/id.xml
deleted file mode 100644
index 749ab207ce6..00000000000
--- a/test/rexml/data/id.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE foo [
-
-<!ELEMENT foo (bar)>
-<!ATTLIST foo id CDATA #IMPLIED>
-<!ELEMENT bar (#PCDATA|cheese)*>
-<!ATTLIST bar id ID #REQUIRED>
-<!ELEMENT cheese (#PCDATA)>
-<!ATTLIST cheese kind ID #IMPLIED>
-]>
-
-<foo id="foobar">
- <bar id="fb1">
- baz
- <cheese kind="edam">gouda</cheese>
- baz
- <cheese kind="gouda">cheddar</cheese>
- baz
- </bar>
-</foo>
diff --git a/test/rexml/data/iso8859-1.xml b/test/rexml/data/iso8859-1.xml
deleted file mode 100644
index 5fb04ec9bad..00000000000
--- a/test/rexml/data/iso8859-1.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version='1.0' encoding='ISO-8859-1'?>
-<booh>
- <image caption='andr is nice'/>
-</booh>
diff --git a/test/rexml/data/jaxen24.xml b/test/rexml/data/jaxen24.xml
deleted file mode 100644
index 9b819967eea..00000000000
--- a/test/rexml/data/jaxen24.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<body><p><span></span></p><div></div></body>
diff --git a/test/rexml/data/jaxen3.xml b/test/rexml/data/jaxen3.xml
deleted file mode 100644
index a87723a3b98..00000000000
--- a/test/rexml/data/jaxen3.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration>
- <hostname>
- <val>2</val>
- <attrlist>
- <hostname>CE-A</hostname>
- </attrlist>
- </hostname>
- <hostname>
- <val>1</val>
- <attrlist>
- <hostname>CE-B</hostname>
- </attrlist>
- </hostname>
-</Configuration>
diff --git a/test/rexml/data/lang.xml b/test/rexml/data/lang.xml
deleted file mode 100644
index 49b45db2915..00000000000
--- a/test/rexml/data/lang.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-<e1 xml:lang="hr">
- <e2 xml:lang="en-US">
- <e3/>
- </e2>
- <e2 xml:lang="hu">
- <e3/>
- <e3/>
- <e3 xml:lang="es"/>
- </e2>
-</e1> \ No newline at end of file
diff --git a/test/rexml/data/lang0.xml b/test/rexml/data/lang0.xml
deleted file mode 100644
index 283b4e0f085..00000000000
--- a/test/rexml/data/lang0.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<programming_languages>
- <language oop='yes'>
- <name>
- Ruby
- </name>
- <creator>
- Yukihiro Matsumoto
- </creator>
- </language>
- <language oop='yes'>
- <name>
- Python
- </name>
- <creator>
- Guido van Rossum
- </creator>
- </language>
-</programming_languages>
diff --git a/test/rexml/data/message.xml b/test/rexml/data/message.xml
deleted file mode 100644
index 3b81df2a86d..00000000000
--- a/test/rexml/data/message.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<message>
- <header>
- <service>lookupformservice</service>
- <connectionid>9</connectionid>
- <appid>stammdaten</appid>
- <action>new</action>
- </header>
- <body>
- <data>
- <items>
- <item>
- <name>iteminfo</name>
- <value>ELE</value>
- </item>
- <item>
- <name>parentinfo</name>
- <value>Pruefgebiete</value>
- </item>
- <item>
- <name>id</name>
- <value>1</value>
- </item>
- </items>
- </data>
- </body>
-</message>
diff --git a/test/rexml/data/moreover.xml b/test/rexml/data/moreover.xml
deleted file mode 100644
index 38d4c4f81cd..00000000000
--- a/test/rexml/data/moreover.xml
+++ /dev/null
@@ -1,244 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
- <moreovernews>
- <article code="13563275">
- <url>http://c.moreover.com/click/here.pl?x13563273</url>
- <headline_text>e-Commerce Operators Present Version 1.0 of the XML Standard</headline_text>
- <source>StockAccess</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.stockaccess.com/index.html</document_url>
- <harvest_time>Dec 24 2000 6:28AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13560996">
- <url>http://c.moreover.com/click/here.pl?x13560995</url>
- <headline_text>W3C Publishes XML Protocol Requirements Document</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 24 2000 12:22AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13553522">
- <url>http://c.moreover.com/click/here.pl?x13553521</url>
- <headline_text>Prowler: Open Source XML-Based Content Management Framework</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 23 2000 2:05PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13549014">
- <url>http://c.moreover.com/click/here.pl?x13549013</url>
- <headline_text>The Middleware Company Debuts Public Training Courses in Ejb, J2ee And Xml</headline_text>
- <source>Java Industry Connection</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://industry.java.sun.com/javanews/more/hotnews/</document_url>
- <harvest_time>Dec 23 2000 12:15PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13544468">
- <url>http://c.moreover.com/click/here.pl?x13544467</url>
- <headline_text>Revised Working Draft for the W3C XML Information Set</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 23 2000 5:50AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13534837">
- <url>http://c.moreover.com/click/here.pl?x13534836</url>
- <headline_text>XML: Its The Great Peacemaker</headline_text>
- <source>ZDNet</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.zdnet.com/intweek/</document_url>
- <harvest_time>Dec 22 2000 9:05PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13533486">
- <url>http://c.moreover.com/click/here.pl?x13533485</url>
- <headline_text>Project eL - The XML Leningrad Codex Markup Project</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 22 2000 8:34PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13533489">
- <url>http://c.moreover.com/click/here.pl?x13533488</url>
- <headline_text>XML Linking Language (XLink) and XML Base Specifications Issued as W3C Proposed Recommenda</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 22 2000 8:34PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13533493">
- <url>http://c.moreover.com/click/here.pl?x13533492</url>
- <headline_text>W3C Releases XHTML Basic Specification as a W3C Recommendation</headline_text>
- <source>Xml</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.xml.com/</document_url>
- <harvest_time>Dec 22 2000 8:34PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13521835">
- <url>http://c.moreover.com/click/here.pl?x13521827</url>
- <headline_text>Java, Xml And Oracle9i(TM) Make A Great Team</headline_text>
- <source>Java Industry Connection</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://industry.java.sun.com/javanews/more/hotnews/</document_url>
- <harvest_time>Dec 22 2000 3:21PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13512020">
- <url>http://c.moreover.com/click/here.pl?x13511233</url>
- <headline_text>Competing initiatives to vie for security standard</headline_text>
- <source>ZDNet</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.zdnet.com/eweek/filters/news/</document_url>
- <harvest_time>Dec 22 2000 10:54AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13492401">
- <url>http://c.moreover.com/click/here.pl?x13492397</url>
- <headline_text>Oracle Provides Developers with Great Xml Reading This Holiday Season</headline_text>
- <source>Java Industry Connection</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://industry.java.sun.com/javanews/more/hotnews/</document_url>
- <harvest_time>Dec 21 2000 8:08PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13491296">
- <url>http://c.moreover.com/click/here.pl?x13491292</url>
- <headline_text>XML as the great peacemaker - Extensible Markup Language Accomplished The Seemingly Impossible This Year: It B</headline_text>
- <source>Hospitality Net</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.hospitalitynet.org/news/list.htm?c=2000</document_url>
- <harvest_time>Dec 21 2000 7:45PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13484761">
- <url>http://c.moreover.com/click/here.pl?x13484758</url>
- <headline_text>XML as the great peacemaker</headline_text>
- <source>CNET</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://news.cnet.com/news/0-1003.html?tag=st.ne.1002.dir.1003</document_url>
- <harvest_time>Dec 21 2000 4:41PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13480897">
- <url>http://c.moreover.com/click/here.pl?x13480896</url>
- <headline_text>COOP Switzerland Selects Mercator as Integration Platform</headline_text>
- <source>Stockhouse Canada</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.stockhouse.ca/news/</document_url>
- <harvest_time>Dec 21 2000 1:55PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13471024">
- <url>http://c.moreover.com/click/here.pl?x13471023</url>
- <headline_text>Competing XML Specs Move Toward a Union</headline_text>
- <source>Internet World</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://www.internetworld.com/</document_url>
- <harvest_time>Dec 21 2000 11:14AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13452281">
- <url>http://c.moreover.com/click/here.pl?x13452280</url>
- <headline_text>Next-generation XHTML stripped down for handhelds</headline_text>
- <source>CNET</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://news.cnet.com/news/0-1005.html?tag=st.ne.1002.dir.1005</document_url>
- <harvest_time>Dec 20 2000 9:11PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13451791">
- <url>http://c.moreover.com/click/here.pl?x13451789</url>
- <headline_text>Xml Powers Oracle9i(TM) Dynamic Services</headline_text>
- <source>Java Industry Connection</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://industry.java.sun.com/javanews/more/hotnews/</document_url>
- <harvest_time>Dec 20 2000 9:05PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13442098">
- <url>http://c.moreover.com/click/here.pl?x13442097</url>
- <headline_text>XML DOM reference guide</headline_text>
- <source>ASPWire</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://aspwire.com/</document_url>
- <harvest_time>Dec 20 2000 6:26PM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- <article code="13424118">
- <url>http://c.moreover.com/click/here.pl?x13424117</url>
- <headline_text>Repeat/Xqsite And Bowstreet Team to Deliver Integrated Xml Solutions</headline_text>
- <source>Java Industry Connection</source>
- <media_type>text</media_type>
- <cluster>moreover...</cluster>
- <tagline> </tagline>
- <document_url>http://industry.java.sun.com/javanews/more/hotnews/</document_url>
- <harvest_time>Dec 20 2000 9:04AM</harvest_time>
- <access_registration> </access_registration>
- <access_status> </access_status>
- </article>
- </moreovernews>
-
diff --git a/test/rexml/data/much_ado.xml b/test/rexml/data/much_ado.xml
deleted file mode 100644
index f008fadbb06..00000000000
--- a/test/rexml/data/much_ado.xml
+++ /dev/null
@@ -1,6850 +0,0 @@
-<?xml version="1.0"?>
-<PLAY>
-<TITLE>Much Ado about Nothing</TITLE>
-
-<FM>
-<P>Text placed in the public domain by Moby Lexical Tools, 1992.</P>
-<P>SGML markup by Jon Bosak, 1992-1994.</P>
-<P>XML version by Jon Bosak, 1996-1998.</P>
-<P>This work may be freely copied and distributed worldwide.</P>
-</FM>
-
-
-<PERSONAE>
-<TITLE>Dramatis Personae</TITLE>
-
-<PERSONA>DON PEDRO, prince of Arragon.</PERSONA>
-<PERSONA>DON JOHN, his bastard brother.</PERSONA>
-<PERSONA>CLAUDIO, a young lord of Florence.</PERSONA>
-<PERSONA>BENEDICK, a young lord of Padua.</PERSONA>
-<PERSONA>LEONATO, governor of Messina.</PERSONA>
-<PERSONA>ANTONIO, his brother.</PERSONA>
-<PERSONA>BALTHASAR, attendant on Don Pedro.</PERSONA>
-
-<PGROUP>
-<PERSONA>CONRADE</PERSONA>
-<PERSONA>BORACHIO</PERSONA>
-<GRPDESCR>followers of Don John.</GRPDESCR>
-</PGROUP>
-
-<PERSONA>FRIAR FRANCIS</PERSONA>
-<PERSONA>DOGBERRY, a constable.</PERSONA>
-<PERSONA>VERGES, a headborough.</PERSONA>
-<PERSONA>A Sexton.</PERSONA>
-<PERSONA>A Boy.</PERSONA>
-<PERSONA>HERO, daughter to Leonato.</PERSONA>
-<PERSONA>BEATRICE, niece to Leonato.</PERSONA>
-
-<PGROUP>
-<PERSONA>MARGARET</PERSONA>
-<PERSONA>URSULA</PERSONA>
-<GRPDESCR>gentlewomen attending on Hero.</GRPDESCR>
-</PGROUP>
-
-<PERSONA>Messengers, Watch, Attendants, &amp;c. </PERSONA>
-</PERSONAE>
-
-<SCNDESCR>SCENE Messina.</SCNDESCR>
-
-<PLAYSUBT>MUCH ADO ABOUT NOTHING</PLAYSUBT>
-
-<ACT><TITLE>ACT I</TITLE>
-
-<SCENE><TITLE>SCENE I. Before LEONATO'S house.</TITLE>
-<STAGEDIR>Enter LEONATO, HERO, and BEATRICE, with a
-Messenger</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I learn in this letter that Don Peter of Arragon</LINE>
-<LINE>comes this night to Messina.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>He is very near by this: he was not three leagues off</LINE>
-<LINE>when I left him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>How many gentlemen have you lost in this action?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>But few of any sort, and none of name.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>A victory is twice itself when the achiever brings</LINE>
-<LINE>home full numbers. I find here that Don Peter hath</LINE>
-<LINE>bestowed much honour on a young Florentine called Claudio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>Much deserved on his part and equally remembered by</LINE>
-<LINE>Don Pedro: he hath borne himself beyond the</LINE>
-<LINE>promise of his age, doing, in the figure of a lamb,</LINE>
-<LINE>the feats of a lion: he hath indeed better</LINE>
-<LINE>bettered expectation than you must expect of me to</LINE>
-<LINE>tell you how.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>He hath an uncle here in Messina will be very much</LINE>
-<LINE>glad of it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>I have already delivered him letters, and there</LINE>
-<LINE>appears much joy in him; even so much that joy could</LINE>
-<LINE>not show itself modest enough without a badge of</LINE>
-<LINE>bitterness.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Did he break out into tears?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>In great measure.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>A kind overflow of kindness: there are no faces</LINE>
-<LINE>truer than those that are so washed. How much</LINE>
-<LINE>better is it to weep at joy than to joy at weeping!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I pray you, is Signior Mountanto returned from the</LINE>
-<LINE>wars or no?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>I know none of that name, lady: there was none such</LINE>
-<LINE>in the army of any sort.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What is he that you ask for, niece?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>My cousin means Signior Benedick of Padua.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>O, he's returned; and as pleasant as ever he was.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>He set up his bills here in Messina and challenged</LINE>
-<LINE>Cupid at the flight; and my uncle's fool, reading</LINE>
-<LINE>the challenge, subscribed for Cupid, and challenged</LINE>
-<LINE>him at the bird-bolt. I pray you, how many hath he</LINE>
-<LINE>killed and eaten in these wars? But how many hath</LINE>
-<LINE>he killed? for indeed I promised to eat all of his killing.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Faith, niece, you tax Signior Benedick too much;</LINE>
-<LINE>but he'll be meet with you, I doubt it not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>He hath done good service, lady, in these wars.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You had musty victual, and he hath holp to eat it:</LINE>
-<LINE>he is a very valiant trencherman; he hath an</LINE>
-<LINE>excellent stomach.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>And a good soldier too, lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>And a good soldier to a lady: but what is he to a lord?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>A lord to a lord, a man to a man; stuffed with all</LINE>
-<LINE>honourable virtues.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>It is so, indeed; he is no less than a stuffed man:</LINE>
-<LINE>but for the stuffing,--well, we are all mortal.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>You must not, sir, mistake my niece. There is a</LINE>
-<LINE>kind of merry war betwixt Signior Benedick and her:</LINE>
-<LINE>they never meet but there's a skirmish of wit</LINE>
-<LINE>between them.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Alas! he gets nothing by that. In our last</LINE>
-<LINE>conflict four of his five wits went halting off, and</LINE>
-<LINE>now is the whole man governed with one: so that if</LINE>
-<LINE>he have wit enough to keep himself warm, let him</LINE>
-<LINE>bear it for a difference between himself and his</LINE>
-<LINE>horse; for it is all the wealth that he hath left,</LINE>
-<LINE>to be known a reasonable creature. Who is his</LINE>
-<LINE>companion now? He hath every month a new sworn brother.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>Is't possible?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Very easily possible: he wears his faith but as</LINE>
-<LINE>the fashion of his hat; it ever changes with the</LINE>
-<LINE>next block.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>I see, lady, the gentleman is not in your books.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No; an he were, I would burn my study. But, I pray</LINE>
-<LINE>you, who is his companion? Is there no young</LINE>
-<LINE>squarer now that will make a voyage with him to the devil?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>He is most in the company of the right noble Claudio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>O Lord, he will hang upon him like a disease: he</LINE>
-<LINE>is sooner caught than the pestilence, and the taker</LINE>
-<LINE>runs presently mad. God help the noble Claudio! if</LINE>
-<LINE>he have caught the Benedick, it will cost him a</LINE>
-<LINE>thousand pound ere a' be cured.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>I will hold friends with you, lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Do, good friend.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>You will never run mad, niece.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No, not till a hot January.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>Don Pedro is approached.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter DON PEDRO, DON JOHN, CLAUDIO, BENEDICK,
-and BALTHASAR</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Good Signior Leonato, you are come to meet your</LINE>
-<LINE>trouble: the fashion of the world is to avoid</LINE>
-<LINE>cost, and you encounter it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Never came trouble to my house in the likeness of</LINE>
-<LINE>your grace: for trouble being gone, comfort should</LINE>
-<LINE>remain; but when you depart from me, sorrow abides</LINE>
-<LINE>and happiness takes his leave.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>You embrace your charge too willingly. I think this</LINE>
-<LINE>is your daughter.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Her mother hath many times told me so.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Were you in doubt, sir, that you asked her?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Signior Benedick, no; for then were you a child.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>You have it full, Benedick: we may guess by this</LINE>
-<LINE>what you are, being a man. Truly, the lady fathers</LINE>
-<LINE>herself. Be happy, lady; for you are like an</LINE>
-<LINE>honourable father.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>If Signior Leonato be her father, she would not</LINE>
-<LINE>have his head on her shoulders for all Messina, as</LINE>
-<LINE>like him as she is.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I wonder that you will still be talking, Signior</LINE>
-<LINE>Benedick: nobody marks you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>What, my dear Lady Disdain! are you yet living?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Is it possible disdain should die while she hath</LINE>
-<LINE>such meet food to feed it as Signior Benedick?</LINE>
-<LINE>Courtesy itself must convert to disdain, if you come</LINE>
-<LINE>in her presence.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Then is courtesy a turncoat. But it is certain I</LINE>
-<LINE>am loved of all ladies, only you excepted: and I</LINE>
-<LINE>would I could find in my heart that I had not a hard</LINE>
-<LINE>heart; for, truly, I love none.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>A dear happiness to women: they would else have</LINE>
-<LINE>been troubled with a pernicious suitor. I thank God</LINE>
-<LINE>and my cold blood, I am of your humour for that: I</LINE>
-<LINE>had rather hear my dog bark at a crow than a man</LINE>
-<LINE>swear he loves me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>God keep your ladyship still in that mind! so some</LINE>
-<LINE>gentleman or other shall 'scape a predestinate</LINE>
-<LINE>scratched face.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Scratching could not make it worse, an 'twere such</LINE>
-<LINE>a face as yours were.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Well, you are a rare parrot-teacher.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>A bird of my tongue is better than a beast of yours.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I would my horse had the speed of your tongue, and</LINE>
-<LINE>so good a continuer. But keep your way, i' God's</LINE>
-<LINE>name; I have done.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You always end with a jade's trick: I know you of old.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>That is the sum of all, Leonato. Signior Claudio</LINE>
-<LINE>and Signior Benedick, my dear friend Leonato hath</LINE>
-<LINE>invited you all. I tell him we shall stay here at</LINE>
-<LINE>the least a month; and he heartily prays some</LINE>
-<LINE>occasion may detain us longer. I dare swear he is no</LINE>
-<LINE>hypocrite, but prays from his heart.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>If you swear, my lord, you shall not be forsworn.</LINE>
-<STAGEDIR>To DON JOHN</STAGEDIR>
-<LINE>Let me bid you welcome, my lord: being reconciled to</LINE>
-<LINE>the prince your brother, I owe you all duty.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I thank you: I am not of many words, but I thank</LINE>
-<LINE>you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Please it your grace lead on?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Your hand, Leonato; we will go together.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt all except BENEDICK and CLAUDIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Benedick, didst thou note the daughter of Signior Leonato?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I noted her not; but I looked on her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Is she not a modest young lady?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Do you question me, as an honest man should do, for</LINE>
-<LINE>my simple true judgment; or would you have me speak</LINE>
-<LINE>after my custom, as being a professed tyrant to their sex?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>No; I pray thee speak in sober judgment.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Why, i' faith, methinks she's too low for a high</LINE>
-<LINE>praise, too brown for a fair praise and too little</LINE>
-<LINE>for a great praise: only this commendation I can</LINE>
-<LINE>afford her, that were she other than she is, she</LINE>
-<LINE>were unhandsome; and being no other but as she is, I</LINE>
-<LINE>do not like her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Thou thinkest I am in sport: I pray thee tell me</LINE>
-<LINE>truly how thou likest her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Would you buy her, that you inquire after her?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Can the world buy such a jewel?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Yea, and a case to put it into. But speak you this</LINE>
-<LINE>with a sad brow? or do you play the flouting Jack,</LINE>
-<LINE>to tell us Cupid is a good hare-finder and Vulcan a</LINE>
-<LINE>rare carpenter? Come, in what key shall a man take</LINE>
-<LINE>you, to go in the song?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>In mine eye she is the sweetest lady that ever I</LINE>
-<LINE>looked on.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I can see yet without spectacles and I see no such</LINE>
-<LINE>matter: there's her cousin, an she were not</LINE>
-<LINE>possessed with a fury, exceeds her as much in beauty</LINE>
-<LINE>as the first of May doth the last of December. But I</LINE>
-<LINE>hope you have no intent to turn husband, have you?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I would scarce trust myself, though I had sworn the</LINE>
-<LINE>contrary, if Hero would be my wife.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Is't come to this? In faith, hath not the world</LINE>
-<LINE>one man but he will wear his cap with suspicion?</LINE>
-<LINE>Shall I never see a bachelor of three-score again?</LINE>
-<LINE>Go to, i' faith; an thou wilt needs thrust thy neck</LINE>
-<LINE>into a yoke, wear the print of it and sigh away</LINE>
-<LINE>Sundays. Look Don Pedro is returned to seek you.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Re-enter DON PEDRO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>What secret hath held you here, that you followed</LINE>
-<LINE>not to Leonato's?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I would your grace would constrain me to tell.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I charge thee on thy allegiance.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>You hear, Count Claudio: I can be secret as a dumb</LINE>
-<LINE>man; I would have you think so; but, on my</LINE>
-<LINE>allegiance, mark you this, on my allegiance. He is</LINE>
-<LINE>in love. With who? now that is your grace's part.</LINE>
-<LINE>Mark how short his answer is;--With Hero, Leonato's</LINE>
-<LINE>short daughter.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If this were so, so were it uttered.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Like the old tale, my lord: 'it is not so, nor</LINE>
-<LINE>'twas not so, but, indeed, God forbid it should be</LINE>
-<LINE>so.'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If my passion change not shortly, God forbid it</LINE>
-<LINE>should be otherwise.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Amen, if you love her; for the lady is very well worthy.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>You speak this to fetch me in, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>By my troth, I speak my thought.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And, in faith, my lord, I spoke mine.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>And, by my two faiths and troths, my lord, I spoke mine.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>That I love her, I feel.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>That she is worthy, I know.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>That I neither feel how she should be loved nor</LINE>
-<LINE>know how she should be worthy, is the opinion that</LINE>
-<LINE>fire cannot melt out of me: I will die in it at the stake.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Thou wast ever an obstinate heretic in the despite</LINE>
-<LINE>of beauty.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And never could maintain his part but in the force</LINE>
-<LINE>of his will.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>That a woman conceived me, I thank her; that she</LINE>
-<LINE>brought me up, I likewise give her most humble</LINE>
-<LINE>thanks: but that I will have a recheat winded in my</LINE>
-<LINE>forehead, or hang my bugle in an invisible baldrick,</LINE>
-<LINE>all women shall pardon me. Because I will not do</LINE>
-<LINE>them the wrong to mistrust any, I will do myself the</LINE>
-<LINE>right to trust none; and the fine is, for the which</LINE>
-<LINE>I may go the finer, I will live a bachelor.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I shall see thee, ere I die, look pale with love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>With anger, with sickness, or with hunger, my lord,</LINE>
-<LINE>not with love: prove that ever I lose more blood</LINE>
-<LINE>with love than I will get again with drinking, pick</LINE>
-<LINE>out mine eyes with a ballad-maker's pen and hang me</LINE>
-<LINE>up at the door of a brothel-house for the sign of</LINE>
-<LINE>blind Cupid.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Well, if ever thou dost fall from this faith, thou</LINE>
-<LINE>wilt prove a notable argument.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>If I do, hang me in a bottle like a cat and shoot</LINE>
-<LINE>at me; and he that hits me, let him be clapped on</LINE>
-<LINE>the shoulder, and called Adam.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Well, as time shall try: 'In time the savage bull</LINE>
-<LINE>doth bear the yoke.'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>The savage bull may; but if ever the sensible</LINE>
-<LINE>Benedick bear it, pluck off the bull's horns and set</LINE>
-<LINE>them in my forehead: and let me be vilely painted,</LINE>
-<LINE>and in such great letters as they write 'Here is</LINE>
-<LINE>good horse to hire,' let them signify under my sign</LINE>
-<LINE>'Here you may see Benedick the married man.'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If this should ever happen, thou wouldst be horn-mad.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Nay, if Cupid have not spent all his quiver in</LINE>
-<LINE>Venice, thou wilt quake for this shortly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I look for an earthquake too, then.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Well, you temporize with the hours. In the</LINE>
-<LINE>meantime, good Signior Benedick, repair to</LINE>
-<LINE>Leonato's: commend me to him and tell him I will</LINE>
-<LINE>not fail him at supper; for indeed he hath made</LINE>
-<LINE>great preparation.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I have almost matter enough in me for such an</LINE>
-<LINE>embassage; and so I commit you--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>To the tuition of God: From my house, if I had it,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>The sixth of July: Your loving friend, Benedick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Nay, mock not, mock not. The body of your</LINE>
-<LINE>discourse is sometime guarded with fragments, and</LINE>
-<LINE>the guards are but slightly basted on neither: ere</LINE>
-<LINE>you flout old ends any further, examine your</LINE>
-<LINE>conscience: and so I leave you.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>My liege, your highness now may do me good.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>My love is thine to teach: teach it but how,</LINE>
-<LINE>And thou shalt see how apt it is to learn</LINE>
-<LINE>Any hard lesson that may do thee good.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Hath Leonato any son, my lord?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>No child but Hero; she's his only heir.</LINE>
-<LINE>Dost thou affect her, Claudio?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O, my lord,</LINE>
-<LINE>When you went onward on this ended action,</LINE>
-<LINE>I look'd upon her with a soldier's eye,</LINE>
-<LINE>That liked, but had a rougher task in hand</LINE>
-<LINE>Than to drive liking to the name of love:</LINE>
-<LINE>But now I am return'd and that war-thoughts</LINE>
-<LINE>Have left their places vacant, in their rooms</LINE>
-<LINE>Come thronging soft and delicate desires,</LINE>
-<LINE>All prompting me how fair young Hero is,</LINE>
-<LINE>Saying, I liked her ere I went to wars.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Thou wilt be like a lover presently</LINE>
-<LINE>And tire the hearer with a book of words.</LINE>
-<LINE>If thou dost love fair Hero, cherish it,</LINE>
-<LINE>And I will break with her and with her father,</LINE>
-<LINE>And thou shalt have her. Was't not to this end</LINE>
-<LINE>That thou began'st to twist so fine a story?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>How sweetly you do minister to love,</LINE>
-<LINE>That know love's grief by his complexion!</LINE>
-<LINE>But lest my liking might too sudden seem,</LINE>
-<LINE>I would have salved it with a longer treatise.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>What need the bridge much broader than the flood?</LINE>
-<LINE>The fairest grant is the necessity.</LINE>
-<LINE>Look, what will serve is fit: 'tis once, thou lovest,</LINE>
-<LINE>And I will fit thee with the remedy.</LINE>
-<LINE>I know we shall have revelling to-night:</LINE>
-<LINE>I will assume thy part in some disguise</LINE>
-<LINE>And tell fair Hero I am Claudio,</LINE>
-<LINE>And in her bosom I'll unclasp my heart</LINE>
-<LINE>And take her hearing prisoner with the force</LINE>
-<LINE>And strong encounter of my amorous tale:</LINE>
-<LINE>Then after to her father will I break;</LINE>
-<LINE>And the conclusion is, she shall be thine.</LINE>
-<LINE>In practise let us put it presently.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE II. A room in LEONATO's house.</TITLE>
-<STAGEDIR>Enter LEONATO and ANTONIO, meeting</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>How now, brother! Where is my cousin, your son?</LINE>
-<LINE>hath he provided this music?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>He is very busy about it. But, brother, I can tell</LINE>
-<LINE>you strange news that you yet dreamt not of.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Are they good?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>As the event stamps them: but they have a good</LINE>
-<LINE>cover; they show well outward. The prince and Count</LINE>
-<LINE>Claudio, walking in a thick-pleached alley in mine</LINE>
-<LINE>orchard, were thus much overheard by a man of mine:</LINE>
-<LINE>the prince discovered to Claudio that he loved my</LINE>
-<LINE>niece your daughter and meant to acknowledge it</LINE>
-<LINE>this night in a dance: and if he found her</LINE>
-<LINE>accordant, he meant to take the present time by the</LINE>
-<LINE>top and instantly break with you of it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Hath the fellow any wit that told you this?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>A good sharp fellow: I will send for him; and</LINE>
-<LINE>question him yourself.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>No, no; we will hold it as a dream till it appear</LINE>
-<LINE>itself: but I will acquaint my daughter withal,</LINE>
-<LINE>that she may be the better prepared for an answer,</LINE>
-<LINE>if peradventure this be true. Go you and tell her of it.</LINE>
-<STAGEDIR>Enter Attendants</STAGEDIR>
-<LINE>Cousins, you know what you have to do. O, I cry you</LINE>
-<LINE>mercy, friend; go you with me, and I will use your</LINE>
-<LINE>skill. Good cousin, have a care this busy time.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE III. The same.</TITLE>
-<STAGEDIR>Enter DON JOHN and CONRADE</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>What the good-year, my lord! why are you thus out</LINE>
-<LINE>of measure sad?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>There is no measure in the occasion that breeds;</LINE>
-<LINE>therefore the sadness is without limit.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>You should hear reason.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>And when I have heard it, what blessing brings it?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>If not a present remedy, at least a patient</LINE>
-<LINE>sufferance.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I wonder that thou, being, as thou sayest thou art,</LINE>
-<LINE>born under Saturn, goest about to apply a moral</LINE>
-<LINE>medicine to a mortifying mischief. I cannot hide</LINE>
-<LINE>what I am: I must be sad when I have cause and smile</LINE>
-<LINE>at no man's jests, eat when I have stomach and wait</LINE>
-<LINE>for no man's leisure, sleep when I am drowsy and</LINE>
-<LINE>tend on no man's business, laugh when I am merry and</LINE>
-<LINE>claw no man in his humour.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Yea, but you must not make the full show of this</LINE>
-<LINE>till you may do it without controlment. You have of</LINE>
-<LINE>late stood out against your brother, and he hath</LINE>
-<LINE>ta'en you newly into his grace; where it is</LINE>
-<LINE>impossible you should take true root but by the</LINE>
-<LINE>fair weather that you make yourself: it is needful</LINE>
-<LINE>that you frame the season for your own harvest.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I had rather be a canker in a hedge than a rose in</LINE>
-<LINE>his grace, and it better fits my blood to be</LINE>
-<LINE>disdained of all than to fashion a carriage to rob</LINE>
-<LINE>love from any: in this, though I cannot be said to</LINE>
-<LINE>be a flattering honest man, it must not be denied</LINE>
-<LINE>but I am a plain-dealing villain. I am trusted with</LINE>
-<LINE>a muzzle and enfranchised with a clog; therefore I</LINE>
-<LINE>have decreed not to sing in my cage. If I had my</LINE>
-<LINE>mouth, I would bite; if I had my liberty, I would do</LINE>
-<LINE>my liking: in the meantime let me be that I am and</LINE>
-<LINE>seek not to alter me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Can you make no use of your discontent?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I make all use of it, for I use it only.</LINE>
-<LINE>Who comes here?</LINE>
-<STAGEDIR>Enter BORACHIO</STAGEDIR>
-<LINE>What news, Borachio?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>I came yonder from a great supper: the prince your</LINE>
-<LINE>brother is royally entertained by Leonato: and I</LINE>
-<LINE>can give you intelligence of an intended marriage.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Will it serve for any model to build mischief on?</LINE>
-<LINE>What is he for a fool that betroths himself to</LINE>
-<LINE>unquietness?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Marry, it is your brother's right hand.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Who? the most exquisite Claudio?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Even he.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>A proper squire! And who, and who? which way looks</LINE>
-<LINE>he?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Marry, on Hero, the daughter and heir of Leonato.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>A very forward March-chick! How came you to this?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Being entertained for a perfumer, as I was smoking a</LINE>
-<LINE>musty room, comes me the prince and Claudio, hand</LINE>
-<LINE>in hand in sad conference: I whipt me behind the</LINE>
-<LINE>arras; and there heard it agreed upon that the</LINE>
-<LINE>prince should woo Hero for himself, and having</LINE>
-<LINE>obtained her, give her to Count Claudio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Come, come, let us thither: this may prove food to</LINE>
-<LINE>my displeasure. That young start-up hath all the</LINE>
-<LINE>glory of my overthrow: if I can cross him any way, I</LINE>
-<LINE>bless myself every way. You are both sure, and will assist me?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>To the death, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Let us to the great supper: their cheer is the</LINE>
-<LINE>greater that I am subdued. Would the cook were of</LINE>
-<LINE>my mind! Shall we go prove what's to be done?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>We'll wait upon your lordship.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-</ACT>
-
-<ACT><TITLE>ACT II</TITLE>
-
-<SCENE><TITLE>SCENE I. A hall in LEONATO'S house.</TITLE>
-<STAGEDIR>Enter LEONATO, ANTONIO, HERO, BEATRICE, and others</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Was not Count John here at supper?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>I saw him not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>How tartly that gentleman looks! I never can see</LINE>
-<LINE>him but I am heart-burned an hour after.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>He is of a very melancholy disposition.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>He were an excellent man that were made just in the</LINE>
-<LINE>midway between him and Benedick: the one is too</LINE>
-<LINE>like an image and says nothing, and the other too</LINE>
-<LINE>like my lady's eldest son, evermore tattling.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Then half Signior Benedick's tongue in Count John's</LINE>
-<LINE>mouth, and half Count John's melancholy in Signior</LINE>
-<LINE>Benedick's face,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>With a good leg and a good foot, uncle, and money</LINE>
-<LINE>enough in his purse, such a man would win any woman</LINE>
-<LINE>in the world, if a' could get her good-will.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>By my troth, niece, thou wilt never get thee a</LINE>
-<LINE>husband, if thou be so shrewd of thy tongue.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>In faith, she's too curst.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Too curst is more than curst: I shall lessen God's</LINE>
-<LINE>sending that way; for it is said, 'God sends a curst</LINE>
-<LINE>cow short horns;' but to a cow too curst he sends none.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>So, by being too curst, God will send you no horns.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Just, if he send me no husband; for the which</LINE>
-<LINE>blessing I am at him upon my knees every morning and</LINE>
-<LINE>evening. Lord, I could not endure a husband with a</LINE>
-<LINE>beard on his face: I had rather lie in the woollen.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>You may light on a husband that hath no beard.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>What should I do with him? dress him in my apparel</LINE>
-<LINE>and make him my waiting-gentlewoman? He that hath a</LINE>
-<LINE>beard is more than a youth, and he that hath no</LINE>
-<LINE>beard is less than a man: and he that is more than</LINE>
-<LINE>a youth is not for me, and he that is less than a</LINE>
-<LINE>man, I am not for him: therefore, I will even take</LINE>
-<LINE>sixpence in earnest of the bear-ward, and lead his</LINE>
-<LINE>apes into hell.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Well, then, go you into hell?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No, but to the gate; and there will the devil meet</LINE>
-<LINE>me, like an old cuckold, with horns on his head, and</LINE>
-<LINE>say 'Get you to heaven, Beatrice, get you to</LINE>
-<LINE>heaven; here's no place for you maids:' so deliver</LINE>
-<LINE>I up my apes, and away to Saint Peter for the</LINE>
-<LINE>heavens; he shows me where the bachelors sit, and</LINE>
-<LINE>there live we as merry as the day is long.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE><STAGEDIR>To HERO</STAGEDIR> Well, niece, I trust you will be ruled</LINE>
-<LINE>by your father.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Yes, faith; it is my cousin's duty to make curtsy</LINE>
-<LINE>and say 'Father, as it please you.' But yet for all</LINE>
-<LINE>that, cousin, let him be a handsome fellow, or else</LINE>
-<LINE>make another curtsy and say 'Father, as it please</LINE>
-<LINE>me.'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Well, niece, I hope to see you one day fitted with a husband.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Not till God make men of some other metal than</LINE>
-<LINE>earth. Would it not grieve a woman to be</LINE>
-<LINE>overmastered with a pierce of valiant dust? to make</LINE>
-<LINE>an account of her life to a clod of wayward marl?</LINE>
-<LINE>No, uncle, I'll none: Adam's sons are my brethren;</LINE>
-<LINE>and, truly, I hold it a sin to match in my kindred.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Daughter, remember what I told you: if the prince</LINE>
-<LINE>do solicit you in that kind, you know your answer.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>The fault will be in the music, cousin, if you be</LINE>
-<LINE>not wooed in good time: if the prince be too</LINE>
-<LINE>important, tell him there is measure in every thing</LINE>
-<LINE>and so dance out the answer. For, hear me, Hero:</LINE>
-<LINE>wooing, wedding, and repenting, is as a Scotch jig,</LINE>
-<LINE>a measure, and a cinque pace: the first suit is hot</LINE>
-<LINE>and hasty, like a Scotch jig, and full as</LINE>
-<LINE>fantastical; the wedding, mannerly-modest, as a</LINE>
-<LINE>measure, full of state and ancientry; and then comes</LINE>
-<LINE>repentance and, with his bad legs, falls into the</LINE>
-<LINE>cinque pace faster and faster, till he sink into his grave.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Cousin, you apprehend passing shrewdly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I have a good eye, uncle; I can see a church by daylight.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>The revellers are entering, brother: make good room.</LINE>
-</SPEECH>
-
-<STAGEDIR>All put on their masks</STAGEDIR>
-<STAGEDIR>Enter DON PEDRO, CLAUDIO, BENEDICK, BALTHASAR,
-DON JOHN, BORACHIO, MARGARET, URSULA and others, masked</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Lady, will you walk about with your friend?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>So you walk softly and look sweetly and say nothing,</LINE>
-<LINE>I am yours for the walk; and especially when I walk away.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>With me in your company?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>I may say so, when I please.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>And when please you to say so?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>When I like your favour; for God defend the lute</LINE>
-<LINE>should be like the case!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>My visor is Philemon's roof; within the house is Jove.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Why, then, your visor should be thatched.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Speak low, if you speak love.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Drawing her aside</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Well, I would you did like me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>So would not I, for your own sake; for I have many</LINE>
-<LINE>ill-qualities.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Which is one?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>I say my prayers aloud.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>I love you the better: the hearers may cry, Amen.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>God match me with a good dancer!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Amen.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>And God keep him out of my sight when the dance is</LINE>
-<LINE>done! Answer, clerk.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>No more words: the clerk is answered.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>I know you well enough; you are Signior Antonio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>At a word, I am not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>I know you by the waggling of your head.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>To tell you true, I counterfeit him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>You could never do him so ill-well, unless you were</LINE>
-<LINE>the very man. Here's his dry hand up and down: you</LINE>
-<LINE>are he, you are he.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>ANTONIO</SPEAKER>
-<LINE>At a word, I am not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Come, come, do you think I do not know you by your</LINE>
-<LINE>excellent wit? can virtue hide itself? Go to,</LINE>
-<LINE>mum, you are he: graces will appear, and there's an</LINE>
-<LINE>end.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Will you not tell me who told you so?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>No, you shall pardon me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Nor will you not tell me who you are?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Not now.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>That I was disdainful, and that I had my good wit</LINE>
-<LINE>out of the 'Hundred Merry Tales:'--well this was</LINE>
-<LINE>Signior Benedick that said so.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>What's he?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I am sure you know him well enough.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Not I, believe me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Did he never make you laugh?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I pray you, what is he?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Why, he is the prince's jester: a very dull fool;</LINE>
-<LINE>only his gift is in devising impossible slanders:</LINE>
-<LINE>none but libertines delight in him; and the</LINE>
-<LINE>commendation is not in his wit, but in his villany;</LINE>
-<LINE>for he both pleases men and angers them, and then</LINE>
-<LINE>they laugh at him and beat him. I am sure he is in</LINE>
-<LINE>the fleet: I would he had boarded me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>When I know the gentleman, I'll tell him what you say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Do, do: he'll but break a comparison or two on me;</LINE>
-<LINE>which, peradventure not marked or not laughed at,</LINE>
-<LINE>strikes him into melancholy; and then there's a</LINE>
-<LINE>partridge wing saved, for the fool will eat no</LINE>
-<LINE>supper that night.</LINE>
-<STAGEDIR>Music</STAGEDIR>
-<LINE>We must follow the leaders.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>In every good thing.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Nay, if they lead to any ill, I will leave them at</LINE>
-<LINE>the next turning.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Dance. Then exeunt all except DON JOHN, BORACHIO,
-and CLAUDIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Sure my brother is amorous on Hero and hath</LINE>
-<LINE>withdrawn her father to break with him about it.</LINE>
-<LINE>The ladies follow her and but one visor remains.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>And that is Claudio: I know him by his bearing.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Are not you Signior Benedick?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>You know me well; I am he.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Signior, you are very near my brother in his love:</LINE>
-<LINE>he is enamoured on Hero; I pray you, dissuade him</LINE>
-<LINE>from her: she is no equal for his birth: you may</LINE>
-<LINE>do the part of an honest man in it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>How know you he loves her?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I heard him swear his affection.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>So did I too; and he swore he would marry her to-night.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Come, let us to the banquet.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt DON JOHN and BORACHIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Thus answer I in the name of Benedick,</LINE>
-<LINE>But hear these ill news with the ears of Claudio.</LINE>
-<LINE>'Tis certain so; the prince wooes for himself.</LINE>
-<LINE>Friendship is constant in all other things</LINE>
-<LINE>Save in the office and affairs of love:</LINE>
-<LINE>Therefore, all hearts in love use their own tongues;</LINE>
-<LINE>Let every eye negotiate for itself</LINE>
-<LINE>And trust no agent; for beauty is a witch</LINE>
-<LINE>Against whose charms faith melteth into blood.</LINE>
-<LINE>This is an accident of hourly proof,</LINE>
-<LINE>Which I mistrusted not. Farewell, therefore, Hero!</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Re-enter BENEDICK</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Count Claudio?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Yea, the same.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Come, will you go with me?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Whither?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Even to the next willow, about your own business,</LINE>
-<LINE>county. What fashion will you wear the garland of?</LINE>
-<LINE>about your neck, like an usurer's chain? or under</LINE>
-<LINE>your arm, like a lieutenant's scarf? You must wear</LINE>
-<LINE>it one way, for the prince hath got your Hero.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I wish him joy of her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Why, that's spoken like an honest drovier: so they</LINE>
-<LINE>sell bullocks. But did you think the prince would</LINE>
-<LINE>have served you thus?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I pray you, leave me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Ho! now you strike like the blind man: 'twas the</LINE>
-<LINE>boy that stole your meat, and you'll beat the post.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If it will not be, I'll leave you.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Alas, poor hurt fowl! now will he creep into sedges.</LINE>
-<LINE>But that my Lady Beatrice should know me, and not</LINE>
-<LINE>know me! The prince's fool! Ha? It may be I go</LINE>
-<LINE>under that title because I am merry. Yea, but so I</LINE>
-<LINE>am apt to do myself wrong; I am not so reputed: it</LINE>
-<LINE>is the base, though bitter, disposition of Beatrice</LINE>
-<LINE>that puts the world into her person and so gives me</LINE>
-<LINE>out. Well, I'll be revenged as I may.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Re-enter DON PEDRO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Now, signior, where's the count? did you see him?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Troth, my lord, I have played the part of Lady Fame.</LINE>
-<LINE>I found him here as melancholy as a lodge in a</LINE>
-<LINE>warren: I told him, and I think I told him true,</LINE>
-<LINE>that your grace had got the good will of this young</LINE>
-<LINE>lady; and I offered him my company to a willow-tree,</LINE>
-<LINE>either to make him a garland, as being forsaken, or</LINE>
-<LINE>to bind him up a rod, as being worthy to be whipped.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>To be whipped! What's his fault?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>The flat transgression of a schoolboy, who, being</LINE>
-<LINE>overjoyed with finding a birds' nest, shows it his</LINE>
-<LINE>companion, and he steals it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Wilt thou make a trust a transgression? The</LINE>
-<LINE>transgression is in the stealer.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Yet it had not been amiss the rod had been made,</LINE>
-<LINE>and the garland too; for the garland he might have</LINE>
-<LINE>worn himself, and the rod he might have bestowed on</LINE>
-<LINE>you, who, as I take it, have stolen his birds' nest.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I will but teach them to sing, and restore them to</LINE>
-<LINE>the owner.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>If their singing answer your saying, by my faith,</LINE>
-<LINE>you say honestly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>The Lady Beatrice hath a quarrel to you: the</LINE>
-<LINE>gentleman that danced with her told her she is much</LINE>
-<LINE>wronged by you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>O, she misused me past the endurance of a block!</LINE>
-<LINE>an oak but with one green leaf on it would have</LINE>
-<LINE>answered her; my very visor began to assume life and</LINE>
-<LINE>scold with her. She told me, not thinking I had been</LINE>
-<LINE>myself, that I was the prince's jester, that I was</LINE>
-<LINE>duller than a great thaw; huddling jest upon jest</LINE>
-<LINE>with such impossible conveyance upon me that I stood</LINE>
-<LINE>like a man at a mark, with a whole army shooting at</LINE>
-<LINE>me. She speaks poniards, and every word stabs:</LINE>
-<LINE>if her breath were as terrible as her terminations,</LINE>
-<LINE>there were no living near her; she would infect to</LINE>
-<LINE>the north star. I would not marry her, though she</LINE>
-<LINE>were endowed with all that Adam bad left him before</LINE>
-<LINE>he transgressed: she would have made Hercules have</LINE>
-<LINE>turned spit, yea, and have cleft his club to make</LINE>
-<LINE>the fire too. Come, talk not of her: you shall find</LINE>
-<LINE>her the infernal Ate in good apparel. I would to God</LINE>
-<LINE>some scholar would conjure her; for certainly, while</LINE>
-<LINE>she is here, a man may live as quiet in hell as in a</LINE>
-<LINE>sanctuary; and people sin upon purpose, because they</LINE>
-<LINE>would go thither; so, indeed, all disquiet, horror</LINE>
-<LINE>and perturbation follows her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Look, here she comes.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter CLAUDIO, BEATRICE, HERO, and LEONATO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Will your grace command me any service to the</LINE>
-<LINE>world's end? I will go on the slightest errand now</LINE>
-<LINE>to the Antipodes that you can devise to send me on;</LINE>
-<LINE>I will fetch you a tooth-picker now from the</LINE>
-<LINE>furthest inch of Asia, bring you the length of</LINE>
-<LINE>Prester John's foot, fetch you a hair off the great</LINE>
-<LINE>Cham's beard, do you any embassage to the Pigmies,</LINE>
-<LINE>rather than hold three words' conference with this</LINE>
-<LINE>harpy. You have no employment for me?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>None, but to desire your good company.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>O God, sir, here's a dish I love not: I cannot</LINE>
-<LINE>endure my Lady Tongue.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Come, lady, come; you have lost the heart of</LINE>
-<LINE>Signior Benedick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Indeed, my lord, he lent it me awhile; and I gave</LINE>
-<LINE>him use for it, a double heart for his single one:</LINE>
-<LINE>marry, once before he won it of me with false dice,</LINE>
-<LINE>therefore your grace may well say I have lost it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>You have put him down, lady, you have put him down.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>So I would not he should do me, my lord, lest I</LINE>
-<LINE>should prove the mother of fools. I have brought</LINE>
-<LINE>Count Claudio, whom you sent me to seek.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Why, how now, count! wherefore are you sad?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Not sad, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>How then? sick?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Neither, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>The count is neither sad, nor sick, nor merry, nor</LINE>
-<LINE>well; but civil count, civil as an orange, and</LINE>
-<LINE>something of that jealous complexion.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I' faith, lady, I think your blazon to be true;</LINE>
-<LINE>though, I'll be sworn, if he be so, his conceit is</LINE>
-<LINE>false. Here, Claudio, I have wooed in thy name, and</LINE>
-<LINE>fair Hero is won: I have broke with her father,</LINE>
-<LINE>and his good will obtained: name the day of</LINE>
-<LINE>marriage, and God give thee joy!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Count, take of me my daughter, and with her my</LINE>
-<LINE>fortunes: his grace hath made the match, and an</LINE>
-<LINE>grace say Amen to it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Speak, count, 'tis your cue.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Silence is the perfectest herald of joy: I were</LINE>
-<LINE>but little happy, if I could say how much. Lady, as</LINE>
-<LINE>you are mine, I am yours: I give away myself for</LINE>
-<LINE>you and dote upon the exchange.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Speak, cousin; or, if you cannot, stop his mouth</LINE>
-<LINE>with a kiss, and let not him speak neither.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>In faith, lady, you have a merry heart.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Yea, my lord; I thank it, poor fool, it keeps on</LINE>
-<LINE>the windy side of care. My cousin tells him in his</LINE>
-<LINE>ear that he is in her heart.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And so she doth, cousin.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Good Lord, for alliance! Thus goes every one to the</LINE>
-<LINE>world but I, and I am sunburnt; I may sit in a</LINE>
-<LINE>corner and cry heigh-ho for a husband!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Lady Beatrice, I will get you one.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I would rather have one of your father's getting.</LINE>
-<LINE>Hath your grace ne'er a brother like you? Your</LINE>
-<LINE>father got excellent husbands, if a maid could come by them.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Will you have me, lady?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No, my lord, unless I might have another for</LINE>
-<LINE>working-days: your grace is too costly to wear</LINE>
-<LINE>every day. But, I beseech your grace, pardon me: I</LINE>
-<LINE>was born to speak all mirth and no matter.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Your silence most offends me, and to be merry best</LINE>
-<LINE>becomes you; for, out of question, you were born in</LINE>
-<LINE>a merry hour.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No, sure, my lord, my mother cried; but then there</LINE>
-<LINE>was a star danced, and under that was I born.</LINE>
-<LINE>Cousins, God give you joy!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Niece, will you look to those things I told you of?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I cry you mercy, uncle. By your grace's pardon.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>By my troth, a pleasant-spirited lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>There's little of the melancholy element in her, my</LINE>
-<LINE>lord: she is never sad but when she sleeps, and</LINE>
-<LINE>not ever sad then; for I have heard my daughter say,</LINE>
-<LINE>she hath often dreamed of unhappiness and waked</LINE>
-<LINE>herself with laughing.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>She cannot endure to hear tell of a husband.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O, by no means: she mocks all her wooers out of suit.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>She were an excellent wife for Benedict.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O Lord, my lord, if they were but a week married,</LINE>
-<LINE>they would talk themselves mad.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>County Claudio, when mean you to go to church?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>To-morrow, my lord: time goes on crutches till love</LINE>
-<LINE>have all his rites.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Not till Monday, my dear son, which is hence a just</LINE>
-<LINE>seven-night; and a time too brief, too, to have all</LINE>
-<LINE>things answer my mind.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Come, you shake the head at so long a breathing:</LINE>
-<LINE>but, I warrant thee, Claudio, the time shall not go</LINE>
-<LINE>dully by us. I will in the interim undertake one of</LINE>
-<LINE>Hercules' labours; which is, to bring Signior</LINE>
-<LINE>Benedick and the Lady Beatrice into a mountain of</LINE>
-<LINE>affection the one with the other. I would fain have</LINE>
-<LINE>it a match, and I doubt not but to fashion it, if</LINE>
-<LINE>you three will but minister such assistance as I</LINE>
-<LINE>shall give you direction.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>My lord, I am for you, though it cost me ten</LINE>
-<LINE>nights' watchings.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And I, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>And you too, gentle Hero?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>I will do any modest office, my lord, to help my</LINE>
-<LINE>cousin to a good husband.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>And Benedick is not the unhopefullest husband that</LINE>
-<LINE>I know. Thus far can I praise him; he is of a noble</LINE>
-<LINE>strain, of approved valour and confirmed honesty. I</LINE>
-<LINE>will teach you how to humour your cousin, that she</LINE>
-<LINE>shall fall in love with Benedick; and I, with your</LINE>
-<LINE>two helps, will so practise on Benedick that, in</LINE>
-<LINE>despite of his quick wit and his queasy stomach, he</LINE>
-<LINE>shall fall in love with Beatrice. If we can do this,</LINE>
-<LINE>Cupid is no longer an archer: his glory shall be</LINE>
-<LINE>ours, for we are the only love-gods. Go in with me,</LINE>
-<LINE>and I will tell you my drift.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE II. The same.</TITLE>
-<STAGEDIR>Enter DON JOHN and BORACHIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>It is so; the Count Claudio shall marry the</LINE>
-<LINE>daughter of Leonato.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Yea, my lord; but I can cross it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Any bar, any cross, any impediment will be</LINE>
-<LINE>medicinable to me: I am sick in displeasure to him,</LINE>
-<LINE>and whatsoever comes athwart his affection ranges</LINE>
-<LINE>evenly with mine. How canst thou cross this marriage?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Not honestly, my lord; but so covertly that no</LINE>
-<LINE>dishonesty shall appear in me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Show me briefly how.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>I think I told your lordship a year since, how much</LINE>
-<LINE>I am in the favour of Margaret, the waiting</LINE>
-<LINE>gentlewoman to Hero.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I remember.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>I can, at any unseasonable instant of the night,</LINE>
-<LINE>appoint her to look out at her lady's chamber window.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>What life is in that, to be the death of this marriage?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>The poison of that lies in you to temper. Go you to</LINE>
-<LINE>the prince your brother; spare not to tell him that</LINE>
-<LINE>he hath wronged his honour in marrying the renowned</LINE>
-<LINE>Claudio--whose estimation do you mightily hold</LINE>
-<LINE>up--to a contaminated stale, such a one as Hero.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>What proof shall I make of that?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Proof enough to misuse the prince, to vex Claudio,</LINE>
-<LINE>to undo Hero and kill Leonato. Look you for any</LINE>
-<LINE>other issue?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Only to despite them, I will endeavour any thing.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Go, then; find me a meet hour to draw Don Pedro and</LINE>
-<LINE>the Count Claudio alone: tell them that you know</LINE>
-<LINE>that Hero loves me; intend a kind of zeal both to the</LINE>
-<LINE>prince and Claudio, as,--in love of your brother's</LINE>
-<LINE>honour, who hath made this match, and his friend's</LINE>
-<LINE>reputation, who is thus like to be cozened with the</LINE>
-<LINE>semblance of a maid,--that you have discovered</LINE>
-<LINE>thus. They will scarcely believe this without trial:</LINE>
-<LINE>offer them instances; which shall bear no less</LINE>
-<LINE>likelihood than to see me at her chamber-window,</LINE>
-<LINE>hear me call Margaret Hero, hear Margaret term me</LINE>
-<LINE>Claudio; and bring them to see this the very night</LINE>
-<LINE>before the intended wedding,--for in the meantime I</LINE>
-<LINE>will so fashion the matter that Hero shall be</LINE>
-<LINE>absent,--and there shall appear such seeming truth</LINE>
-<LINE>of Hero's disloyalty that jealousy shall be called</LINE>
-<LINE>assurance and all the preparation overthrown.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Grow this to what adverse issue it can, I will put</LINE>
-<LINE>it in practise. Be cunning in the working this, and</LINE>
-<LINE>thy fee is a thousand ducats.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Be you constant in the accusation, and my cunning</LINE>
-<LINE>shall not shame me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I will presently go learn their day of marriage.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE III. LEONATO'S orchard.</TITLE>
-<STAGEDIR>Enter BENEDICK</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Boy!</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter Boy</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>Boy</SPEAKER>
-<LINE>Signior?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>In my chamber-window lies a book: bring it hither</LINE>
-<LINE>to me in the orchard.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Boy</SPEAKER>
-<LINE>I am here already, sir.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I know that; but I would have thee hence, and here again.</LINE>
-<STAGEDIR>Exit Boy</STAGEDIR>
-<LINE>I do much wonder that one man, seeing how much</LINE>
-<LINE>another man is a fool when he dedicates his</LINE>
-<LINE>behaviors to love, will, after he hath laughed at</LINE>
-<LINE>such shallow follies in others, become the argument</LINE>
-<LINE>of his own scorn by failing in love: and such a man</LINE>
-<LINE>is Claudio. I have known when there was no music</LINE>
-<LINE>with him but the drum and the fife; and now had he</LINE>
-<LINE>rather hear the tabour and the pipe: I have known</LINE>
-<LINE>when he would have walked ten mile a-foot to see a</LINE>
-<LINE>good armour; and now will he lie ten nights awake,</LINE>
-<LINE>carving the fashion of a new doublet. He was wont to</LINE>
-<LINE>speak plain and to the purpose, like an honest man</LINE>
-<LINE>and a soldier; and now is he turned orthography; his</LINE>
-<LINE>words are a very fantastical banquet, just so many</LINE>
-<LINE>strange dishes. May I be so converted and see with</LINE>
-<LINE>these eyes? I cannot tell; I think not: I will not</LINE>
-<LINE>be sworn, but love may transform me to an oyster; but</LINE>
-<LINE>I'll take my oath on it, till he have made an oyster</LINE>
-<LINE>of me, he shall never make me such a fool. One woman</LINE>
-<LINE>is fair, yet I am well; another is wise, yet I am</LINE>
-<LINE>well; another virtuous, yet I am well; but till all</LINE>
-<LINE>graces be in one woman, one woman shall not come in</LINE>
-<LINE>my grace. Rich she shall be, that's certain; wise,</LINE>
-<LINE>or I'll none; virtuous, or I'll never cheapen her;</LINE>
-<LINE>fair, or I'll never look on her; mild, or come not</LINE>
-<LINE>near me; noble, or not I for an angel; of good</LINE>
-<LINE>discourse, an excellent musician, and her hair shall</LINE>
-<LINE>be of what colour it please God. Ha! the prince and</LINE>
-<LINE>Monsieur Love! I will hide me in the arbour.</LINE>
-</SPEECH>
-
-<STAGEDIR>Withdraws</STAGEDIR>
-<STAGEDIR>Enter DON PEDRO, CLAUDIO, and LEONATO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Come, shall we hear this music?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Yea, my good lord. How still the evening is,</LINE>
-<LINE>As hush'd on purpose to grace harmony!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>See you where Benedick hath hid himself?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O, very well, my lord: the music ended,</LINE>
-<LINE>We'll fit the kid-fox with a pennyworth.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter BALTHASAR with Music</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Come, Balthasar, we'll hear that song again.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>O, good my lord, tax not so bad a voice</LINE>
-<LINE>To slander music any more than once.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>It is the witness still of excellency</LINE>
-<LINE>To put a strange face on his own perfection.</LINE>
-<LINE>I pray thee, sing, and let me woo no more.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Because you talk of wooing, I will sing;</LINE>
-<LINE>Since many a wooer doth commence his suit</LINE>
-<LINE>To her he thinks not worthy, yet he wooes,</LINE>
-<LINE>Yet will he swear he loves.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Now, pray thee, come;</LINE>
-<LINE>Or, if thou wilt hold longer argument,</LINE>
-<LINE>Do it in notes.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Note this before my notes;</LINE>
-<LINE>There's not a note of mine that's worth the noting.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Why, these are very crotchets that he speaks;</LINE>
-<LINE>Note, notes, forsooth, and nothing.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Air</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Now, divine air! now is his soul ravished! Is it</LINE>
-<LINE>not strange that sheeps' guts should hale souls out</LINE>
-<LINE>of men's bodies? Well, a horn for my money, when</LINE>
-<LINE>all's done.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>The Song</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>Sigh no more, ladies, sigh no more,</LINE>
-<LINE>Men were deceivers ever,</LINE>
-<LINE>One foot in sea and one on shore,</LINE>
-<LINE>To one thing constant never:</LINE>
-<LINE>Then sigh not so, but let them go,</LINE>
-<LINE>And be you blithe and bonny,</LINE>
-<LINE>Converting all your sounds of woe</LINE>
-<LINE>Into Hey nonny, nonny.</LINE>
-<LINE>Sing no more ditties, sing no moe,</LINE>
-<LINE>Of dumps so dull and heavy;</LINE>
-<LINE>The fraud of men was ever so,</LINE>
-<LINE>Since summer first was leafy:</LINE>
-<LINE>Then sigh not so, &amp;c.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>By my troth, a good song.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>And an ill singer, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Ha, no, no, faith; thou singest well enough for a shift.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>An he had been a dog that should have howled thus,</LINE>
-<LINE>they would have hanged him: and I pray God his bad</LINE>
-<LINE>voice bode no mischief. I had as lief have heard the</LINE>
-<LINE>night-raven, come what plague could have come after</LINE>
-<LINE>it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Yea, marry, dost thou hear, Balthasar? I pray thee,</LINE>
-<LINE>get us some excellent music; for to-morrow night we</LINE>
-<LINE>would have it at the Lady Hero's chamber-window.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BALTHASAR</SPEAKER>
-<LINE>The best I can, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Do so: farewell.</LINE>
-<STAGEDIR>Exit BALTHASAR</STAGEDIR>
-<LINE>Come hither, Leonato. What was it you told me of</LINE>
-<LINE>to-day, that your niece Beatrice was in love with</LINE>
-<LINE>Signior Benedick?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O, ay: stalk on. stalk on; the fowl sits. I did</LINE>
-<LINE>never think that lady would have loved any man.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>No, nor I neither; but most wonderful that she</LINE>
-<LINE>should so dote on Signior Benedick, whom she hath in</LINE>
-<LINE>all outward behaviors seemed ever to abhor.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Is't possible? Sits the wind in that corner?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>By my troth, my lord, I cannot tell what to think</LINE>
-<LINE>of it but that she loves him with an enraged</LINE>
-<LINE>affection: it is past the infinite of thought.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>May be she doth but counterfeit.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Faith, like enough.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O God, counterfeit! There was never counterfeit of</LINE>
-<LINE>passion came so near the life of passion as she</LINE>
-<LINE>discovers it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Why, what effects of passion shows she?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Bait the hook well; this fish will bite.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What effects, my lord? She will sit you, you heard</LINE>
-<LINE>my daughter tell you how.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>She did, indeed.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>How, how, pray you? You amaze me: I would have I</LINE>
-<LINE>thought her spirit had been invincible against all</LINE>
-<LINE>assaults of affection.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I would have sworn it had, my lord; especially</LINE>
-<LINE>against Benedick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I should think this a gull, but that the</LINE>
-<LINE>white-bearded fellow speaks it: knavery cannot,</LINE>
-<LINE>sure, hide himself in such reverence.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>He hath ta'en the infection: hold it up.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Hath she made her affection known to Benedick?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>No; and swears she never will: that's her torment.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>'Tis true, indeed; so your daughter says: 'Shall</LINE>
-<LINE>I,' says she, 'that have so oft encountered him</LINE>
-<LINE>with scorn, write to him that I love him?'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>This says she now when she is beginning to write to</LINE>
-<LINE>him; for she'll be up twenty times a night, and</LINE>
-<LINE>there will she sit in her smock till she have writ a</LINE>
-<LINE>sheet of paper: my daughter tells us all.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Now you talk of a sheet of paper, I remember a</LINE>
-<LINE>pretty jest your daughter told us of.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O, when she had writ it and was reading it over, she</LINE>
-<LINE>found Benedick and Beatrice between the sheet?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>That.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O, she tore the letter into a thousand halfpence;</LINE>
-<LINE>railed at herself, that she should be so immodest</LINE>
-<LINE>to write to one that she knew would flout her; 'I</LINE>
-<LINE>measure him,' says she, 'by my own spirit; for I</LINE>
-<LINE>should flout him, if he writ to me; yea, though I</LINE>
-<LINE>love him, I should.'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Then down upon her knees she falls, weeps, sobs,</LINE>
-<LINE>beats her heart, tears her hair, prays, curses; 'O</LINE>
-<LINE>sweet Benedick! God give me patience!'</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>She doth indeed; my daughter says so: and the</LINE>
-<LINE>ecstasy hath so much overborne her that my daughter</LINE>
-<LINE>is sometime afeared she will do a desperate outrage</LINE>
-<LINE>to herself: it is very true.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>It were good that Benedick knew of it by some</LINE>
-<LINE>other, if she will not discover it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>To what end? He would make but a sport of it and</LINE>
-<LINE>torment the poor lady worse.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>An he should, it were an alms to hang him. She's an</LINE>
-<LINE>excellent sweet lady; and, out of all suspicion,</LINE>
-<LINE>she is virtuous.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And she is exceeding wise.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>In every thing but in loving Benedick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O, my lord, wisdom and blood combating in so tender</LINE>
-<LINE>a body, we have ten proofs to one that blood hath</LINE>
-<LINE>the victory. I am sorry for her, as I have just</LINE>
-<LINE>cause, being her uncle and her guardian.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I would she had bestowed this dotage on me: I would</LINE>
-<LINE>have daffed all other respects and made her half</LINE>
-<LINE>myself. I pray you, tell Benedick of it, and hear</LINE>
-<LINE>what a' will say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Were it good, think you?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Hero thinks surely she will die; for she says she</LINE>
-<LINE>will die, if he love her not, and she will die, ere</LINE>
-<LINE>she make her love known, and she will die, if he woo</LINE>
-<LINE>her, rather than she will bate one breath of her</LINE>
-<LINE>accustomed crossness.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>She doth well: if she should make tender of her</LINE>
-<LINE>love, 'tis very possible he'll scorn it; for the</LINE>
-<LINE>man, as you know all, hath a contemptible spirit.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>He is a very proper man.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>He hath indeed a good outward happiness.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Before God! and, in my mind, very wise.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>He doth indeed show some sparks that are like wit.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And I take him to be valiant.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>As Hector, I assure you: and in the managing of</LINE>
-<LINE>quarrels you may say he is wise; for either he</LINE>
-<LINE>avoids them with great discretion, or undertakes</LINE>
-<LINE>them with a most Christian-like fear.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>If he do fear God, a' must necessarily keep peace:</LINE>
-<LINE>if he break the peace, he ought to enter into a</LINE>
-<LINE>quarrel with fear and trembling.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>And so will he do; for the man doth fear God,</LINE>
-<LINE>howsoever it seems not in him by some large jests</LINE>
-<LINE>he will make. Well I am sorry for your niece. Shall</LINE>
-<LINE>we go seek Benedick, and tell him of her love?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Never tell him, my lord: let her wear it out with</LINE>
-<LINE>good counsel.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Nay, that's impossible: she may wear her heart out first.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Well, we will hear further of it by your daughter:</LINE>
-<LINE>let it cool the while. I love Benedick well; and I</LINE>
-<LINE>could wish he would modestly examine himself, to see</LINE>
-<LINE>how much he is unworthy so good a lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>My lord, will you walk? dinner is ready.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If he do not dote on her upon this, I will never</LINE>
-<LINE>trust my expectation.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Let there be the same net spread for her; and that</LINE>
-<LINE>must your daughter and her gentlewomen carry. The</LINE>
-<LINE>sport will be, when they hold one an opinion of</LINE>
-<LINE>another's dotage, and no such matter: that's the</LINE>
-<LINE>scene that I would see, which will be merely a</LINE>
-<LINE>dumb-show. Let us send her to call him in to dinner.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt DON PEDRO, CLAUDIO, and LEONATO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE><STAGEDIR>Coming forward</STAGEDIR> This can be no trick: the</LINE>
-<LINE>conference was sadly borne. They have the truth of</LINE>
-<LINE>this from Hero. They seem to pity the lady: it</LINE>
-<LINE>seems her affections have their full bent. Love me!</LINE>
-<LINE>why, it must be requited. I hear how I am censured:</LINE>
-<LINE>they say I will bear myself proudly, if I perceive</LINE>
-<LINE>the love come from her; they say too that she will</LINE>
-<LINE>rather die than give any sign of affection. I did</LINE>
-<LINE>never think to marry: I must not seem proud: happy</LINE>
-<LINE>are they that hear their detractions and can put</LINE>
-<LINE>them to mending. They say the lady is fair; 'tis a</LINE>
-<LINE>truth, I can bear them witness; and virtuous; 'tis</LINE>
-<LINE>so, I cannot reprove it; and wise, but for loving</LINE>
-<LINE>me; by my troth, it is no addition to her wit, nor</LINE>
-<LINE>no great argument of her folly, for I will be</LINE>
-<LINE>horribly in love with her. I may chance have some</LINE>
-<LINE>odd quirks and remnants of wit broken on me,</LINE>
-<LINE>because I have railed so long against marriage: but</LINE>
-<LINE>doth not the appetite alter? a man loves the meat</LINE>
-<LINE>in his youth that he cannot endure in his age.</LINE>
-<LINE>Shall quips and sentences and these paper bullets of</LINE>
-<LINE>the brain awe a man from the career of his humour?</LINE>
-<LINE>No, the world must be peopled. When I said I would</LINE>
-<LINE>die a bachelor, I did not think I should live till I</LINE>
-<LINE>were married. Here comes Beatrice. By this day!</LINE>
-<LINE>she's a fair lady: I do spy some marks of love in</LINE>
-<LINE>her.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter BEATRICE</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Against my will I am sent to bid you come in to dinner.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Fair Beatrice, I thank you for your pains.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I took no more pains for those thanks than you take</LINE>
-<LINE>pains to thank me: if it had been painful, I would</LINE>
-<LINE>not have come.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>You take pleasure then in the message?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Yea, just so much as you may take upon a knife's</LINE>
-<LINE>point and choke a daw withal. You have no stomach,</LINE>
-<LINE>signior: fare you well.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Ha! 'Against my will I am sent to bid you come in</LINE>
-<LINE>to dinner;' there's a double meaning in that 'I took</LINE>
-<LINE>no more pains for those thanks than you took pains</LINE>
-<LINE>to thank me.' that's as much as to say, Any pains</LINE>
-<LINE>that I take for you is as easy as thanks. If I do</LINE>
-<LINE>not take pity of her, I am a villain; if I do not</LINE>
-<LINE>love her, I am a Jew. I will go get her picture.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-</SCENE>
-
-</ACT>
-
-<ACT><TITLE>ACT III</TITLE>
-
-<SCENE><TITLE>SCENE I. LEONATO'S garden.</TITLE>
-<STAGEDIR>Enter HERO, MARGARET, and URSULA</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Good Margaret, run thee to the parlor;</LINE>
-<LINE>There shalt thou find my cousin Beatrice</LINE>
-<LINE>Proposing with the prince and Claudio:</LINE>
-<LINE>Whisper her ear and tell her, I and Ursula</LINE>
-<LINE>Walk in the orchard and our whole discourse</LINE>
-<LINE>Is all of her; say that thou overheard'st us;</LINE>
-<LINE>And bid her steal into the pleached bower,</LINE>
-<LINE>Where honeysuckles, ripen'd by the sun,</LINE>
-<LINE>Forbid the sun to enter, like favourites,</LINE>
-<LINE>Made proud by princes, that advance their pride</LINE>
-<LINE>Against that power that bred it: there will she hide her,</LINE>
-<LINE>To listen our purpose. This is thy office;</LINE>
-<LINE>Bear thee well in it and leave us alone.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>I'll make her come, I warrant you, presently.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Now, Ursula, when Beatrice doth come,</LINE>
-<LINE>As we do trace this alley up and down,</LINE>
-<LINE>Our talk must only be of Benedick.</LINE>
-<LINE>When I do name him, let it be thy part</LINE>
-<LINE>To praise him more than ever man did merit:</LINE>
-<LINE>My talk to thee must be how Benedick</LINE>
-<LINE>Is sick in love with Beatrice. Of this matter</LINE>
-<LINE>Is little Cupid's crafty arrow made,</LINE>
-<LINE>That only wounds by hearsay.</LINE>
-<STAGEDIR>Enter BEATRICE, behind</STAGEDIR>
-<LINE>Now begin;</LINE>
-<LINE>For look where Beatrice, like a lapwing, runs</LINE>
-<LINE>Close by the ground, to hear our conference.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>The pleasant'st angling is to see the fish</LINE>
-<LINE>Cut with her golden oars the silver stream,</LINE>
-<LINE>And greedily devour the treacherous bait:</LINE>
-<LINE>So angle we for Beatrice; who even now</LINE>
-<LINE>Is couched in the woodbine coverture.</LINE>
-<LINE>Fear you not my part of the dialogue.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Then go we near her, that her ear lose nothing</LINE>
-<LINE>Of the false sweet bait that we lay for it.</LINE>
-<STAGEDIR>Approaching the bower</STAGEDIR>
-<LINE>No, truly, Ursula, she is too disdainful;</LINE>
-<LINE>I know her spirits are as coy and wild</LINE>
-<LINE>As haggerds of the rock.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>But are you sure</LINE>
-<LINE>That Benedick loves Beatrice so entirely?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>So says the prince and my new-trothed lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>And did they bid you tell her of it, madam?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>They did entreat me to acquaint her of it;</LINE>
-<LINE>But I persuaded them, if they loved Benedick,</LINE>
-<LINE>To wish him wrestle with affection,</LINE>
-<LINE>And never to let Beatrice know of it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Why did you so? Doth not the gentleman</LINE>
-<LINE>Deserve as full as fortunate a bed</LINE>
-<LINE>As ever Beatrice shall couch upon?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>O god of love! I know he doth deserve</LINE>
-<LINE>As much as may be yielded to a man:</LINE>
-<LINE>But Nature never framed a woman's heart</LINE>
-<LINE>Of prouder stuff than that of Beatrice;</LINE>
-<LINE>Disdain and scorn ride sparkling in her eyes,</LINE>
-<LINE>Misprising what they look on, and her wit</LINE>
-<LINE>Values itself so highly that to her</LINE>
-<LINE>All matter else seems weak: she cannot love,</LINE>
-<LINE>Nor take no shape nor project of affection,</LINE>
-<LINE>She is so self-endeared.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Sure, I think so;</LINE>
-<LINE>And therefore certainly it were not good</LINE>
-<LINE>She knew his love, lest she make sport at it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Why, you speak truth. I never yet saw man,</LINE>
-<LINE>How wise, how noble, young, how rarely featured,</LINE>
-<LINE>But she would spell him backward: if fair-faced,</LINE>
-<LINE>She would swear the gentleman should be her sister;</LINE>
-<LINE>If black, why, Nature, drawing of an antique,</LINE>
-<LINE>Made a foul blot; if tall, a lance ill-headed;</LINE>
-<LINE>If low, an agate very vilely cut;</LINE>
-<LINE>If speaking, why, a vane blown with all winds;</LINE>
-<LINE>If silent, why, a block moved with none.</LINE>
-<LINE>So turns she every man the wrong side out</LINE>
-<LINE>And never gives to truth and virtue that</LINE>
-<LINE>Which simpleness and merit purchaseth.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Sure, sure, such carping is not commendable.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>No, not to be so odd and from all fashions</LINE>
-<LINE>As Beatrice is, cannot be commendable:</LINE>
-<LINE>But who dare tell her so? If I should speak,</LINE>
-<LINE>She would mock me into air; O, she would laugh me</LINE>
-<LINE>Out of myself, press me to death with wit.</LINE>
-<LINE>Therefore let Benedick, like cover'd fire,</LINE>
-<LINE>Consume away in sighs, waste inwardly:</LINE>
-<LINE>It were a better death than die with mocks,</LINE>
-<LINE>Which is as bad as die with tickling.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Yet tell her of it: hear what she will say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>No; rather I will go to Benedick</LINE>
-<LINE>And counsel him to fight against his passion.</LINE>
-<LINE>And, truly, I'll devise some honest slanders</LINE>
-<LINE>To stain my cousin with: one doth not know</LINE>
-<LINE>How much an ill word may empoison liking.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>O, do not do your cousin such a wrong.</LINE>
-<LINE>She cannot be so much without true judgment--</LINE>
-<LINE>Having so swift and excellent a wit</LINE>
-<LINE>As she is prized to have--as to refuse</LINE>
-<LINE>So rare a gentleman as Signior Benedick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>He is the only man of Italy.</LINE>
-<LINE>Always excepted my dear Claudio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>I pray you, be not angry with me, madam,</LINE>
-<LINE>Speaking my fancy: Signior Benedick,</LINE>
-<LINE>For shape, for bearing, argument and valour,</LINE>
-<LINE>Goes foremost in report through Italy.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Indeed, he hath an excellent good name.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>His excellence did earn it, ere he had it.</LINE>
-<LINE>When are you married, madam?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Why, every day, to-morrow. Come, go in:</LINE>
-<LINE>I'll show thee some attires, and have thy counsel</LINE>
-<LINE>Which is the best to furnish me to-morrow.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>She's limed, I warrant you: we have caught her, madam.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>If it proves so, then loving goes by haps:</LINE>
-<LINE>Some Cupid kills with arrows, some with traps.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt HERO and URSULA</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE><STAGEDIR>Coming forward</STAGEDIR></LINE>
-<LINE>What fire is in mine ears? Can this be true?</LINE>
-<LINE>Stand I condemn'd for pride and scorn so much?</LINE>
-<LINE>Contempt, farewell! and maiden pride, adieu!</LINE>
-<LINE>No glory lives behind the back of such.</LINE>
-<LINE>And, Benedick, love on; I will requite thee,</LINE>
-<LINE>Taming my wild heart to thy loving hand:</LINE>
-<LINE>If thou dost love, my kindness shall incite thee</LINE>
-<LINE>To bind our loves up in a holy band;</LINE>
-<LINE>For others say thou dost deserve, and I</LINE>
-<LINE>Believe it better than reportingly.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE II. A room in LEONATO'S house</TITLE>
-<STAGEDIR>Enter DON PEDRO, CLAUDIO, BENEDICK, and LEONATO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I do but stay till your marriage be consummate, and</LINE>
-<LINE>then go I toward Arragon.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I'll bring you thither, my lord, if you'll</LINE>
-<LINE>vouchsafe me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Nay, that would be as great a soil in the new gloss</LINE>
-<LINE>of your marriage as to show a child his new coat</LINE>
-<LINE>and forbid him to wear it. I will only be bold</LINE>
-<LINE>with Benedick for his company; for, from the crown</LINE>
-<LINE>of his head to the sole of his foot, he is all</LINE>
-<LINE>mirth: he hath twice or thrice cut Cupid's</LINE>
-<LINE>bow-string and the little hangman dare not shoot at</LINE>
-<LINE>him; he hath a heart as sound as a bell and his</LINE>
-<LINE>tongue is the clapper, for what his heart thinks his</LINE>
-<LINE>tongue speaks.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Gallants, I am not as I have been.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>So say I methinks you are sadder.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I hope he be in love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Hang him, truant! there's no true drop of blood in</LINE>
-<LINE>him, to be truly touched with love: if he be sad,</LINE>
-<LINE>he wants money.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I have the toothache.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Draw it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Hang it!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>You must hang it first, and draw it afterwards.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>What! sigh for the toothache?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Where is but a humour or a worm.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Well, every one can master a grief but he that has</LINE>
-<LINE>it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Yet say I, he is in love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>There is no appearance of fancy in him, unless it be</LINE>
-<LINE>a fancy that he hath to strange disguises; as, to be</LINE>
-<LINE>a Dutchman today, a Frenchman to-morrow, or in the</LINE>
-<LINE>shape of two countries at once, as, a German from</LINE>
-<LINE>the waist downward, all slops, and a Spaniard from</LINE>
-<LINE>the hip upward, no doublet. Unless he have a fancy</LINE>
-<LINE>to this foolery, as it appears he hath, he is no</LINE>
-<LINE>fool for fancy, as you would have it appear he is.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If he be not in love with some woman, there is no</LINE>
-<LINE>believing old signs: a' brushes his hat o'</LINE>
-<LINE>mornings; what should that bode?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Hath any man seen him at the barber's?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>No, but the barber's man hath been seen with him,</LINE>
-<LINE>and the old ornament of his cheek hath already</LINE>
-<LINE>stuffed tennis-balls.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Indeed, he looks younger than he did, by the loss of a beard.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Nay, a' rubs himself with civet: can you smell him</LINE>
-<LINE>out by that?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>That's as much as to say, the sweet youth's in love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>The greatest note of it is his melancholy.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And when was he wont to wash his face?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Yea, or to paint himself? for the which, I hear</LINE>
-<LINE>what they say of him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Nay, but his jesting spirit; which is now crept into</LINE>
-<LINE>a lute-string and now governed by stops.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Indeed, that tells a heavy tale for him: conclude,</LINE>
-<LINE>conclude he is in love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Nay, but I know who loves him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>That would I know too: I warrant, one that knows him not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Yes, and his ill conditions; and, in despite of</LINE>
-<LINE>all, dies for him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>She shall be buried with her face upwards.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Yet is this no charm for the toothache. Old</LINE>
-<LINE>signior, walk aside with me: I have studied eight</LINE>
-<LINE>or nine wise words to speak to you, which these</LINE>
-<LINE>hobby-horses must not hear.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt BENEDICK and LEONATO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>For my life, to break with him about Beatrice.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>'Tis even so. Hero and Margaret have by this</LINE>
-<LINE>played their parts with Beatrice; and then the two</LINE>
-<LINE>bears will not bite one another when they meet.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter DON JOHN</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>My lord and brother, God save you!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Good den, brother.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>If your leisure served, I would speak with you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>In private?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>If it please you: yet Count Claudio may hear; for</LINE>
-<LINE>what I would speak of concerns him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>What's the matter?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE><STAGEDIR>To CLAUDIO</STAGEDIR> Means your lordship to be married</LINE>
-<LINE>to-morrow?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>You know he does.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I know not that, when he knows what I know.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If there be any impediment, I pray you discover it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>You may think I love you not: let that appear</LINE>
-<LINE>hereafter, and aim better at me by that I now will</LINE>
-<LINE>manifest. For my brother, I think he holds you</LINE>
-<LINE>well, and in dearness of heart hath holp to effect</LINE>
-<LINE>your ensuing marriage;--surely suit ill spent and</LINE>
-<LINE>labour ill bestowed.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Why, what's the matter?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I came hither to tell you; and, circumstances</LINE>
-<LINE>shortened, for she has been too long a talking of,</LINE>
-<LINE>the lady is disloyal.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Who, Hero?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Even she; Leonato's Hero, your Hero, every man's Hero:</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Disloyal?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>The word is too good to paint out her wickedness; I</LINE>
-<LINE>could say she were worse: think you of a worse</LINE>
-<LINE>title, and I will fit her to it. Wonder not till</LINE>
-<LINE>further warrant: go but with me to-night, you shall</LINE>
-<LINE>see her chamber-window entered, even the night</LINE>
-<LINE>before her wedding-day: if you love her then,</LINE>
-<LINE>to-morrow wed her; but it would better fit your honour</LINE>
-<LINE>to change your mind.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>May this be so?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>I will not think it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>If you dare not trust that you see, confess not</LINE>
-<LINE>that you know: if you will follow me, I will show</LINE>
-<LINE>you enough; and when you have seen more and heard</LINE>
-<LINE>more, proceed accordingly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>If I see any thing to-night why I should not marry</LINE>
-<LINE>her to-morrow in the congregation, where I should</LINE>
-<LINE>wed, there will I shame her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>And, as I wooed for thee to obtain her, I will join</LINE>
-<LINE>with thee to disgrace her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>I will disparage her no farther till you are my</LINE>
-<LINE>witnesses: bear it coldly but till midnight, and</LINE>
-<LINE>let the issue show itself.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>O day untowardly turned!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O mischief strangely thwarting!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>O plague right well prevented! so will you say when</LINE>
-<LINE>you have seen the sequel.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE III. A street.</TITLE>
-<STAGEDIR>Enter DOGBERRY and VERGES with the Watch</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Are you good men and true?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Yea, or else it were pity but they should suffer</LINE>
-<LINE>salvation, body and soul.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Nay, that were a punishment too good for them, if</LINE>
-<LINE>they should have any allegiance in them, being</LINE>
-<LINE>chosen for the prince's watch.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Well, give them their charge, neighbour Dogberry.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>First, who think you the most desertless man to be</LINE>
-<LINE>constable?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>First Watchman</SPEAKER>
-<LINE>Hugh Otecake, sir, or George Seacole; for they can</LINE>
-<LINE>write and read.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Come hither, neighbour Seacole. God hath blessed</LINE>
-<LINE>you with a good name: to be a well-favoured man is</LINE>
-<LINE>the gift of fortune; but to write and read comes by nature.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Second Watchman</SPEAKER>
-<LINE>Both which, master constable,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>You have: I knew it would be your answer. Well,</LINE>
-<LINE>for your favour, sir, why, give God thanks, and make</LINE>
-<LINE>no boast of it; and for your writing and reading,</LINE>
-<LINE>let that appear when there is no need of such</LINE>
-<LINE>vanity. You are thought here to be the most</LINE>
-<LINE>senseless and fit man for the constable of the</LINE>
-<LINE>watch; therefore bear you the lantern. This is your</LINE>
-<LINE>charge: you shall comprehend all vagrom men; you are</LINE>
-<LINE>to bid any man stand, in the prince's name.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Second Watchman</SPEAKER>
-<LINE>How if a' will not stand?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Why, then, take no note of him, but let him go; and</LINE>
-<LINE>presently call the rest of the watch together and</LINE>
-<LINE>thank God you are rid of a knave.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>If he will not stand when he is bidden, he is none</LINE>
-<LINE>of the prince's subjects.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>True, and they are to meddle with none but the</LINE>
-<LINE>prince's subjects. You shall also make no noise in</LINE>
-<LINE>the streets; for, for the watch to babble and to</LINE>
-<LINE>talk is most tolerable and not to be endured.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>We will rather sleep than talk: we know what</LINE>
-<LINE>belongs to a watch.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Why, you speak like an ancient and most quiet</LINE>
-<LINE>watchman; for I cannot see how sleeping should</LINE>
-<LINE>offend: only, have a care that your bills be not</LINE>
-<LINE>stolen. Well, you are to call at all the</LINE>
-<LINE>ale-houses, and bid those that are drunk get them to bed.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>How if they will not?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Why, then, let them alone till they are sober: if</LINE>
-<LINE>they make you not then the better answer, you may</LINE>
-<LINE>say they are not the men you took them for.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>Well, sir.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>If you meet a thief, you may suspect him, by virtue</LINE>
-<LINE>of your office, to be no true man; and, for such</LINE>
-<LINE>kind of men, the less you meddle or make with them,</LINE>
-<LINE>why the more is for your honesty.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>If we know him to be a thief, shall we not lay</LINE>
-<LINE>hands on him?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Truly, by your office, you may; but I think they</LINE>
-<LINE>that touch pitch will be defiled: the most peaceable</LINE>
-<LINE>way for you, if you do take a thief, is to let him</LINE>
-<LINE>show himself what he is and steal out of your company.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>You have been always called a merciful man, partner.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Truly, I would not hang a dog by my will, much more</LINE>
-<LINE>a man who hath any honesty in him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>If you hear a child cry in the night, you must call</LINE>
-<LINE>to the nurse and bid her still it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>How if the nurse be asleep and will not hear us?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Why, then, depart in peace, and let the child wake</LINE>
-<LINE>her with crying; for the ewe that will not hear her</LINE>
-<LINE>lamb when it baes will never answer a calf when he bleats.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>'Tis very true.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>This is the end of the charge:--you, constable, are</LINE>
-<LINE>to present the prince's own person: if you meet the</LINE>
-<LINE>prince in the night, you may stay him.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Nay, by'r our lady, that I think a' cannot.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Five shillings to one on't, with any man that knows</LINE>
-<LINE>the statutes, he may stay him: marry, not without</LINE>
-<LINE>the prince be willing; for, indeed, the watch ought</LINE>
-<LINE>to offend no man; and it is an offence to stay a</LINE>
-<LINE>man against his will.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>By'r lady, I think it be so.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Ha, ha, ha! Well, masters, good night: an there be</LINE>
-<LINE>any matter of weight chances, call up me: keep your</LINE>
-<LINE>fellows' counsels and your own; and good night.</LINE>
-<LINE>Come, neighbour.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE>Well, masters, we hear our charge: let us go sit here</LINE>
-<LINE>upon the church-bench till two, and then all to bed.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>One word more, honest neighbours. I pray you watch</LINE>
-<LINE>about Signior Leonato's door; for the wedding being</LINE>
-<LINE>there to-morrow, there is a great coil to-night.</LINE>
-<LINE>Adieu: be vigitant, I beseech you.</LINE>
-</SPEECH>
-
-<STAGEDIR>Exeunt DOGBERRY and VERGES</STAGEDIR>
-<STAGEDIR>Enter BORACHIO and CONRADE</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>What Conrade!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE><STAGEDIR>Aside</STAGEDIR> Peace! stir not.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Conrade, I say!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Here, man; I am at thy elbow.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Mass, and my elbow itched; I thought there would a</LINE>
-<LINE>scab follow.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>I will owe thee an answer for that: and now forward</LINE>
-<LINE>with thy tale.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Stand thee close, then, under this pent-house, for</LINE>
-<LINE>it drizzles rain; and I will, like a true drunkard,</LINE>
-<LINE>utter all to thee.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE><STAGEDIR>Aside</STAGEDIR> Some treason, masters: yet stand close.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Therefore know I have earned of Don John a thousand ducats.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Is it possible that any villany should be so dear?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Thou shouldst rather ask if it were possible any</LINE>
-<LINE>villany should be so rich; for when rich villains</LINE>
-<LINE>have need of poor ones, poor ones may make what</LINE>
-<LINE>price they will.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>I wonder at it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>That shows thou art unconfirmed. Thou knowest that</LINE>
-<LINE>the fashion of a doublet, or a hat, or a cloak, is</LINE>
-<LINE>nothing to a man.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Yes, it is apparel.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>I mean, the fashion.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Yes, the fashion is the fashion.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Tush! I may as well say the fool's the fool. But</LINE>
-<LINE>seest thou not what a deformed thief this fashion</LINE>
-<LINE>is?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Watchman</SPEAKER>
-<LINE><STAGEDIR>Aside</STAGEDIR> I know that Deformed; a' has been a vile</LINE>
-<LINE>thief this seven year; a' goes up and down like a</LINE>
-<LINE>gentleman: I remember his name.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Didst thou not hear somebody?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>No; 'twas the vane on the house.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Seest thou not, I say, what a deformed thief this</LINE>
-<LINE>fashion is? how giddily a' turns about all the hot</LINE>
-<LINE>bloods between fourteen and five-and-thirty?</LINE>
-<LINE>sometimes fashioning them like Pharaoh's soldiers</LINE>
-<LINE>in the reeky painting, sometime like god Bel's</LINE>
-<LINE>priests in the old church-window, sometime like the</LINE>
-<LINE>shaven Hercules in the smirched worm-eaten tapestry,</LINE>
-<LINE>where his codpiece seems as massy as his club?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>All this I see; and I see that the fashion wears</LINE>
-<LINE>out more apparel than the man. But art not thou</LINE>
-<LINE>thyself giddy with the fashion too, that thou hast</LINE>
-<LINE>shifted out of thy tale into telling me of the fashion?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Not so, neither: but know that I have to-night</LINE>
-<LINE>wooed Margaret, the Lady Hero's gentlewoman, by the</LINE>
-<LINE>name of Hero: she leans me out at her mistress'</LINE>
-<LINE>chamber-window, bids me a thousand times good</LINE>
-<LINE>night,--I tell this tale vilely:--I should first</LINE>
-<LINE>tell thee how the prince, Claudio and my master,</LINE>
-<LINE>planted and placed and possessed by my master Don</LINE>
-<LINE>John, saw afar off in the orchard this amiable encounter.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>And thought they Margaret was Hero?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Two of them did, the prince and Claudio; but the</LINE>
-<LINE>devil my master knew she was Margaret; and partly</LINE>
-<LINE>by his oaths, which first possessed them, partly by</LINE>
-<LINE>the dark night, which did deceive them, but chiefly</LINE>
-<LINE>by my villany, which did confirm any slander that</LINE>
-<LINE>Don John had made, away went Claudio enraged; swore</LINE>
-<LINE>he would meet her, as he was appointed, next morning</LINE>
-<LINE>at the temple, and there, before the whole</LINE>
-<LINE>congregation, shame her with what he saw o'er night</LINE>
-<LINE>and send her home again without a husband.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>First Watchman</SPEAKER>
-<LINE>We charge you, in the prince's name, stand!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Second Watchman</SPEAKER>
-<LINE>Call up the right master constable. We have here</LINE>
-<LINE>recovered the most dangerous piece of lechery that</LINE>
-<LINE>ever was known in the commonwealth.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>First Watchman</SPEAKER>
-<LINE>And one Deformed is one of them: I know him; a'</LINE>
-<LINE>wears a lock.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Masters, masters,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Second Watchman</SPEAKER>
-<LINE>You'll be made bring Deformed forth, I warrant you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>Masters,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>First Watchman</SPEAKER>
-<LINE>Never speak: we charge you let us obey you to go with us.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>We are like to prove a goodly commodity, being taken</LINE>
-<LINE>up of these men's bills.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>A commodity in question, I warrant you. Come, we'll obey you.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE IV. HERO's apartment.</TITLE>
-<STAGEDIR>Enter HERO, MARGARET, and URSULA</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Good Ursula, wake my cousin Beatrice, and desire</LINE>
-<LINE>her to rise.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>I will, lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>And bid her come hither.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Well.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exit</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Troth, I think your other rabato were better.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>No, pray thee, good Meg, I'll wear this.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>By my troth, 's not so good; and I warrant your</LINE>
-<LINE>cousin will say so.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>My cousin's a fool, and thou art another: I'll wear</LINE>
-<LINE>none but this.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>I like the new tire within excellently, if the hair</LINE>
-<LINE>were a thought browner; and your gown's a most rare</LINE>
-<LINE>fashion, i' faith. I saw the Duchess of Milan's</LINE>
-<LINE>gown that they praise so.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>O, that exceeds, they say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>By my troth, 's but a night-gown in respect of</LINE>
-<LINE>yours: cloth o' gold, and cuts, and laced with</LINE>
-<LINE>silver, set with pearls, down sleeves, side sleeves,</LINE>
-<LINE>and skirts, round underborne with a bluish tinsel:</LINE>
-<LINE>but for a fine, quaint, graceful and excellent</LINE>
-<LINE>fashion, yours is worth ten on 't.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>God give me joy to wear it! for my heart is</LINE>
-<LINE>exceeding heavy.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>'Twill be heavier soon by the weight of a man.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Fie upon thee! art not ashamed?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Of what, lady? of speaking honourably? Is not</LINE>
-<LINE>marriage honourable in a beggar? Is not your lord</LINE>
-<LINE>honourable without marriage? I think you would have</LINE>
-<LINE>me say, 'saving your reverence, a husband:' and bad</LINE>
-<LINE>thinking do not wrest true speaking, I'll offend</LINE>
-<LINE>nobody: is there any harm in 'the heavier for a</LINE>
-<LINE>husband'? None, I think, and it be the right husband</LINE>
-<LINE>and the right wife; otherwise 'tis light, and not</LINE>
-<LINE>heavy: ask my Lady Beatrice else; here she comes.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter BEATRICE</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Good morrow, coz.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Good morrow, sweet Hero.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Why how now? do you speak in the sick tune?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I am out of all other tune, methinks.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Clap's into 'Light o' love;' that goes without a</LINE>
-<LINE>burden: do you sing it, and I'll dance it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Ye light o' love, with your heels! then, if your</LINE>
-<LINE>husband have stables enough, you'll see he shall</LINE>
-<LINE>lack no barns.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>O illegitimate construction! I scorn that with my heels.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>'Tis almost five o'clock, cousin; tis time you were</LINE>
-<LINE>ready. By my troth, I am exceeding ill: heigh-ho!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>For a hawk, a horse, or a husband?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>For the letter that begins them all, H.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Well, and you be not turned Turk, there's no more</LINE>
-<LINE>sailing by the star.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>What means the fool, trow?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Nothing I; but God send every one their heart's desire!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>These gloves the count sent me; they are an</LINE>
-<LINE>excellent perfume.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I am stuffed, cousin; I cannot smell.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>A maid, and stuffed! there's goodly catching of cold.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>O, God help me! God help me! how long have you</LINE>
-<LINE>professed apprehension?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Even since you left it. Doth not my wit become me rarely?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>It is not seen enough, you should wear it in your</LINE>
-<LINE>cap. By my troth, I am sick.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Get you some of this distilled Carduus Benedictus,</LINE>
-<LINE>and lay it to your heart: it is the only thing for a qualm.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>There thou prickest her with a thistle.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Benedictus! why Benedictus? you have some moral in</LINE>
-<LINE>this Benedictus.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Moral! no, by my troth, I have no moral meaning; I</LINE>
-<LINE>meant, plain holy-thistle. You may think perchance</LINE>
-<LINE>that I think you are in love: nay, by'r lady, I am</LINE>
-<LINE>not such a fool to think what I list, nor I list</LINE>
-<LINE>not to think what I can, nor indeed I cannot think,</LINE>
-<LINE>if I would think my heart out of thinking, that you</LINE>
-<LINE>are in love or that you will be in love or that you</LINE>
-<LINE>can be in love. Yet Benedick was such another, and</LINE>
-<LINE>now is he become a man: he swore he would never</LINE>
-<LINE>marry, and yet now, in despite of his heart, he eats</LINE>
-<LINE>his meat without grudging: and how you may be</LINE>
-<LINE>converted I know not, but methinks you look with</LINE>
-<LINE>your eyes as other women do.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>What pace is this that thy tongue keeps?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>MARGARET</SPEAKER>
-<LINE>Not a false gallop.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Re-enter URSULA</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>URSULA</SPEAKER>
-<LINE>Madam, withdraw: the prince, the count, Signior</LINE>
-<LINE>Benedick, Don John, and all the gallants of the</LINE>
-<LINE>town, are come to fetch you to church.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Help to dress me, good coz, good Meg, good Ursula.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE V. Another room in LEONATO'S house.</TITLE>
-<STAGEDIR>Enter LEONATO, with DOGBERRY and VERGES</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What would you with me, honest neighbour?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Marry, sir, I would have some confidence with you</LINE>
-<LINE>that decerns you nearly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Brief, I pray you; for you see it is a busy time with me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Marry, this it is, sir.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Yes, in truth it is, sir.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What is it, my good friends?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Goodman Verges, sir, speaks a little off the</LINE>
-<LINE>matter: an old man, sir, and his wits are not so</LINE>
-<LINE>blunt as, God help, I would desire they were; but,</LINE>
-<LINE>in faith, honest as the skin between his brows.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Yes, I thank God I am as honest as any man living</LINE>
-<LINE>that is an old man and no honester than I.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Comparisons are odorous: palabras, neighbour Verges.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Neighbours, you are tedious.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>It pleases your worship to say so, but we are the</LINE>
-<LINE>poor duke's officers; but truly, for mine own part,</LINE>
-<LINE>if I were as tedious as a king, I could find it in</LINE>
-<LINE>my heart to bestow it all of your worship.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>All thy tediousness on me, ah?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Yea, an 'twere a thousand pound more than 'tis; for</LINE>
-<LINE>I hear as good exclamation on your worship as of any</LINE>
-<LINE>man in the city; and though I be but a poor man, I</LINE>
-<LINE>am glad to hear it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>And so am I.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I would fain know what you have to say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Marry, sir, our watch to-night, excepting your</LINE>
-<LINE>worship's presence, ha' ta'en a couple of as arrant</LINE>
-<LINE>knaves as any in Messina.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>A good old man, sir; he will be talking: as they</LINE>
-<LINE>say, when the age is in, the wit is out: God help</LINE>
-<LINE>us! it is a world to see. Well said, i' faith,</LINE>
-<LINE>neighbour Verges: well, God's a good man; an two men</LINE>
-<LINE>ride of a horse, one must ride behind. An honest</LINE>
-<LINE>soul, i' faith, sir; by my troth he is, as ever</LINE>
-<LINE>broke bread; but God is to be worshipped; all men</LINE>
-<LINE>are not alike; alas, good neighbour!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Indeed, neighbour, he comes too short of you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Gifts that God gives.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I must leave you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>One word, sir: our watch, sir, have indeed</LINE>
-<LINE>comprehended two aspicious persons, and we would</LINE>
-<LINE>have them this morning examined before your worship.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Take their examination yourself and bring it me: I</LINE>
-<LINE>am now in great haste, as it may appear unto you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>It shall be suffigance.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Drink some wine ere you go: fare you well.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Enter a Messenger</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>Messenger</SPEAKER>
-<LINE>My lord, they stay for you to give your daughter to</LINE>
-<LINE>her husband.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I'll wait upon them: I am ready.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt LEONATO and Messenger</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Go, good partner, go, get you to Francis Seacole;</LINE>
-<LINE>bid him bring his pen and inkhorn to the gaol: we</LINE>
-<LINE>are now to examination these men.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>And we must do it wisely.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>We will spare for no wit, I warrant you; here's</LINE>
-<LINE>that shall drive some of them to a non-come: only</LINE>
-<LINE>get the learned writer to set down our</LINE>
-<LINE>excommunication and meet me at the gaol.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-</ACT>
-
-<ACT><TITLE>ACT IV</TITLE>
-
-<SCENE><TITLE>SCENE I. A church.</TITLE>
-<STAGEDIR>Enter DON PEDRO, DON JOHN, LEONATO, FRIAR FRANCIS,
-CLAUDIO, BENEDICK, HERO, BEATRICE, and Attendants</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Come, Friar Francis, be brief; only to the plain</LINE>
-<LINE>form of marriage, and you shall recount their</LINE>
-<LINE>particular duties afterwards.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>You come hither, my lord, to marry this lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>No.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>To be married to her: friar, you come to marry her.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Lady, you come hither to be married to this count.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>I do.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>If either of you know any inward impediment why you</LINE>
-<LINE>should not be conjoined, charge you, on your souls,</LINE>
-<LINE>to utter it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Know you any, Hero?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>None, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Know you any, count?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I dare make his answer, none.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O, what men dare do! what men may do! what men daily</LINE>
-<LINE>do, not knowing what they do!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>How now! interjections? Why, then, some be of</LINE>
-<LINE>laughing, as, ah, ha, he!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Stand thee by, friar. Father, by your leave:</LINE>
-<LINE>Will you with free and unconstrained soul</LINE>
-<LINE>Give me this maid, your daughter?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>As freely, son, as God did give her me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>And what have I to give you back, whose worth</LINE>
-<LINE>May counterpoise this rich and precious gift?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Nothing, unless you render her again.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Sweet prince, you learn me noble thankfulness.</LINE>
-<LINE>There, Leonato, take her back again:</LINE>
-<LINE>Give not this rotten orange to your friend;</LINE>
-<LINE>She's but the sign and semblance of her honour.</LINE>
-<LINE>Behold how like a maid she blushes here!</LINE>
-<LINE>O, what authority and show of truth</LINE>
-<LINE>Can cunning sin cover itself withal!</LINE>
-<LINE>Comes not that blood as modest evidence</LINE>
-<LINE>To witness simple virtue? Would you not swear,</LINE>
-<LINE>All you that see her, that she were a maid,</LINE>
-<LINE>By these exterior shows? But she is none:</LINE>
-<LINE>She knows the heat of a luxurious bed;</LINE>
-<LINE>Her blush is guiltiness, not modesty.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What do you mean, my lord?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Not to be married,</LINE>
-<LINE>Not to knit my soul to an approved wanton.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Dear my lord, if you, in your own proof,</LINE>
-<LINE>Have vanquish'd the resistance of her youth,</LINE>
-<LINE>And made defeat of her virginity,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>I know what you would say: if I have known her,</LINE>
-<LINE>You will say she did embrace me as a husband,</LINE>
-<LINE>And so extenuate the 'forehand sin:</LINE>
-<LINE>No, Leonato,</LINE>
-<LINE>I never tempted her with word too large;</LINE>
-<LINE>But, as a brother to his sister, show'd</LINE>
-<LINE>Bashful sincerity and comely love.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>And seem'd I ever otherwise to you?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Out on thee! Seeming! I will write against it:</LINE>
-<LINE>You seem to me as Dian in her orb,</LINE>
-<LINE>As chaste as is the bud ere it be blown;</LINE>
-<LINE>But you are more intemperate in your blood</LINE>
-<LINE>Than Venus, or those pamper'd animals</LINE>
-<LINE>That rage in savage sensuality.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Is my lord well, that he doth speak so wide?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Sweet prince, why speak not you?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>What should I speak?</LINE>
-<LINE>I stand dishonour'd, that have gone about</LINE>
-<LINE>To link my dear friend to a common stale.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Are these things spoken, or do I but dream?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Sir, they are spoken, and these things are true.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>This looks not like a nuptial.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>True! O God!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Leonato, stand I here?</LINE>
-<LINE>Is this the prince? is this the prince's brother?</LINE>
-<LINE>Is this face Hero's? are our eyes our own?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>All this is so: but what of this, my lord?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Let me but move one question to your daughter;</LINE>
-<LINE>And, by that fatherly and kindly power</LINE>
-<LINE>That you have in her, bid her answer truly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I charge thee do so, as thou art my child.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>O, God defend me! how am I beset!</LINE>
-<LINE>What kind of catechising call you this?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>To make you answer truly to your name.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>Is it not Hero? Who can blot that name</LINE>
-<LINE>With any just reproach?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>Marry, that can Hero;</LINE>
-<LINE>Hero itself can blot out Hero's virtue.</LINE>
-<LINE>What man was he talk'd with you yesternight</LINE>
-<LINE>Out at your window betwixt twelve and one?</LINE>
-<LINE>Now, if you are a maid, answer to this.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>I talk'd with no man at that hour, my lord.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON PEDRO</SPEAKER>
-<LINE>Why, then are you no maiden. Leonato,</LINE>
-<LINE>I am sorry you must hear: upon mine honour,</LINE>
-<LINE>Myself, my brother and this grieved count</LINE>
-<LINE>Did see her, hear her, at that hour last night</LINE>
-<LINE>Talk with a ruffian at her chamber-window</LINE>
-<LINE>Who hath indeed, most like a liberal villain,</LINE>
-<LINE>Confess'd the vile encounters they have had</LINE>
-<LINE>A thousand times in secret.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Fie, fie! they are not to be named, my lord,</LINE>
-<LINE>Not to be spoke of;</LINE>
-<LINE>There is not chastity enough in language</LINE>
-<LINE>Without offence to utter them. Thus, pretty lady,</LINE>
-<LINE>I am sorry for thy much misgovernment.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CLAUDIO</SPEAKER>
-<LINE>O Hero, what a Hero hadst thou been,</LINE>
-<LINE>If half thy outward graces had been placed</LINE>
-<LINE>About thy thoughts and counsels of thy heart!</LINE>
-<LINE>But fare thee well, most foul, most fair! farewell,</LINE>
-<LINE>Thou pure impiety and impious purity!</LINE>
-<LINE>For thee I'll lock up all the gates of love,</LINE>
-<LINE>And on my eyelids shall conjecture hang,</LINE>
-<LINE>To turn all beauty into thoughts of harm,</LINE>
-<LINE>And never shall it more be gracious.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Hath no man's dagger here a point for me?</LINE>
-</SPEECH>
-
-
-<STAGEDIR>HERO swoons</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Why, how now, cousin! wherefore sink you down?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DON JOHN</SPEAKER>
-<LINE>Come, let us go. These things, come thus to light,</LINE>
-<LINE>Smother her spirits up.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt DON PEDRO, DON JOHN, and CLAUDIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>How doth the lady?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Dead, I think. Help, uncle!</LINE>
-<LINE>Hero! why, Hero! Uncle! Signior Benedick! Friar!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>O Fate! take not away thy heavy hand.</LINE>
-<LINE>Death is the fairest cover for her shame</LINE>
-<LINE>That may be wish'd for.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>How now, cousin Hero!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Have comfort, lady.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Dost thou look up?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Yea, wherefore should she not?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Wherefore! Why, doth not every earthly thing</LINE>
-<LINE>Cry shame upon her? Could she here deny</LINE>
-<LINE>The story that is printed in her blood?</LINE>
-<LINE>Do not live, Hero; do not ope thine eyes:</LINE>
-<LINE>For, did I think thou wouldst not quickly die,</LINE>
-<LINE>Thought I thy spirits were stronger than thy shames,</LINE>
-<LINE>Myself would, on the rearward of reproaches,</LINE>
-<LINE>Strike at thy life. Grieved I, I had but one?</LINE>
-<LINE>Chid I for that at frugal nature's frame?</LINE>
-<LINE>O, one too much by thee! Why had I one?</LINE>
-<LINE>Why ever wast thou lovely in my eyes?</LINE>
-<LINE>Why had I not with charitable hand</LINE>
-<LINE>Took up a beggar's issue at my gates,</LINE>
-<LINE>Who smirch'd thus and mired with infamy,</LINE>
-<LINE>I might have said 'No part of it is mine;</LINE>
-<LINE>This shame derives itself from unknown loins'?</LINE>
-<LINE>But mine and mine I loved and mine I praised</LINE>
-<LINE>And mine that I was proud on, mine so much</LINE>
-<LINE>That I myself was to myself not mine,</LINE>
-<LINE>Valuing of her,--why, she, O, she is fallen</LINE>
-<LINE>Into a pit of ink, that the wide sea</LINE>
-<LINE>Hath drops too few to wash her clean again</LINE>
-<LINE>And salt too little which may season give</LINE>
-<LINE>To her foul-tainted flesh!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Sir, sir, be patient.</LINE>
-<LINE>For my part, I am so attired in wonder,</LINE>
-<LINE>I know not what to say.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>O, on my soul, my cousin is belied!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Lady, were you her bedfellow last night?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>No, truly not; although, until last night,</LINE>
-<LINE>I have this twelvemonth been her bedfellow.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Confirm'd, confirm'd! O, that is stronger made</LINE>
-<LINE>Which was before barr'd up with ribs of iron!</LINE>
-<LINE>Would the two princes lie, and Claudio lie,</LINE>
-<LINE>Who loved her so, that, speaking of her foulness,</LINE>
-<LINE>Wash'd it with tears? Hence from her! let her die.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Hear me a little; for I have only been</LINE>
-<LINE>Silent so long and given way unto</LINE>
-<LINE>This course of fortune</LINE>
-<LINE>By noting of the lady. I have mark'd</LINE>
-<LINE>A thousand blushing apparitions</LINE>
-<LINE>To start into her face, a thousand innocent shames</LINE>
-<LINE>In angel whiteness beat away those blushes;</LINE>
-<LINE>And in her eye there hath appear'd a fire,</LINE>
-<LINE>To burn the errors that these princes hold</LINE>
-<LINE>Against her maiden truth. Call me a fool;</LINE>
-<LINE>Trust not my reading nor my observations,</LINE>
-<LINE>Which with experimental seal doth warrant</LINE>
-<LINE>The tenor of my book; trust not my age,</LINE>
-<LINE>My reverence, calling, nor divinity,</LINE>
-<LINE>If this sweet lady lie not guiltless here</LINE>
-<LINE>Under some biting error.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Friar, it cannot be.</LINE>
-<LINE>Thou seest that all the grace that she hath left</LINE>
-<LINE>Is that she will not add to her damnation</LINE>
-<LINE>A sin of perjury; she not denies it:</LINE>
-<LINE>Why seek'st thou then to cover with excuse</LINE>
-<LINE>That which appears in proper nakedness?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Lady, what man is he you are accused of?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>HERO</SPEAKER>
-<LINE>They know that do accuse me; I know none:</LINE>
-<LINE>If I know more of any man alive</LINE>
-<LINE>Than that which maiden modesty doth warrant,</LINE>
-<LINE>Let all my sins lack mercy! O my father,</LINE>
-<LINE>Prove you that any man with me conversed</LINE>
-<LINE>At hours unmeet, or that I yesternight</LINE>
-<LINE>Maintain'd the change of words with any creature,</LINE>
-<LINE>Refuse me, hate me, torture me to death!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>There is some strange misprision in the princes.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Two of them have the very bent of honour;</LINE>
-<LINE>And if their wisdoms be misled in this,</LINE>
-<LINE>The practise of it lives in John the bastard,</LINE>
-<LINE>Whose spirits toil in frame of villanies.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>I know not. If they speak but truth of her,</LINE>
-<LINE>These hands shall tear her; if they wrong her honour,</LINE>
-<LINE>The proudest of them shall well hear of it.</LINE>
-<LINE>Time hath not yet so dried this blood of mine,</LINE>
-<LINE>Nor age so eat up my invention,</LINE>
-<LINE>Nor fortune made such havoc of my means,</LINE>
-<LINE>Nor my bad life reft me so much of friends,</LINE>
-<LINE>But they shall find, awaked in such a kind,</LINE>
-<LINE>Both strength of limb and policy of mind,</LINE>
-<LINE>Ability in means and choice of friends,</LINE>
-<LINE>To quit me of them throughly.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Pause awhile,</LINE>
-<LINE>And let my counsel sway you in this case.</LINE>
-<LINE>Your daughter here the princes left for dead:</LINE>
-<LINE>Let her awhile be secretly kept in,</LINE>
-<LINE>And publish it that she is dead indeed;</LINE>
-<LINE>Maintain a mourning ostentation</LINE>
-<LINE>And on your family's old monument</LINE>
-<LINE>Hang mournful epitaphs and do all rites</LINE>
-<LINE>That appertain unto a burial.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>What shall become of this? what will this do?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>Marry, this well carried shall on her behalf</LINE>
-<LINE>Change slander to remorse; that is some good:</LINE>
-<LINE>But not for that dream I on this strange course,</LINE>
-<LINE>But on this travail look for greater birth.</LINE>
-<LINE>She dying, as it must so be maintain'd,</LINE>
-<LINE>Upon the instant that she was accused,</LINE>
-<LINE>Shall be lamented, pitied and excused</LINE>
-<LINE>Of every hearer: for it so falls out</LINE>
-<LINE>That what we have we prize not to the worth</LINE>
-<LINE>Whiles we enjoy it, but being lack'd and lost,</LINE>
-<LINE>Why, then we rack the value, then we find</LINE>
-<LINE>The virtue that possession would not show us</LINE>
-<LINE>Whiles it was ours. So will it fare with Claudio:</LINE>
-<LINE>When he shall hear she died upon his words,</LINE>
-<LINE>The idea of her life shall sweetly creep</LINE>
-<LINE>Into his study of imagination,</LINE>
-<LINE>And every lovely organ of her life</LINE>
-<LINE>Shall come apparell'd in more precious habit,</LINE>
-<LINE>More moving-delicate and full of life,</LINE>
-<LINE>Into the eye and prospect of his soul,</LINE>
-<LINE>Than when she lived indeed; then shall he mourn,</LINE>
-<LINE>If ever love had interest in his liver,</LINE>
-<LINE>And wish he had not so accused her,</LINE>
-<LINE>No, though he thought his accusation true.</LINE>
-<LINE>Let this be so, and doubt not but success</LINE>
-<LINE>Will fashion the event in better shape</LINE>
-<LINE>Than I can lay it down in likelihood.</LINE>
-<LINE>But if all aim but this be levell'd false,</LINE>
-<LINE>The supposition of the lady's death</LINE>
-<LINE>Will quench the wonder of her infamy:</LINE>
-<LINE>And if it sort not well, you may conceal her,</LINE>
-<LINE>As best befits her wounded reputation,</LINE>
-<LINE>In some reclusive and religious life,</LINE>
-<LINE>Out of all eyes, tongues, minds and injuries.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Signior Leonato, let the friar advise you:</LINE>
-<LINE>And though you know my inwardness and love</LINE>
-<LINE>Is very much unto the prince and Claudio,</LINE>
-<LINE>Yet, by mine honour, I will deal in this</LINE>
-<LINE>As secretly and justly as your soul</LINE>
-<LINE>Should with your body.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>LEONATO</SPEAKER>
-<LINE>Being that I flow in grief,</LINE>
-<LINE>The smallest twine may lead me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>FRIAR FRANCIS</SPEAKER>
-<LINE>'Tis well consented: presently away;</LINE>
-<LINE>For to strange sores strangely they strain the cure.</LINE>
-<LINE>Come, lady, die to live: this wedding-day</LINE>
-<LINE>Perhaps is but prolong'd: have patience and endure.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt all but BENEDICK and BEATRICE</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Lady Beatrice, have you wept all this while?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Yea, and I will weep a while longer.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I will not desire that.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You have no reason; I do it freely.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Surely I do believe your fair cousin is wronged.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Ah, how much might the man deserve of me that would right her!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Is there any way to show such friendship?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>A very even way, but no such friend.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>May a man do it?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>It is a man's office, but not yours.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I do love nothing in the world so well as you: is</LINE>
-<LINE>not that strange?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>As strange as the thing I know not. It were as</LINE>
-<LINE>possible for me to say I loved nothing so well as</LINE>
-<LINE>you: but believe me not; and yet I lie not; I</LINE>
-<LINE>confess nothing, nor I deny nothing. I am sorry for my cousin.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>By my sword, Beatrice, thou lovest me.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Do not swear, and eat it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>I will swear by it that you love me; and I will make</LINE>
-<LINE>him eat it that says I love not you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Will you not eat your word?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>With no sauce that can be devised to it. I protest</LINE>
-<LINE>I love thee.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Why, then, God forgive me!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>What offence, sweet Beatrice?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You have stayed me in a happy hour: I was about to</LINE>
-<LINE>protest I loved you.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>And do it with all thy heart.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I love you with so much of my heart that none is</LINE>
-<LINE>left to protest.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Come, bid me do any thing for thee.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Kill Claudio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Ha! not for the wide world.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You kill me to deny it. Farewell.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Tarry, sweet Beatrice.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>I am gone, though I am here: there is no love in</LINE>
-<LINE>you: nay, I pray you, let me go.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Beatrice,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>In faith, I will go.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>We'll be friends first.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>You dare easier be friends with me than fight with mine enemy.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Is Claudio thine enemy?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Is he not approved in the height a villain, that</LINE>
-<LINE>hath slandered, scorned, dishonoured my kinswoman? O</LINE>
-<LINE>that I were a man! What, bear her in hand until they</LINE>
-<LINE>come to take hands; and then, with public</LINE>
-<LINE>accusation, uncovered slander, unmitigated rancour,</LINE>
-<LINE>--O God, that I were a man! I would eat his heart</LINE>
-<LINE>in the market-place.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Hear me, Beatrice,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Talk with a man out at a window! A proper saying!</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Nay, but, Beatrice,--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Sweet Hero! She is wronged, she is slandered, she is undone.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Beat--</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Princes and counties! Surely, a princely testimony,</LINE>
-<LINE>a goodly count, Count Comfect; a sweet gallant,</LINE>
-<LINE>surely! O that I were a man for his sake! or that I</LINE>
-<LINE>had any friend would be a man for my sake! But</LINE>
-<LINE>manhood is melted into courtesies, valour into</LINE>
-<LINE>compliment, and men are only turned into tongue, and</LINE>
-<LINE>trim ones too: he is now as valiant as Hercules</LINE>
-<LINE>that only tells a lie and swears it. I cannot be a</LINE>
-<LINE>man with wishing, therefore I will die a woman with grieving.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Tarry, good Beatrice. By this hand, I love thee.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Use it for my love some other way than swearing by it.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Think you in your soul the Count Claudio hath wronged Hero?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BEATRICE</SPEAKER>
-<LINE>Yea, as sure as I have a thought or a soul.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BENEDICK</SPEAKER>
-<LINE>Enough, I am engaged; I will challenge him. I will</LINE>
-<LINE>kiss your hand, and so I leave you. By this hand,</LINE>
-<LINE>Claudio shall render me a dear account. As you</LINE>
-<LINE>hear of me, so think of me. Go, comfort your</LINE>
-<LINE>cousin: I must say she is dead: and so, farewell.</LINE>
-</SPEECH>
-
-
-<STAGEDIR>Exeunt</STAGEDIR>
-</SCENE>
-
-<SCENE><TITLE>SCENE II. A prison.</TITLE>
-<STAGEDIR>Enter DOGBERRY, VERGES, and Sexton, in gowns; and
-the Watch, with CONRADE and BORACHIO</STAGEDIR>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Is our whole dissembly appeared?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>O, a stool and a cushion for the sexton.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Sexton</SPEAKER>
-<LINE>Which be the malefactors?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Marry, that am I and my partner.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>VERGES</SPEAKER>
-<LINE>Nay, that's certain; we have the exhibition to examine.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>Sexton</SPEAKER>
-<LINE>But which are the offenders that are to be</LINE>
-<LINE>examined? let them come before master constable.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Yea, marry, let them come before me. What is your</LINE>
-<LINE>name, friend?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Borachio.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Pray, write down, Borachio. Yours, sirrah?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<LINE>I am a gentleman, sir, and my name is Conrade.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Write down, master gentleman Conrade. Masters, do</LINE>
-<LINE>you serve God?</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>CONRADE</SPEAKER>
-<SPEAKER>BORACHIO</SPEAKER>
-<LINE>Yea, sir, we hope.</LINE>
-</SPEECH>
-
-<SPEECH>
-<SPEAKER>DOGBERRY</SPEAKER>
-<LINE>Write down, that they hope they serve God: and</LINE>
-<LINE>write God first; for God defend but God should go</LINE>
-<LINE>before such villains! Masters, it is proved already</LINE>