class Meteor::Ml::Xml::ParserImpl

XML parser (XMLパーサ)

Constants

KAIGYO_CODE

KAIGYO_CODE = “r?n|r”.freeze

PATTERN_ESCAPE
PATTERN_UNESCAPE
TABLE_FOR_ESCAPE_

Public Class Methods

new(*args) click to toggle source

initializer (イニシャライザ) @overload initialize @overload initialize(ps)

@param [Meteor::Parser] ps parser (パーサ)
Calls superclass method Meteor::Core::Kernel::new
# File lib/meteor.rb, line 5500
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

Public Instance Methods

content_type() click to toggle source

get content type (コンテントタイプを取得する) @return [String] conent type (コンテントタイプ)

# File lib/meteor.rb, line 5558
def content_type
  @root.content_type
end
parse() click to toggle source

parse document (ドキュメントを解析する)

# File lib/meteor.rb, line 5538
def parse
  analyze_ml
end

Private Instance Methods

analyze_kaigyo_code() click to toggle source

analuze document , set newline (ドキュメントをパースし、改行コードをセットする)

# File lib/meteor.rb, line 5565
def analyze_kaigyo_code
  #改行コード取得

  for a in KAIGYO_CODE
    if @root.document.include?(a)
      @root.kaigyo_code = a
      #puts "kaigyo:" << @root.kaigyo_code
    end
  end

end
analyze_ml() click to toggle source

analyze document (ドキュメントをパースする)

# File lib/meteor.rb, line 5545
def analyze_ml
  #改行コードの取得
  analyze_kaigyo_code

  @res = nil
end
escape(content) click to toggle source
# File lib/meteor.rb, line 5579
def escape(content)
  #特殊文字の置換
  content.gsub!(@@pattern_escape, TABLE_FOR_ESCAPE_)

  content
end
escape_content(*args) click to toggle source
# File lib/meteor.rb, line 5588
def escape_content(*args)
  escape(args[0])
end
initialize_1(ps) click to toggle source

initializer (イニシャライザ) @param [Meteor::Parser] ps parser (パーサ)

# File lib/meteor.rb, line 5527
def initialize_1(ps)
  @root.document = String.new(ps.document)
  ps.document_hook = String.new(ps.document_hook)
end
unescape(content) click to toggle source
# File lib/meteor.rb, line 5594
def unescape(content)
  #特殊文字の置換
  #「<」<-「&lt;」
  #「>」<-「&gt;」
  #「"」<-「&quot;」
  #「'」<-「&apos;」
  #「&」<-「&amp;」
  content.gsub(@@pattern_unescape) do
    case $1
      when AND_3
        AND_1
      when QO_3
        DOUBLE_QUATATION
      when AP_3
        AP_1
      when GT_3
        GT_1
      when LT_3
        LT_1
    end
  end

  content
end
unescape_content(*args) click to toggle source
# File lib/meteor.rb, line 5621
def unescape_content(*args)
  unescape(args[0])
end