lib/masterview/analyzer.rb in masterview-0.3.2 vs lib/masterview/analyzer.rb in masterview-0.3.3
- old
+ new
@@ -108,10 +108,11 @@
def initialize( options = {} )
@depth = 0
@stack = []
@list = []
+ @prolog = [] # prolog if any
@content = options[:content_hash] || {}
@options = options
@only_check_hash = options[:only_check_hash] || false
@builder = Builder.new(@content)
@default_extname = options[:default_extname] || ::MasterView::IOMgr.erb.default_extension
@@ -144,11 +145,18 @@
def start_document
#todo
end
def doctype(name, pub_sys, long_name, uri)
- #todo
+ xml_doctype = []
+ xml_doctype << '<!DOCTYPE'
+ xml_doctype << name
+ xml_doctype << pub_sys unless pub_sys.nil?
+ xml_doctype << %Q["#{long_name}"] unless long_name.nil?
+ xml_doctype << %Q["#{uri}"] unless uri.nil?
+ doctype_str = xml_doctype.join(' ')+'>'
+ @prolog << doctype_str
end
def start_element(uri, localname, qname, attributes)
unescape_attributes!(attributes)
@depth += 1
@@ -239,9 +247,13 @@
def store_last_buffer(end_element)
unless @stack.empty?
@stack.last.inc_parts
index = end_element ? -1 : @stack.last.parts-1
data = @stack.last.buffer.join
+ unless @prolog.empty?
+ data = @prolog.join + data
+ @prolog = []
+ end
hash_invalid = false;
if @stack.last.import
if only_check_hash?
hash = src_hash(data)
bdata = @builder.data(@stack.last.name, index)