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

Function xmlNewTextWriterTree

ThirdParty/libxml2/vtklibxml2/xmlwriter.c:411–457  ·  view source on GitHub ↗

* xmlNewTextWriterTree: * @doc: xmlDocPtr * @node: xmlNodePtr or NULL for doc->children * @compression: compress the output? * * Create a new xmlNewTextWriter structure with @doc as output * starting at @node * * Returns the new xmlTextWriterPtr or NULL in case of error */

Source from the content-addressed store, hash-verified

409 * Returns the new xmlTextWriterPtr or NULL in case of error
410 */
411xmlTextWriterPtr
412xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression)
413{
414 xmlTextWriterPtr ret;
415 xmlSAXHandler saxHandler;
416 xmlParserCtxtPtr ctxt;
417
418 if (doc == NULL) {
419 xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
420 "xmlNewTextWriterTree : invalid document tree!\n");
421 return NULL;
422 }
423
424 memset(&saxHandler, '\0', sizeof(saxHandler));
425 xmlSAX2InitDefaultSAXHandler(&saxHandler, 1);
426 saxHandler.startDocument = xmlTextWriterStartDocumentCallback;
427 saxHandler.startElement = xmlSAX2StartElement;
428 saxHandler.endElement = xmlSAX2EndElement;
429
430 ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL);
431 if (ctxt == NULL) {
432 xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
433 "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
434 return NULL;
435 }
436 /*
437 * For some reason this seems to completely break if node names
438 * are interned.
439 */
440 ctxt->dictNames = 0;
441
442 ret = xmlNewTextWriterPushParser(ctxt, compression);
443 if (ret == NULL) {
444 xmlFreeParserCtxt(ctxt);
445 xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
446 "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
447 return NULL;
448 }
449
450 ctxt->myDoc = doc;
451 ctxt->node = node;
452 ret->no_doc_free = 1;
453
454 xmlSetDocCompressMode(doc, compression);
455
456 return ret;
457}
458
459/**
460 * xmlFreeTextWriter:

Callers

nothing calls this directly

Calls 6

xmlWriterErrMsgFunction · 0.85
xmlCreatePushParserCtxtFunction · 0.85
xmlFreeParserCtxtFunction · 0.85
xmlSetDocCompressModeFunction · 0.85

Tested by

no test coverage detected