fixed a bug in the document extension element where the doctype infos were
authorDaniel Veillard <veillard@src.gnome.org>
Sun, 25 Nov 2001 14:54:08 +0000 (14:54 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sun, 25 Nov 2001 14:54:08 +0000 (14:54 +0000)
* libxslt/transform.c: fixed a bug in the document extension
  element where the doctype infos were not taken into account.
Daniel

ChangeLog
libxslt/transform.c

index 81392e6694e9adb44c669a9cf62517fea579e72a..f86fab5aef63693973a04f54f68a3675652c5320 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Nov 25 15:52:38 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/transform.c: fixed a bug in the document extension
+         element where the doctype infos were not taken into account.
+
 Thu Nov 22 19:08:23 CET 2001 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/extra.c: fixed xsltDebug() to output with the normal
index 2fa4eee5506308a4efaddb6cdfd419974bcdeab6..407c9bc11402f85d5e23a7ded05c0b4b55e8e585 100644 (file)
@@ -1489,7 +1489,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlChar *element, *end;
     xmlDocPtr res = NULL;
     xmlDocPtr oldOutput;
-    xmlNodePtr oldInsert;
+    xmlNodePtr oldInsert, root;
     const char *oldOutputFile;
     xsltOutputType oldType;
     xmlChar *URL = NULL;
@@ -1802,6 +1802,60 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
     ctxt->insert = (xmlNodePtr) res;
     xsltApplyOneTemplate(ctxt, node, inst->children, NULL, NULL);
 
+    /*
+     * Do some post processing work depending on the generated output
+     */
+    root = xmlDocGetRootElement(res);
+    if (root != NULL) {
+        /*
+         * Apply the default selection of the method
+         */
+        if ((method == NULL) &&
+            (root->ns == NULL) &&
+            (!xmlStrcasecmp(root->name, (const xmlChar *) "html"))) {
+            xmlNodePtr tmp;
+
+            tmp = res->children;
+            while ((tmp != NULL) && (tmp != root)) {
+                if (tmp->type == XML_ELEMENT_NODE)
+                    break;
+                if ((tmp->type == XML_TEXT_NODE) && (!xmlIsBlankNode(tmp)))
+                    break;
+               tmp = tmp->next;
+            }
+            if (tmp == root) {
+                ctxt->type = XSLT_OUTPUT_HTML;
+                res->type = XML_HTML_DOCUMENT_NODE;
+                if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                    res->intSubset = xmlCreateIntSubset(res, root->name,
+                                                        doctypePublic,
+                                                        doctypeSystem);
+               if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+                   res = htmlNewDoc(doctypeSystem, doctypePublic);
+#ifdef XSLT_GENERATE_HTML_DOCTYPE
+               } else if (version != NULL) {
+                    xsltGetHTMLIDs(version, &doctypePublic,
+                                   &doctypeSystem);
+                    if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                        res->intSubset =
+                            xmlCreateIntSubset(res, root->name,
+                                               doctypePublic,
+                                               doctypeSystem);
+#endif
+                }
+            }
+
+        }
+        if (ctxt->type == XSLT_OUTPUT_XML) {
+            XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
+                XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+                if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+                res->intSubset = xmlCreateIntSubset(res, root->name,
+                                                    doctypePublic,
+                                                    doctypeSystem);
+        }
+    }
+
     /*
      * Save the result
      */