Difference between revisions of "New Freeplane File Format (Proposal)"

From Freeplane - free mind mapping and knowledge management software
(document structure up to 3.10)
m (3.10: add note about config:type possible values)
Line 164: Line 164:
 
     [...]
 
     [...]
 
  </office:settings>
 
  </office:settings>
 +
 +
; Note : as described in chapter 19.32, The values of the config:type attribute are boolean, short, int, long, double, string, datetime or base64Binary.
  
 
TBD
 
TBD

Revision as of 13:14, 10 April 2010

This page is work in progress and not endorsed in any way (yet) by the Freeplane team as a whole Discussion happens on the developers' mailing list ⇐


Introduction

Freeplane version 1.0.x (and 1.1.x) was developed using FreeMind's format and file extension (.mm) in an effort to allow a smooth transition to users willing to switch to Freeplane. As Freeplane grows mature and wants to make true its Visions, a new file format is required.

File types and extensions.

A Freeplane file can come in 4 flavors, as single XML document file or as package:

  1. Single XML document:
    1. a plain XML format with extension .freeplane.
      This format allows further for easy automated generation and XSLT transformation.
    2. the above format in a standard ZIP or JAR file, i.e. if a file named myfile.freeplane.zip or myfile.freeplane.jar contains a file named myfile.freeplane, it will be opened by Freeplane in the same way as the above plain XML format (other files in the same archive will be ignored).
      The file format is still easy to generate but takes less space than plain XML, is cleaner to email (some mailers choke on text formats) and can be used to transport other files (even though they will be ignored by Freeplane).
  2. Package Document:
    1. a more complex zipped format with extension .freeplanez.
      This format allows for embedded styles, images and other 3rd party objects.
    2. the same structure but in an uncompressed directory with extension .freeplane.d.

Overall, the XML format is the same in all flavors, and aligned (as much as possible) with the Open Document Format from the OASIS organization.

File format requirements

  1. clean XML
  2. multiple maps per file possible
  3. easy generation
  4. embedding of 3rd party objects
  5. support real styles
  6. allow for comparison between different files
  7. allow for tracked changes

Generic rules

  1. Each XML file must start with an XML declaration <?xml version="1.0" encoding="UTF-8" ?> .
    • this means that the Freeplane format is based on XML 1.0 and has UTF-8 as encoding.
    • (X)HTML entities are not used anymore for accentuated characters but just plain UTF-8 encoding.
  2. A single XML document may continue with an XSLT reference like <?xml-stylesheet type="application/xslt+xml" href="url-to-some-XHTML-transformation-sheet"?> as to allow web browsers to render directly Freeplane files.
  3. All XML markups are in small caps and must have an explicit namespace
  4. The namespace must be declared either as xmlns:attribute of the root element of the XML file, or, if rendered by a plug-in, as xmlns:attribute of the XML element rendered by this plug-in
    Example 
    if a node has the xmlns attribute <map:node xmlns:myplug="myplug-namespace" ...>[...], Freeplane could find an OSGi service NodeRenderer with a filter based on the given namespace to render this specific node.
  5. The namespace for Freeplane specific elements is xmlns:map="http://freeplane.org/formats/map-2010".
  6. Until further notice, all formatting elements are based on XHTML 1.0/1.1 and have the namespace xmlns:xhtml="http://www.w3.org/1999/xhtml".
    • SimplyHTML must be adapted accordingly, and perhaps released as OSGi bundle!?

Format Specifics

(structure aligned with version 1.2 of the Open Document Format)

Part 1 - XML File Format

1 - Introduction

1.1 to 1.4 - no changes

1.5 - Namespaces

We stick to the same namespaces wherever applicable, and add the following one:

Table 6 - Freeplane namespaces
Prefix Description Namespace
map For all Freeplane specific elements http://freeplane.org/formats/map-2010

2 - Scope (not relevant)

3 - Document Structure

3.1 Document Representation

3.1.2 <office:document>(Single OpenDocument XML Files)

A typical single opendocument might look as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="application/xslt+xml" href="http://freeplane.org/formats/map-2010/to-xhtml10.xsl" ?>
<office:document office:mimetype="application/x-freeplane" office:version="1.2-fp-1.0" xmlns:[...]>
  <office:automatic-styles> [...] </office:automatic-styles>
  <office:body>             [...] </office:body>
  <office:font-face-decls>  [...] </office:font-face-decls>
  <office:master-styles>    [...] </office:master-styles>
  <office:meta>             [...] </office:meta>
  <office:scripts>          [...] </office:scripts>
  <office:settings>         [...] </office:settings>
  <office:styles>           [...] </office:styles>
</office:document>
Notes 
Once Freeplane has a registered mime-type, mimetype could become application/freeplane. The version is made of the ODF version 1.2, 'fp' for Freeplane and an internal version number, 1.0 to start with.
3.1.3 Package OpenDocument Files

File content.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<office:document-content office:version="1.2-fp-1.0" xmlns:[...]>
  <office:automatic-styles> [...] </office:automatic-styles>
  <office:body>             [...] </office:body>
  <office:font-face-decls>  [...] </office:font-face-decls>
  <office:scripts>          [...] </office:scripts>
</office:document>

File styles.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<office:document-styles office:version="1.2-fp-1.0" xmlns:[...]>
  <office:automatic-styles> [...] </office:automatic-styles>
  <office:font-face-decls>  [...] </office:font-face-decls>
  <office:master-styles>    [...] </office:master-styles>
  <office:styles>           [...] </office:styles>
</office:document>

File meta.xml:

<?xml version="1.0" office:version="1.2-fp-1.0" encoding="UTF-8" ?>
<office:document-meta xmlns:[...]>
  <office:meta>             [...] </office:meta>
</office:document>

File settings.xml:

<?xml version="1.0" office:version="1.2-fp-1.0" encoding="UTF-8" ?>
<office:document-settings xmlns:[...]>
  <office:settings>         [...] </office:settings>
</office:document>

3.2 <office:meta>

Section can and should be used as-is. No changes needed.

⇒ Freeplane should offer a dialog to enter document information.

3.3 <office:body>

Mandatory section, but only child needed is a Freeplane specific <x-office:map>.

Note 
x-office is used instead of office to avoid polluting the 'office' namespace. x-office can be used as an alternative prefix for the same Freeplane namespace as 'map'.

3.4 to 3.9 not needed, replaced by <x-office:map>

<x-office:map> can contain one or more <map:map> element, each representing what is currently the root element of a .mm map (with of course necessary adaptations, e.g. <map:node> instead of <node>).

TBD 
describe in more details the possible content of a map.

3.10 <office:settings>

Section can and should be used as-is. No changes needed.

Possibly Freeplane doesn't need the full scope and could cope only with config-item-set and config-item as in:

<office:settings>
  <config:config-item-set config:name="somename">
    <config:config-item config:name="itemname" config:type="itemtype">
      ConfigValue
    </config:config-item>
    [...]
  </config:config-item-set>
  <config:config-item-set config:name="someothername">
    [...]
</office:settings>
Note 
as described in chapter 19.32, The values of the config:type attribute are boolean, short, int, long, double, string, datetime or base64Binary.

TBD

Part 2 - OpenFormula

not applicable (yet?)

Part 3 - Packages

TBD