| 586 | |
| 587 | |
| 588 | void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) |
| 589 | { |
| 590 | if (!_nsContextPushed) |
| 591 | _namespaces.pushContext(); |
| 592 | _nsContextPushed = false; |
| 593 | ++_elementCount; |
| 594 | |
| 595 | declareAttributeNamespaces(attributes); |
| 596 | |
| 597 | writeMarkup(MARKUP_LT); |
| 598 | if (!localName.empty() && (qname.empty() || localName == qname)) |
| 599 | { |
| 600 | XMLString prefix; |
| 601 | if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) |
| 602 | { |
| 603 | prefix = uniquePrefix(); |
| 604 | _namespaces.declarePrefix(prefix, namespaceURI); |
| 605 | } |
| 606 | else prefix = _namespaces.getPrefix(namespaceURI); |
| 607 | writeName(prefix, localName); |
| 608 | } |
| 609 | else if (namespaceURI.empty() && localName.empty() && !qname.empty()) |
| 610 | { |
| 611 | writeXML(qname); |
| 612 | } |
| 613 | else if (!localName.empty() && !qname.empty()) |
| 614 | { |
| 615 | XMLString local; |
| 616 | XMLString prefix; |
| 617 | Name::split(qname, prefix, local); |
| 618 | if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); |
| 619 | const XMLString& uri = _namespaces.getURI(prefix); |
| 620 | if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) |
| 621 | { |
| 622 | _namespaces.declarePrefix(prefix, namespaceURI); |
| 623 | } |
| 624 | writeName(prefix, localName); |
| 625 | } |
| 626 | else throw XMLException("Tag mismatch", nameToString(localName, qname)); |
| 627 | |
| 628 | AttributeMap attributeMap; |
| 629 | addNamespaceAttributes(attributeMap); |
| 630 | addAttributes(attributeMap, attributes, namespaceURI); |
| 631 | writeAttributes(attributeMap); |
| 632 | _unclosedStartTag = true; |
| 633 | } |
| 634 | |
| 635 | |
| 636 | void XMLWriter::writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) |
nothing calls this directly
no test coverage detected