[yelp: 4/4] [libyelp/yelp-docbook-document] Fixes for DB5 IDs and titles



commit b09d1fc3de5cbd1bfe18c07044d9be4f725cf7ba
Author: Shaun McCance <shaunm gnome org>
Date:   Fri May 21 18:24:07 2010 -0500

    [libyelp/yelp-docbook-document] Fixes for DB5 IDs and titles

 libyelp/yelp-docbook-document.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/libyelp/yelp-docbook-document.c b/libyelp/yelp-docbook-document.c
index 7463033..bb083d3 100644
--- a/libyelp/yelp-docbook-document.c
+++ b/libyelp/yelp-docbook-document.c
@@ -352,6 +352,9 @@ docbook_process (YelpDocbookDocument *docbook)
     priv->xmlcur = xmlDocGetRootElement (xmldoc);
 
     id = xmlGetProp (priv->xmlcur, BAD_CAST "id");
+    if (!id)
+        id = xmlGetNsProp (priv->xmlcur, XML_XML_NAMESPACE, BAD_CAST "id");
+
     if (id) {
         priv->root_id = g_strdup (id);
         yelp_document_set_page_id (document, NULL, (gchar *) id);
@@ -366,7 +369,12 @@ docbook_process (YelpDocbookDocument *docbook)
         yelp_document_set_next_id (document, "//about", "//index");
         /* add the id attribute to the root element with value "index"
          * so when we try to load the document later, it doesn't fail */
-        xmlNewProp (priv->xmlcur, BAD_CAST "id", BAD_CAST "//index");
+        if (priv->xmlcur->ns)
+            xmlNewNsProp (priv->xmlcur,
+                          xmlNewNs (priv->xmlcur, XML_XML_NAMESPACE, BAD_CAST "xml"),
+                          BAD_CAST "id", BAD_CAST "//index");
+        else
+            xmlNewProp (priv->xmlcur, BAD_CAST "id", BAD_CAST "//index");
     }
     yelp_document_set_root_id (document, priv->root_id, priv->root_id);
     yelp_document_set_root_id (document, "//about", priv->root_id);
@@ -478,13 +486,23 @@ docbook_walk (YelpDocbookDocument *docbook)
                 }
 
     id = xmlGetProp (priv->xmlcur, BAD_CAST "id");
+    if (!id)
+        id = xmlGetNsProp (priv->xmlcur, XML_XML_NAMESPACE, BAD_CAST "id");
 
     if (docbook_walk_divisionQ (docbook) && !id) {
         /* If id attribute is not present, autogenerate a
          * unique value, and insert it into the in-memory tree */
         g_snprintf (autoidstr, 20, "//autoid-%d", ++autoid);
-        xmlNewProp (priv->xmlcur, BAD_CAST "id", BAD_CAST autoidstr);
-        id = xmlGetProp (priv->xmlcur, BAD_CAST "id"); 
+        if (priv->xmlcur->ns) {
+            xmlNewNsProp (priv->xmlcur,
+                          xmlNewNs (priv->xmlcur, XML_XML_NAMESPACE, BAD_CAST "xml"),
+                          BAD_CAST "id", BAD_CAST autoidstr);
+            id = xmlGetNsProp (priv->xmlcur, XML_XML_NAMESPACE, BAD_CAST "id");
+        }
+        else {
+            xmlNewProp (priv->xmlcur, BAD_CAST "id", BAD_CAST autoidstr);
+            id = xmlGetProp (priv->xmlcur, BAD_CAST "id"); 
+        }
     }
 
     if (docbook_walk_chunkQ (docbook)) {
@@ -681,6 +699,8 @@ docbook_walk_get_title (YelpDocbookDocument *docbook)
             }
             else if (!xmlStrcmp (child->name, BAD_CAST "title"))
                 title_tmp = child;
+            else if (!xmlStrcmp (child->name, BAD_CAST "info"))
+                infos[0] = child;
             else if (!xmlStrcmp (child->name, BAD_CAST infoname))
                 infos[0] = child;
             else if (!xmlStrcmp (child->name, BAD_CAST "blockinfo"))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]