Class: Meteor::Ml::Xml::ParserImpl
- Inherits:
-
Core::Kernel
- Object
- Parser
- Core::Kernel
- Meteor::Ml::Xml::ParserImpl
- Defined in:
- lib/meteor.rb,
lib/meteor.rb
Overview
XML parser (XMLパーサ)
Constant Summary
- PATTERN_UNESCAPE =
'&(amp|quot|apos|gt|lt);'- TABLE_FOR_ESCAPE_ =
{ '&' => '&', '"' => '"', '\'' => ''', '<' => '<', '>' => '>', }
- PATTERN_ESCAPE =
'[&\"\'<>]'- @@pattern_unescape =
Regexp.new(PATTERN_UNESCAPE)
- @@pattern_escape =
Regexp.new(PATTERN_ESCAPE)
- @@pattern_and_1 =
Regexp.new(AND_1)
- @@pattern_lt_1 =
Regexp.new(LT_1)
- @@pattern_gt_1 =
Regexp.new(GT_1)
- @@pattern_dq_1 =
Regexp.new(DOUBLE_QUATATION)
- @@pattern_ap_1 =
Regexp.new(AP_1)
- @@pattern_lt_2 =
Regexp.new(LT_2)
- @@pattern_gt_2 =
Regexp.new(GT_2)
- @@pattern_dq_2 =
Regexp.new(QO_2)
- @@pattern_ap_2 =
Regexp.new(AP_2)
- @@pattern_and_2 =
Regexp.new(AND_2)
Constants inherited from Core::Kernel
AND_1, AND_2, AND_3, AP_1, AP_2, AP_3, ATTR_EQ, CLEAN_1, CLEAN_2, DOUBLE_QUATATION, EMPTY, EN_1, ERASE_ATTR_1, ESCAPE_ENTITY_REF, GET_ATTRS_MAP, GET_ATTR_1, GT_1, GT_2, GT_3, LT_1, LT_2, LT_3, MODE, MODE_AF, MODE_BF, MODE_UTF8, PATTERN_FIND_1, PATTERN_FIND_2_1, PATTERN_FIND_2_2, PATTERN_FIND_2_3, PATTERN_FIND_3, PATTERN_FIND_4, PATTERN_FIND_5, QO_2, QO_3, SEARCH_CX_1, SEARCH_CX_2, SEARCH_CX_3, SEARCH_CX_4, SEARCH_CX_5, SEARCH_CX_6, SET_ATTR_1, SET_CX_1, SET_CX_2, SET_CX_3, SET_CX_4, SET_MONO_1, SPACE, TAG_CLOSE, TAG_CLOSE3, TAG_OPEN, TAG_OPEN3, TAG_SEARCH_1_1, TAG_SEARCH_1_2, TAG_SEARCH_1_3, TAG_SEARCH_1_4, TAG_SEARCH_1_4_2, TAG_SEARCH_2_1, TAG_SEARCH_2_1_2, TAG_SEARCH_2_2, TAG_SEARCH_2_2_2, TAG_SEARCH_2_3, TAG_SEARCH_2_3_2, TAG_SEARCH_2_3_2_2, TAG_SEARCH_2_4, TAG_SEARCH_2_4_2, TAG_SEARCH_2_4_2_2, TAG_SEARCH_2_4_2_3, TAG_SEARCH_2_4_3, TAG_SEARCH_2_4_3_2, TAG_SEARCH_2_4_4, TAG_SEARCH_2_6, TAG_SEARCH_2_7, TAG_SEARCH_3_1, TAG_SEARCH_3_1_2, TAG_SEARCH_3_1_2_2, TAG_SEARCH_3_2, TAG_SEARCH_3_2_2, TAG_SEARCH_3_2_2_2, TAG_SEARCH_4_1, TAG_SEARCH_4_2, TAG_SEARCH_4_3, TAG_SEARCH_4_4, TAG_SEARCH_4_5, TAG_SEARCH_4_6, TAG_SEARCH_4_7, TAG_SEARCH_4_7_2, TAG_SEARCH_NC_1_1, TAG_SEARCH_NC_1_2, TAG_SEARCH_NC_1_3, TAG_SEARCH_NC_1_4, TAG_SEARCH_NC_1_4_2, TAG_SEARCH_NC_2_1, TAG_SEARCH_NC_2_1_2, TAG_SEARCH_NC_2_2, TAG_SEARCH_NC_2_2_2, TAG_SEARCH_NC_2_3, TAG_SEARCH_NC_2_3_2, TAG_SEARCH_NC_2_3_2_2, TAG_SEARCH_NC_2_4, TAG_SEARCH_NC_2_4_2, TAG_SEARCH_NC_2_4_2_2, TAG_SEARCH_NC_2_4_2_3, TAG_SEARCH_NC_2_4_3, TAG_SEARCH_NC_2_4_3_2, TAG_SEARCH_NC_2_4_4, TAG_SEARCH_NC_2_6, TAG_SEARCH_NC_2_7, TAG_SEARCH_NC_3_1, TAG_SEARCH_NC_3_1_2, TAG_SEARCH_NC_3_1_2_2, TAG_SEARCH_NC_3_2, TAG_SEARCH_NC_3_2_2, TAG_SEARCH_NC_3_2_2_2
Constants inherited from Parser
HTML, HTML5, XHTML, XHTML5, XML
Instance Attribute Summary
Attributes inherited from Core::Kernel
doc_type, document_hook, element_cache, element_hook
Instance Method Summary (collapse)
-
- (Streing) content_type
get content type (コンテントタイプを取得する).
- - (Object) escape(content)
-
- (ParserImpl) initialize(*args)
constructor
initializer (イニシャライザ).
-
- (Object) parse(document)
set document in parser (ドキュメントをパーサにセットする).
-
- (Object) read(file_path, encoding)
read file , set in parser (ファイルを読み込み、パーサにセットする).
Methods inherited from Core::Kernel
#attr, #attr_map, #character_encoding, #character_encoding=, #content, #create_element_pattern, #cxtag, #document, #document=, #element, #execute, #find, #flush, #remove_element, #root_element, #shadow
Constructor Details
- (ParserImpl) initialize - (ParserImpl) initialize(ps)
initializer (イニシャライザ)
4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 |
# File 'lib/meteor.rb', line 4737 def initialize(*args) super() @doc_type = Parser::XML case args.length when ZERO initialize_0 when ONE initialize_1(args[0]) else raise ArgumentError end end |
Instance Method Details
- (Streing) content_type
get content type (コンテントタイプを取得する)
4789 4790 4791 |
# File 'lib/meteor.rb', line 4789 def content_type() @root.content_type end |
- (Object) escape(content)
4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 |
# File 'lib/meteor.rb', line 4794 def escape(content) #特殊文字の置換 #「&」->「&」 if content.include?(AND_1) then content.gsub!(@@pattern_and_1, AND_2) end #「<」->「<」 if content.include?(LT_1) then content.gsub!(@@pattern_lt_1, LT_2) end #「>」->「>」 if content.include?(GT_1) then content.gsub!(@@pattern_gt_1, GT_2) end #「"」->「"」 if content.include?(DOUBLE_QUATATION) then content.gsub!(@@pattern_dq_1, QO_2) end #「'」->「'」 if content.include?(AP_1) then content.gsub!(@@pattern_ap_1, AP_2) end content end |
- (Object) parse(document)
set document in parser (ドキュメントをパーサにセットする)
4773 4774 4775 |
# File 'lib/meteor.rb', line 4773 def parse(document) @root.document = document end |
- (Object) read(file_path, encoding)
read file , set in parser (ファイルを読み込み、パーサにセットする)
4782 4783 4784 |
# File 'lib/meteor.rb', line 4782 def read(file_path, encoding) super(file_path, encoding) end |