Module | REXML
In: | temp/comment.rb temp/dtd/attlistdecl.rb temp/dtd/notationdecl.rb temp/dtd/elementdecl.rb temp/dtd/dtd.rb temp/dtd/entitydecl.rb temp/doctype.rb temp/encodings/UTF-8.rb temp/encodings/ISO-8859-15.rb temp/encodings/ISO-8859-1.rb temp/encodings/CP-1252.rb temp/encodings/UNILE.rb temp/encodings/US-ASCII.rb temp/encodings/SHIFT-JIS.rb temp/encodings/UTF-16.rb temp/encodings/EUC-JP.rb temp/encodings/ICONV.rb temp/validation/relaxng.rb temp/validation/validation.rb temp/validation/validationexception.rb temp/text.rb temp/rexml.rb temp/quickpath.rb temp/document.rb temp/xmldecl.rb temp/xpath.rb temp/child.rb temp/parsers/streamparser.rb temp/parsers/sax2parser.rb temp/parsers/lightparser.rb temp/parsers/treeparser.rb temp/parsers/xpathparser.rb temp/parsers/pullparser.rb temp/parsers/ultralightparser.rb temp/parsers/baseparser.rb temp/functions.rb temp/sax2listener.rb temp/light/node.rb temp/parseexception.rb temp/undefinednamespaceexception.rb temp/streamlistener.rb temp/namespace.rb temp/element.rb temp/node.rb temp/instruction.rb temp/cdata.rb temp/encoding.rb temp/attribute.rb temp/formatters/default.rb temp/formatters/transitive.rb temp/formatters/pretty.rb temp/syncenumerator.rb temp/xpath_parser.rb temp/xmltokens.rb temp/entity.rb temp/output.rb temp/source.rb temp/parent.rb temp/attlistdecl.rb

-*- mode: ruby; ruby-indent-level: 2; indent-tabs-mode: t; tab-width: 2 -*- vim: sw=2 ts=2

### Methods

<< <=> clone doctype empty? indent_text inspect new node_type parent= to_s value value= wrap write write_with_substitution xpath

### Classes and Modules

Module REXML::DTD
Module REXML::Encoding
Module REXML::EntityConst
Module REXML::Formatters
Module REXML::Functions
Module REXML::Light
Module REXML::Namespace
Module REXML::Node
Module REXML::Parsers
Module REXML::SAX2Listener
Module REXML::StreamListener
Module REXML::Validation
Module REXML::XMLTokens
Class REXML::AttlistDecl
Class REXML::Attribute
Class REXML::Attributes
Class REXML::CData
Class REXML::Child
Class REXML::Comment
Class REXML::Declaration
Class REXML::DocType
Class REXML::Document
Class REXML::Element
Class REXML::ElementDecl
Class REXML::Elements
Class REXML::Entity
Class REXML::ExternalEntity
Class REXML::IOSource
Class REXML::Instruction
Class REXML::NotationDecl
Class REXML::Output
Class REXML::Parent
Class REXML::ParseException
Class REXML::QuickPath
Class REXML::Source
Class REXML::SourceFactory
Class REXML::SyncEnumerator
Class REXML::Text
Class REXML::UndefinedNamespaceException
Class REXML::XMLDecl
Class REXML::XPath
Class REXML::XPathParser

### Constants

REFERENCE | = | /#{Entity::REFERENCE}/
EREFERENCE | = | /&(?!#{Entity::NAME};)/
COPYRIGHT | = | "Copyright ?? 2001-2008 Sean Russell <ser@germane-software.com>"
DATE | = | "2008/019"
VERSION | = | "3.1.7.3"
REVISION | = | "$Revision: 1304 $".gsub(/\$Revision:|\$/,'').strip
Copyright | = | COPYRIGHT
Version | = | VERSION

### Public Class methods

new(arg, respect_whitespace=false, parent=nil, raw=nil, entity_filter=nil, illegal=NEEDS_A_SECOND_CHECK )

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.

`pattern` INTERNAL USE ONLY

### Public Instance methods

<<( to_append )

Appends text to this text node. The text is appended in the `raw` mode of this text node.

<=>( other )

`other` a String or a Text `returns` the result of (to_s <=> arg.to_s)

clone()
doctype()
empty?()
indent_text(string, level=1, style="\t", indentfirstline=true)
inspect()
node_type()
parent=(parent)
to_s()

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"

value()

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"

value=( val )

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>

wrap(string, width, addnewline=false)
write( writer, indent=-1, transitive=false, ie_hack=false )

## DEPRECATED

See REXML::Formatters

write_with_substitution(out, input)

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

xpath()

FIXME This probably won‘t work properly

[Validate]