File format ideas

Frank Osterfeld <[email protected]> Mon, 5 Apr 2004 17:49:36 +0200
Newsgroups gmane.comp.kde.devel.knowit
Message-ID <[email protected]>
Here are some ideas about a new file format.

The requirements that came to my mind:

- format should contain a header for information about the author, a general 
description etc.

- Every node should have an unique ID, which makes it easy to link notes 
without ambiguity.

- Other properties a node could have: title, a keyword list, creation and 
modification dates, icon, state (opened/closed), child nodes, attached links

- The actual node data should be flexible, so it can be used for arbitrary 
kind of notes, for example text notes, mindmaps, ... (different note types 
could be supported by different plugins).


Below, there is a first idea for an XML format (definitions for DTD at the 
bottom). 

Nodes are organized tree-like:
<node>
 ... 
  <node> 
  </node>
</node>

Another idea is to organize them in a flat list and link them via <child> 
elements or similar, but then you have to find the root node(s), you have to 
ensure that it is a proper tree without loops etc.

The "p" (or any other letter, _, etc.) prefix for IDs seems to be necessary, I 
read that the XML type "ID" doesn't allows digits at the beginning (seems to 
be similar to C/C++/Java identifiers). The p could be omitted in the program 
and rest converted to a long variable.

The actual node data is encapsulated in a CDATA tag, so the note's HTML is not 
interpreted as Markup by the XML parser but passed to Knowit. Depending on 
the "type"-value Knowit could pass it to a Text editor or a Mind Map plugin 
for instance.

-------------------------------------------------------------------------------
<knowit_document version="0.9">
  <head>
    <author>John Doe</author>
    <description>My KnowIt file</description>
    <selected_node idref="p1"/> 
  </head>

  <collection>

    <node id="p0" state="opened">
    <date_created>20030402</date_created>
      <date_modified>20030405</date_modified>
      <title>Title</title>
      <keywords>keyword1, keyword2, ..., keywordn</keywords>
      <icon width="32" height="32">dunno.png</icon>
      <child idref="p1"/>
      <link type="knowitlink" target="p2">
        This is a link to another node in this document
      </link>    
      <link type="url" target="http://knowit.sourceforge.net/">
        The KnowIt website
      </link>    
      <data type="textnote">
        <![CDATA[<html>..<body><p>The actual note text</p></body></html>]]>
      </data>

      <node id="p1" state="closed"> <!-- child node -->
      ...
      </node>
    </node>
    <node id="p3" state="closed"> 
    ...
    </node>

  </collection>

</knowit_document>

-------------------------------------------------------------------------------

<!ELEMENT knowit_document (head, collection)>
<!ATTLIST knowit_document version CDATA #REQUIRED>
<!ELEMENT head (author, description)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT selected_node EMPTY>
<!ATTLIST selected_node idref IDREF #IMPLIED>
<!ELEMENT collection (node*)>
<!ELEMENT node (date_created, date_modified, title, keywords?, icon?, link*, 
data, node*)>
<!ATTLIST node id ID #REQUIRED>
<!ATTLIST node state (opened | closed) "closed">
<!ELEMENT icon (#PCDATA)>
<!ATTLIST icon width CDATA #IMPLIED>
<!ATTLIST icon height CDATA #IMPLIED>
<!ELEMENT date_created (#PCDATA)>
<!ELEMENT date_modified (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT keywords (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ATTLIST link type CDATA #REQUIRED>
<!ATTLIST link target CDATA #REQUIRED>
<!ELEMENT data (#CDATA)> 
<!ATTLIST data type CDATA #REQUIRED>


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click