* xmlDtdDumpOutput: * @buf: the XML buffer output * @dtd: the pointer to the DTD * * Dump the XML document DTD, if any. */
| 934 | * Dump the XML document DTD, if any. |
| 935 | */ |
| 936 | static void |
| 937 | xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) { |
| 938 | xmlOutputBufferPtr buf; |
| 939 | xmlNodePtr cur; |
| 940 | int format, level; |
| 941 | |
| 942 | if (dtd == NULL) return; |
| 943 | if ((ctxt == NULL) || (ctxt->buf == NULL)) |
| 944 | return; |
| 945 | buf = ctxt->buf; |
| 946 | xmlOutputBufferWrite(buf, 10, "<!DOCTYPE "); |
| 947 | xmlOutputBufferWriteString(buf, (const char *)dtd->name); |
| 948 | if (dtd->ExternalID != NULL) { |
| 949 | xmlOutputBufferWrite(buf, 8, " PUBLIC "); |
| 950 | xmlOutputBufferWriteQuotedString(buf, dtd->ExternalID); |
| 951 | xmlOutputBufferWrite(buf, 1, " "); |
| 952 | xmlOutputBufferWriteQuotedString(buf, dtd->SystemID); |
| 953 | } else if (dtd->SystemID != NULL) { |
| 954 | xmlOutputBufferWrite(buf, 8, " SYSTEM "); |
| 955 | xmlOutputBufferWriteQuotedString(buf, dtd->SystemID); |
| 956 | } |
| 957 | if ((dtd->entities == NULL) && (dtd->elements == NULL) && |
| 958 | (dtd->attributes == NULL) && (dtd->notations == NULL) && |
| 959 | (dtd->pentities == NULL)) { |
| 960 | xmlOutputBufferWrite(buf, 1, ">"); |
| 961 | return; |
| 962 | } |
| 963 | xmlOutputBufferWrite(buf, 3, " [\n"); |
| 964 | /* |
| 965 | * Dump the notations first they are not in the DTD children list |
| 966 | * Do this only on a standalone DTD or on the internal subset though. |
| 967 | */ |
| 968 | if ((dtd->notations != NULL) && ((dtd->doc == NULL) || |
| 969 | (dtd->doc->intSubset == dtd))) { |
| 970 | xmlBufDumpNotationTable(buf, (xmlNotationTablePtr) dtd->notations); |
| 971 | } |
| 972 | format = ctxt->format; |
| 973 | level = ctxt->level; |
| 974 | ctxt->format = 0; |
| 975 | ctxt->level = -1; |
| 976 | for (cur = dtd->children; cur != NULL; cur = cur->next) { |
| 977 | xmlNodeDumpOutputInternal(ctxt, cur); |
| 978 | } |
| 979 | ctxt->format = format; |
| 980 | ctxt->level = level; |
| 981 | xmlOutputBufferWrite(buf, 2, "]>"); |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * xmlAttrDumpOutput: |
no test coverage detected