MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlTextWriterEndElement

Function xmlTextWriterEndElement

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:1110–1192  ·  view source on GitHub ↗

* xmlTextWriterEndElement: * @writer: the xmlTextWriterPtr * * End the current xml element. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */

Source from the content-addressed store, hash-verified

1108 * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
1109 */
1110int
1111xmlTextWriterEndElement(xmlTextWriterPtr writer)
1112{
1113 int count;
1114 int sum;
1115 xmlLinkPtr lk;
1116 xmlTextWriterStackEntry *p;
1117
1118 if (writer == NULL)
1119 return -1;
1120
1121 lk = xmlListFront(writer->nodes);
1122 if (lk == 0) {
1123 xmlListDelete(writer->nsstack);
1124 writer->nsstack = NULL;
1125 return -1;
1126 }
1127
1128 p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
1129 if (p == 0) {
1130 xmlListDelete(writer->nsstack);
1131 writer->nsstack = NULL;
1132 return -1;
1133 }
1134
1135 sum = 0;
1136 switch (p->state) {
1137 case XML_TEXTWRITER_ATTRIBUTE:
1138 count = xmlTextWriterEndAttribute(writer);
1139 if (count < 0) {
1140 xmlListDelete(writer->nsstack);
1141 writer->nsstack = NULL;
1142 return -1;
1143 }
1144 sum += count;
1145 /* fallthrough */
1146 case XML_TEXTWRITER_NAME:
1147 /* Output namespace declarations */
1148 count = xmlTextWriterOutputNSDecl(writer);
1149 if (count < 0)
1150 return -1;
1151 sum += count;
1152
1153 if (writer->indent) /* next element needs indent */
1154 writer->doindent = 1;
1155 count = xmlOutputBufferWriteString(writer->out, "/>");
1156 if (count < 0)
1157 return -1;
1158 sum += count;
1159 break;
1160 case XML_TEXTWRITER_TEXT:
1161 if ((writer->indent) && (writer->doindent)) {
1162 count = xmlTextWriterWriteIndent(writer);
1163 sum += count;
1164 writer->doindent = 1;
1165 } else
1166 writer->doindent = 1;
1167 count = xmlOutputBufferWriteString(writer->out, "</");

Callers 3

xmlTextWriterEndDocumentFunction · 0.85

Calls 8

xmlListFrontFunction · 0.85
xmlListDeleteFunction · 0.85
xmlLinkGetDataFunction · 0.85
xmlTextWriterWriteIndentFunction · 0.85
xmlListPopFrontFunction · 0.85

Tested by

no test coverage detected