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

Function xmlTextWriterStartElementNS

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:1045–1100  ·  view source on GitHub ↗

* xmlTextWriterStartElementNS: * @writer: the xmlTextWriterPtr * @prefix: namespace prefix or NULL * @name: element local name * @namespaceURI: namespace URI or NULL * * Start an xml element with namespace support. * * Returns the bytes written (may be 0 because of buffering) or -1 in case of error */

Source from the content-addressed store, hash-verified

1043 * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
1044 */
1045int
1046xmlTextWriterStartElementNS(xmlTextWriterPtr writer,
1047 const xmlChar * prefix, const xmlChar * name,
1048 const xmlChar * namespaceURI)
1049{
1050 int count;
1051 int sum;
1052 xmlChar *buf;
1053
1054 if ((writer == NULL) || (name == NULL) || (*name == '\0'))
1055 return -1;
1056
1057 buf = NULL;
1058 if (prefix != 0) {
1059 buf = xmlStrdup(prefix);
1060 buf = xmlStrcat(buf, BAD_CAST ":");
1061 }
1062 buf = xmlStrcat(buf, name);
1063
1064 sum = 0;
1065 count = xmlTextWriterStartElement(writer, buf);
1066 xmlFree(buf);
1067 if (count < 0)
1068 return -1;
1069 sum += count;
1070
1071 if (namespaceURI != 0) {
1072 xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *)
1073 xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
1074 if (p == 0) {
1075 xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
1076 "xmlTextWriterStartElementNS : out of memory!\n");
1077 return -1;
1078 }
1079
1080 buf = xmlStrdup(BAD_CAST "xmlns");
1081 if (prefix != 0) {
1082 buf = xmlStrcat(buf, BAD_CAST ":");
1083 buf = xmlStrcat(buf, prefix);
1084 }
1085
1086 p->prefix = buf;
1087 p->uri = xmlStrdup(namespaceURI);
1088 if (p->uri == 0) {
1089 xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
1090 "xmlTextWriterStartElementNS : out of memory!\n");
1091 xmlFree(p);
1092 return -1;
1093 }
1094 p->elem = xmlListFront(writer->nodes);
1095
1096 xmlListPushFront(writer->nsstack, p);
1097 }
1098
1099 return sum;
1100}
1101
1102/**

Callers 1

Calls 6

xmlStrdupFunction · 0.85
xmlStrcatFunction · 0.85
xmlWriterErrMsgFunction · 0.85
xmlListFrontFunction · 0.85
xmlListPushFrontFunction · 0.85

Tested by

no test coverage detected