Changes

Jump to: navigation, search

Generate XML

378 bytes added, 01:07, 12 February 2013
m
Why doesn't Gramps just use a .gz extension?: http://www.libreoffice.org/download
[[Category:How do I...]]{{languages}}== GRAMPS Gramps and XML ==
GRAMPS Gramps is capable of importing and exporting an [[Gramps XML|XML file ]] that contains all the information in the database. This file is useful for transferring data from one machine to another or for XML processing.
=== Generating XML ===
The easiest way to generate an XML file is to export the data. This can be done from the Filemenu: {{man menu|Family Trees->Export }} or {{man menu|Family Trees->Backup...}}. This will generate a file with a <ttcode>.gramps</ttcode> extension. This file is usually a gzip'd XML file (depending on some system settings, sometimes this will be an uncompressed XML file).
GRAMPS Gramps compresses the file because XML files can become rather large. For large databases, this file could grow to 10s to 100s of megabytes in size. Fortunately, XML files compress nicely, usually producing a fairly small size.
=== How do I tell if the XML file is compressed? ===
The easiest way is to run the <ttcode>file</ttcode> command on it.
$ file data.gramps
$ gunzip < data.gramps > data.xml
This example creates an uncompressed <ttcode>data.xml</ttcode> file from the compressed <ttcode>data.gramps</ttcode> file.
You must use the I/O redirection operators (">" and "<"), since <ttcode>gzip</ttcode> expects files to have a <ttcode>.gz</ttcode> extension.
=== I am confused. How do I extract editable XML from .gramps file? ===
You may download and run [[Media:Gramps2xml.gz|<code>gramps2xml</code> ]] script.# First make it executable: <code>chmod +x gramps2xml</code># Then run it like so: <code>./gramps2xml filename.gramps filename.xml</code>
== Why doesn't GRAMPS Gramps just use a .gz extension? ==
GRAMPS Gramps uses the [http://freedesktop.org/wiki/Software/shared-mime-info Shared Mime System] defined by [http://freedesktop.org Free Desktop] project, and used by all major desktops, including KDE and GNOME. GRAMPS Gramps relies on the MIME type identified by the Shared Mime System to determine the file type of the file.
The Share Mime System allows you to identify a file's type by either using a file extension or by looking at the contents of a small section of the file. The first problem is, usually the filename or extension pattern has the higher priority compared to the contents: if the file is named <code>something.jpg</code> then it is likely to be JPEG image, not text. So if the GRAMPS Gramps XML file had added <code>.gz</code> extension to the name, the Shared Mime system would tell us that the file's type is <code>application/x-gzip</code> instead of the expected <code>application/x-gramps-xml</code>. Unfortunately, it cannot tell us that it is a gzip'd GRAMPS Gramps XML file.
The second problem is, if we looked at the contents, we would not be able to tell the difference between a gzip'd GRAMPS Gramps XML file or any other gzip'd file. If we looked at uncompressed data, we would not be able to tell the difference between a GRAMPS Gramps XML file and other XML files. So again, the Shared Mime system could not tell us that it is a gzip'd GRAMPS Gramps XML file.
For these reasons, we must rely on the <code>.gramps</code> extension. If we don't, we would not be able to tell if this was a valid file. Even worse, the mime type of <code>application/x-gzip</code> would be associated with another application (such as File Roller or Ark) instead of GRAMPSGramps. The mime type of <code>application/xml</code> may be associated with XML editors (Bluefish, Conglomerate, Emacs, etc). In that situation, the user double-clicking on the file in the file manager (or performing the default action for the type by any other means) will never launch GRAMPS Gramps with this data,
GRAMPS Gramps is not unique in this problem. For example, the OpenDocument format used by [http://www.libreoffice.org/download LibreOffice], OpenOffice, KWord StarOffice, [http://www.calligra-suite.org/ Calligra] and AbiWord is actually a collection of files in a <ttcode>zip</ttcode> archive. If you run <ttcode>unzip</ttcode> on a OpenDocument file, you will see something like:
$ unzip test.odt
inflating: styles.xml
inflating: content.xml
 
== Sample ==
 
[http://www.cohsoft.com.au/tmg2gramps/ tmg2gramps] is a program written to convert a family tree from The Master Genealogist V6 to Gramps XML.
 
 
[[Category:How do I...]]

Navigation menu