* xmlTextWriterOutputNSDecl: * @writer: the xmlTextWriterPtr * * Output the current namespace declarations. */
| 4330 | * Output the current namespace declarations. |
| 4331 | */ |
| 4332 | static int |
| 4333 | xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer) |
| 4334 | { |
| 4335 | xmlLinkPtr lk; |
| 4336 | xmlTextWriterNsStackEntry *np; |
| 4337 | int count; |
| 4338 | int sum; |
| 4339 | |
| 4340 | sum = 0; |
| 4341 | while (!xmlListEmpty(writer->nsstack)) { |
| 4342 | xmlChar *namespaceURI = NULL; |
| 4343 | xmlChar *prefix = NULL; |
| 4344 | |
| 4345 | lk = xmlListFront(writer->nsstack); |
| 4346 | np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk); |
| 4347 | |
| 4348 | if (np != 0) { |
| 4349 | namespaceURI = xmlStrdup(np->uri); |
| 4350 | prefix = xmlStrdup(np->prefix); |
| 4351 | } |
| 4352 | |
| 4353 | xmlListPopFront(writer->nsstack); |
| 4354 | |
| 4355 | if (np != 0) { |
| 4356 | count = xmlTextWriterWriteAttribute(writer, prefix, namespaceURI); |
| 4357 | xmlFree(namespaceURI); |
| 4358 | xmlFree(prefix); |
| 4359 | |
| 4360 | if (count < 0) { |
| 4361 | xmlListDelete(writer->nsstack); |
| 4362 | writer->nsstack = NULL; |
| 4363 | return -1; |
| 4364 | } |
| 4365 | sum += count; |
| 4366 | } |
| 4367 | } |
| 4368 | return sum; |
| 4369 | } |
| 4370 | |
| 4371 | /** |
| 4372 | * xmlFreeTextWriterNsStackEntry: |
no test coverage detected