跳至內容 跳至搜尋

類別會在使用 SAX 事件解析 XML 文件時建立 hash。

方法
C
E
S

常數

CONTENT_KEY = "__content__"
 
HASH_SIZE_KEY = "__hash_size__"
 

屬性

[R] hash

執行個體公開方法

cdata_block(字串)

別名:characters

characters(字串)

另外別名:cdata_block
# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 61
def characters(string)
  current_hash[CONTENT_KEY] << string
end

current_hash()

# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 24
def current_hash
  @hash_stack.last
end

end_document()

# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 33
def end_document
  raise "Parse stack not empty!" if @hash_stack.size > 1
end

end_element(名稱)

# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 54
def end_element(name)
  if current_hash.length > current_hash.delete(HASH_SIZE_KEY) && current_hash[CONTENT_KEY].blank? || current_hash[CONTENT_KEY] == ""
    current_hash.delete(CONTENT_KEY)
  end
  @hash_stack.pop
end

error(錯誤訊息)

# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 37
def error(error_message)
  raise error_message
end

start_document()

# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 28
def start_document
  @hash = {}
  @hash_stack = [@hash]
end