* xmlTextWriterStartAttribute: * @writer: the xmlTextWriterPtr * @name: element name * * Start an xml attribute. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */
| 1752 | * Returns the bytes written (may be 0 because of buffering) or -1 in case of error |
| 1753 | */ |
| 1754 | int |
| 1755 | xmlTextWriterStartAttribute(xmlTextWriterPtr writer, const xmlChar * name) |
| 1756 | { |
| 1757 | int count; |
| 1758 | int sum; |
| 1759 | xmlLinkPtr lk; |
| 1760 | xmlTextWriterStackEntry *p; |
| 1761 | |
| 1762 | if ((writer == NULL) || (name == NULL) || (*name == '\0')) |
| 1763 | return -1; |
| 1764 | |
| 1765 | sum = 0; |
| 1766 | lk = xmlListFront(writer->nodes); |
| 1767 | if (lk == 0) |
| 1768 | return -1; |
| 1769 | |
| 1770 | p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk); |
| 1771 | if (p == 0) |
| 1772 | return -1; |
| 1773 | |
| 1774 | switch (p->state) { |
| 1775 | case XML_TEXTWRITER_ATTRIBUTE: |
| 1776 | count = xmlTextWriterEndAttribute(writer); |
| 1777 | if (count < 0) |
| 1778 | return -1; |
| 1779 | sum += count; |
| 1780 | /* fallthrough */ |
| 1781 | case XML_TEXTWRITER_NAME: |
| 1782 | count = xmlOutputBufferWriteString(writer->out, " "); |
| 1783 | if (count < 0) |
| 1784 | return -1; |
| 1785 | sum += count; |
| 1786 | count = |
| 1787 | xmlOutputBufferWriteString(writer->out, |
| 1788 | (const char *) name); |
| 1789 | if (count < 0) |
| 1790 | return -1; |
| 1791 | sum += count; |
| 1792 | count = xmlOutputBufferWriteString(writer->out, "="); |
| 1793 | if (count < 0) |
| 1794 | return -1; |
| 1795 | sum += count; |
| 1796 | count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar); |
| 1797 | if (count < 0) |
| 1798 | return -1; |
| 1799 | sum += count; |
| 1800 | p->state = XML_TEXTWRITER_ATTRIBUTE; |
| 1801 | break; |
| 1802 | default: |
| 1803 | return -1; |
| 1804 | } |
| 1805 | |
| 1806 | return sum; |
| 1807 | } |
| 1808 | |
| 1809 | /** |
| 1810 | * xmlTextWriterStartAttributeNS: |
no test coverage detected