writeNamespaces writes xmlns attributes for all the namespace prefixes that have been defined in the current element.
()
| 458 | // namespace prefixes that have been defined in |
| 459 | // the current element. |
| 460 | func (p *printer) writeNamespaces() { |
| 461 | for i := len(p.prefixes) - 1; i >= 0; i-- { |
| 462 | prefix := p.prefixes[i] |
| 463 | if prefix.mark { |
| 464 | return |
| 465 | } |
| 466 | p.WriteString(" ") |
| 467 | if prefix.prefix == "" { |
| 468 | // Default name space. |
| 469 | p.WriteString(`xmlns="`) |
| 470 | } else { |
| 471 | p.WriteString("xmlns:") |
| 472 | p.WriteString(prefix.prefix) |
| 473 | p.WriteString(`="`) |
| 474 | } |
| 475 | EscapeText(p, []byte(p.nsForPrefix(prefix.prefix))) |
| 476 | p.WriteString(`"`) |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | // pushPrefix pushes a new prefix on the prefix stack |
| 481 | // without checking to see if it is already defined. |
no test coverage detected