Method: WAX#start
- Defined in:
- lib/wax.rb
#start(p1, p2 = nil) ⇒ Object
Writes the start tag for a given element name, but doesn’t terminate it. If one parameter is specified, it is the element name. If two parameters are specified, they are prefix and name.
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/wax.rb', line 472 def start(p1, p2=nil) if (p2 == nil) # only specified element name prefix, name = nil, p1 else # specified element namespace prefix, name and text prefix, name = p1, p2 end @has_content = @has_indented_content = true terminate_start @has_content = false if @check_me bad_state("start") if @state == :after_root if prefix != nil XMLUtil.verify_name(prefix) @pending_prefixes << prefix end XMLUtil.verify_name(name) end # If this is the root element ... write_doctype(name) if @state == :in_prolog # Can't add to pendingPrefixes until # previous start tag has been terminated. @pending_prefixes << prefix if @check_me and prefix != nil write_indent if @parent_stack.size > 0 has_prefix = prefix != nil and prefix.length > 0 qname = has_prefix ? prefix + ':' + name : name if (@in_commented_start) out '<!--' + qname # Add a "marker" to the element name on the stack # so the end method knows to terminate the comment. @parent_stack.push('-' + qname) else out '<' + qname @parent_stack.push(qname) end # No namespace prefixes have been associated with this element yet. @prefixes_stack.push(nil) @state = :in_start_tag self end |