* xmlTextWriterStartDocumentCallback: * @ctx: the user data (XML parser context) * * called at the start of document processing. */
| 4528 | * called at the start of document processing. |
| 4529 | */ |
| 4530 | static void |
| 4531 | xmlTextWriterStartDocumentCallback(void *ctx) |
| 4532 | { |
| 4533 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 4534 | xmlDocPtr doc; |
| 4535 | |
| 4536 | #ifdef LIBXML_HTML_ENABLED |
| 4537 | if (ctxt->html) { |
| 4538 | if (ctxt->myDoc == NULL) |
| 4539 | ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL); |
| 4540 | if (ctxt->myDoc == NULL) { |
| 4541 | xmlCtxtErrMemory(ctxt); |
| 4542 | return; |
| 4543 | } |
| 4544 | } else |
| 4545 | #endif |
| 4546 | { |
| 4547 | doc = ctxt->myDoc; |
| 4548 | if (doc == NULL) |
| 4549 | doc = ctxt->myDoc = xmlNewDoc(ctxt->version); |
| 4550 | if (doc != NULL) { |
| 4551 | if (doc->children == NULL) { |
| 4552 | if (ctxt->encoding != NULL) |
| 4553 | doc->encoding = xmlStrdup(ctxt->encoding); |
| 4554 | else |
| 4555 | doc->encoding = NULL; |
| 4556 | doc->standalone = ctxt->standalone; |
| 4557 | } |
| 4558 | } else { |
| 4559 | xmlCtxtErrMemory(ctxt); |
| 4560 | return; |
| 4561 | } |
| 4562 | } |
| 4563 | if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) && |
| 4564 | (ctxt->input != NULL) && (ctxt->input->filename != NULL)) { |
| 4565 | ctxt->myDoc->URL = |
| 4566 | xmlCanonicPath((const xmlChar *) ctxt->input->filename); |
| 4567 | if (ctxt->myDoc->URL == NULL) |
| 4568 | ctxt->myDoc->URL = |
| 4569 | xmlStrdup((const xmlChar *) ctxt->input->filename); |
| 4570 | } |
| 4571 | } |
| 4572 | |
| 4573 | /** |
| 4574 | * xmlTextWriterSetIndent: |
nothing calls this directly
no test coverage detected