Ruby 2.1.0 リファレンスマニュアル > ライブラリ一覧 > rexml/documentライブラリ > REXML::Entityクラス
クラス・モジュールの継承リスト: REXML::Entity < REXML::XMLTokens < REXML::Child < REXML::Node < Object < Kernel < BasicObject
XML における実体(エンティティ、entity)の宣言(declaration)を表わすクラス。
DTD(REXML::DocType)内の実体宣言に対応するものです。
require 'rexml/document'
doc = REXML::Document.new(<<EOS)
<!DOCTYPE document [
<!ENTITY f "foo bar baz">
<!ENTITY x SYSTEM "x.txt">
<!ENTITY y SYSTEM "y.png" NDATA PNG>
<!ENTITY % z "zzz">
<!ENTITY zz "%z;%z;&f;">
]>
EOS
entities = doc.doctype.entities
# f は 内部実体名なので、external や ref は nil である
p entities["f"].name # => "f"
p entities["f"].value # => "foo bar baz"
p entities["f"].external # => nil
p entities["f"].ref # => nil
# x は 外部実体名なので value が nil で、
# external や ref が文字列を返してくる。
# しかし解析対象実体(parsed entity)なので ndata は nil を返す
p entities["x"].name # => "x"
p entities["x"].value # => nil
p entities["x"].external # => "SYSTEM"
p entities["x"].ref # => "x.txt"
p entities["x"].ndata # => nil
# y は解析対象外実体(unparsed entity)なので ndata が記法名を返す
p entities["y"].ndata # => "PNG"
# zz は中にパラメータ実体参照と内部実体参照を含むので、
# value, unnormalized, normalized がすべて異なる値を返す
p entities["zz"].value # => "zzzzzz&f;"
p entities["zz"].unnormalized # => "zzzzzzfoo bar baz"
p entities["zz"].normalized # => "%z;%z;&f;"
定義 | 説明 | |
---|---|---|
matches?(string) -> bool
|
string が実体宣言の文法に従う文字列であれば真を返します。 |
|
new(name, value, parent=nil, reference=false) -> REXML::Entity
|
新たな Entity オブジェクトを生成して返します。 |
定義 | 説明 | |
---|---|---|
external -> String | nil
|
実体が外部実体(external entity)宣言である場合は "SYSTEM" もしくは "PUBLIC" という文字列を返します。 |
|
name -> String
|
実体の名前を返します。 |
|
ndata -> String | nil
|
解析対象外実体(unparsed entity)宣言である場合にはその記法名(notation name)を返します。 |
|
normalized -> String | nil
|
正規化された(normalized)実体の値を返します。 |
|
pubid -> String | nil
|
公開識別子(public identifier)を用いた外部実体宣言の場合は、その公開識別子を返します。 |
|
ref -> String | nil
|
外部実体(external entity)宣言の URI を返します。 |
|
to_s -> String
|
実体宣言を文字列化したものを返します。 |
|
unnormalized -> String | nil
|
非正規化された(unnormalized)実体の値を返します。 |
|
value -> String | nil
|
実体の値を返します。 |
|
write(out, indent = -1) -> ()
|
実体宣言を文字列化したものを out に書き込みます。 |
!
!=
__id__
__send__
instance_eval
instance_exec
method_missing
singleton_method_added
singleton_method_removed
singleton_method_undefined
!~
<=>
==
===
=~
_dump
class
clone
define_singleton_method
display
enum_for
eql?
equal?
extend
freeze
frozen?
hash
initialize
initialize_copy
inspect
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
itself
marshal_dump
marshal_load
method
methods
must_be
must_be_close_to
must_be_empty
must_be_instance_of
must_be_kind_of
must_be_nil
must_be_same_as
must_be_within_epsilon
must_equal
must_include
must_match
must_raise
must_respond_to
must_send
must_throw
nil?
object_id
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
psych_to_yaml
public_method
public_methods
public_send
remove_instance_variable
respond_to?
respond_to_missing?
send
singleton_class
singleton_method
singleton_methods
taint
tainted?
tap
to_a
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_str
trust
untaint
untrust
untrusted?
.yaml_tag
::ARGF
::ARGV
::DATA
::ENV
::FALSE
::NIL
::RUBY_COPYRIGHT
::RUBY_DESCRIPTION
::RUBY_ENGINE
::RUBY_PATCHLEVEL
::RUBY_PLATFORM
::RUBY_RELEASE_DATE
::RUBY_REVISION
::RUBY_VERSION
::SCRIPT_LINES__
::STDERR
::STDIN
::STDOUT
::TOPLEVEL_BINDING
::TRUE
bytes
document
next_sibling
next_sibling=
parent
parent=
previous_sibling
previous_sibling=
remove
replace_with