Hi,

as the dumpbdb.pl script has now been added to the source tree, here
are patches for some small changes I've made so far:
* Use print instead of printf when printing unformatted values
* Proper NAD handling
* Write text, xml and unknown data as <![CDATA[]]>
* add private entries, NADs and more vcard entries to the
load-mysql.xslt example file.

Please apply.

I would have opened a ticket for this, bur for some reason I can't
anymore:

Error: Forbidden

TICKET_CREATE privileges are required to perform this operation

Regards,
harry
diff --git a/dumpbdb.pl b/dumpbdb.pl
index 4272734..e5e54a5 100755
--- a/dumpbdb.pl
+++ b/dumpbdb.pl
@@ -8,7 +8,6 @@
 # The DB file given on the command line is dumped as an XML file to stdout. 
 #
 # NB:
-# - NADs are not parsed
 # - integer types are hard-coded to be 4 bytes LSB
 #
 # (c) 2007 Harald Braumann <[EMAIL PROTECTED]>
@@ -116,18 +115,16 @@ sub dump_fields {
         } elsif ($type eq "boolean") {
             printf("%s", get_int([EMAIL PROTECTED]) > 0 ? "1" : "0");
         } elsif ($type eq "string") {
-            printf(get_string([EMAIL PROTECTED]));
+            print("<![CDATA[".get_string([EMAIL PROTECTED])."]]>");
         } elsif ($type eq "nad") {
-            trc("warn: `nad\' type found. don't know how to parse!");
-            printf(join('', @value));
-            $#value = 0;
+            print("<![CDATA[".get_string([EMAIL PROTECTED])."]]>");
         } elsif ($type eq "unknown") {
             trc("warn: `unknown\' type found. don't know how to parse!");
-            printf(join('', @value));
+            print("<![CDATA[".join('', @value)."]]>");
             $#value = 0;
         } else {
             trc("warn: unknown type found!");
-            printf(join('', @value));
+            print("<![CDATA[".join('', @value)."]]>");
             $#value = 0;
         }            
         printf("</$field>\n");
diff --git a/load-mysql.xslt b/load-mysql.xslt
index e39f4b7..3f29647 100644
--- a/load-mysql.xslt
+++ b/load-mysql.xslt
@@ -28,8 +28,18 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 
   <xsl:text>-- DB: `privacy-default` .. not implemented</xsl:text>
   <xsl:text>-- DB: `privacy-items` .. not implemented</xsl:text>
-  <xsl:text>-- DB: `private` .. not implemented</xsl:text>
-  <xsl:text>-- DB: `queue` .. not implemented</xsl:text>
+
+  <xsl:text>-- DB: `private`</xsl:text>
+  <xsl:for-each select="private/entry">
+    INSERT INTO `private`(`collection-owner`, `ns`, `xml`)
+           VALUES('<xsl:value-of select="@key"/>', '<xsl:value-of select="ns"/>', "NAD<xsl:value-of select="xml"/>");
+  </xsl:for-each>
+
+  <xsl:text>-- DB: `queue`</xsl:text>
+  <xsl:for-each select="queue/entry">
+    INSERT INTO `queue`(`collection-owner`, `xml`)
+           VALUES('<xsl:value-of select="@key"/>', "NAD<xsl:value-of select="xml"/>");
+  </xsl:for-each>
 
   <xsl:text>-- DB: `roster-groups`</xsl:text>
   <xsl:for-each select="roster-groups/entry">
@@ -48,8 +58,13 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 
   <xsl:text>-- DB: `vcard`</xsl:text>
   <xsl:for-each select="vcard/entry">
-    INSERT INTO `vcard` (`collection-owner`, `fn`, `nickname`)
-           VALUES('<xsl:value-of select="@key"/>', '<xsl:value-of select="fn"/>', '<xsl:value-of select="nickname"/>');
+    INSERT INTO `vcard` (`collection-owner`, `fn`, `nickname`, `email`, `org-orgname`, `bday`, `role`, 
+                         `n-given`, `n-family`, `tel`)
+           VALUES('<xsl:value-of select="@key"/>', '<xsl:value-of select="fn"/>', '<xsl:value-of select="nickname"/>',
+                  '<xsl:value-of select="email"/>', '<xsl:value-of select="org-orgname"/>', 
+                  '<xsl:value-of select="bday"/>', '<xsl:value-of select="role"/>', 
+                  '<xsl:value-of select="n-given"/>', '<xsl:value-of select="n-family"/>', 
+                  '<xsl:value-of select="tel"/>');
   </xsl:for-each>
 
 

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Jabberd2 mailing list
[email protected]
http://lists.xiaoka.com/listinfo.cgi/jabberd2-xiaoka.com

Reply via email to