* htmlNodeDumpOutputInternal: * @cur: the current node * * Dump an HTML node, recursive behaviour, children are printed too. */
| 1029 | * Dump an HTML node, recursive behaviour, children are printed too. |
| 1030 | */ |
| 1031 | static int |
| 1032 | htmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { |
| 1033 | const xmlChar *oldenc = NULL; |
| 1034 | const xmlChar *oldctxtenc = ctxt->encoding; |
| 1035 | const xmlChar *encoding = ctxt->encoding; |
| 1036 | xmlOutputBufferPtr buf = ctxt->buf; |
| 1037 | int switched_encoding = 0; |
| 1038 | xmlDocPtr doc; |
| 1039 | |
| 1040 | xmlInitParser(); |
| 1041 | |
| 1042 | doc = cur->doc; |
| 1043 | if (doc != NULL) { |
| 1044 | oldenc = doc->encoding; |
| 1045 | if (ctxt->encoding != NULL) { |
| 1046 | doc->encoding = BAD_CAST ctxt->encoding; |
| 1047 | } else if (doc->encoding != NULL) { |
| 1048 | encoding = doc->encoding; |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | if ((encoding != NULL) && (doc != NULL)) |
| 1053 | htmlSetMetaEncoding(doc, (const xmlChar *) encoding); |
| 1054 | if ((encoding == NULL) && (doc != NULL)) |
| 1055 | encoding = htmlGetMetaEncoding(doc); |
| 1056 | if (encoding == NULL) |
| 1057 | encoding = BAD_CAST "HTML"; |
| 1058 | if ((encoding != NULL) && (oldctxtenc == NULL) && |
| 1059 | (buf->encoder == NULL) && (buf->conv == NULL)) { |
| 1060 | if (xmlSaveSwitchEncoding(ctxt, (const char*) encoding) < 0) { |
| 1061 | doc->encoding = oldenc; |
| 1062 | return(-1); |
| 1063 | } |
| 1064 | switched_encoding = 1; |
| 1065 | } |
| 1066 | if (ctxt->options & XML_SAVE_FORMAT) |
| 1067 | htmlNodeDumpFormatOutput(buf, doc, cur, |
| 1068 | (const char *)encoding, 1); |
| 1069 | else |
| 1070 | htmlNodeDumpFormatOutput(buf, doc, cur, |
| 1071 | (const char *)encoding, 0); |
| 1072 | /* |
| 1073 | * Restore the state of the saving context at the end of the document |
| 1074 | */ |
| 1075 | if ((switched_encoding) && (oldctxtenc == NULL)) { |
| 1076 | xmlSaveClearEncoding(ctxt); |
| 1077 | } |
| 1078 | if (doc != NULL) |
| 1079 | doc->encoding = oldenc; |
| 1080 | return(0); |
| 1081 | } |
| 1082 | #endif |
| 1083 | |
| 1084 | /** |
no test coverage detected