<?xml version="1.0" encoding="ISO-8859-1"?>
<abiword version="Win32-nightly">
<!-- =====================================================================  -->
<!-- This file is an AbiWord document.                                      -->
<!-- AbiWord is a free, Open Source word processor.                         -->
<!-- You may obtain more information about AbiWord at www.abisource.com     -->
<!-- You should not edit this file by hand.                                 -->
<!-- =====================================================================  -->

<!--         Build_ID          = (none) -->
<!--         Build_Version     = Win32-nightly -->
<!--         Build_Options     = LicensedTrademarks:Off Debug:Off Pspell:Off -->
<!--         Build_Target      = /home/tom/nightly/abi/src/WIN32_1.1.4_i386_OBJ/obj -->
<!--         Build_CompileTime = 01:11:08 -->
<!--         Build_CompileDate = Jan  3 2001 -->

<lists>
<l id="20994" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="10222" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="2184" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="7955" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="25588" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="13687" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
</lists>
<section>
<p style="Heading 1" props="text-align:center">Importer/Exporter Overview</p>
<p style="Heading 3" props="text-align:center">(C) 2000 Dom Lachowicz</p>
<p style="Heading 3" props="text-align:center">cinamod@hotmail.com</p>
<p style="Heading 3" props="text-align:center">$DATE: January 3, 2001</p>
<p style="Heading 3" props="text-align:center"></p>
<p style="Normal"><c props="font-weight:bold">1. Introduction</c></p>
<p style="Normal"></p>
<p style="Normal"><c props="font-weight:normal">This document gives a general overview of AbiWord´s import/export facilities.  It is meant to be both a high-level overview of the code as well as a in-depth analysis of several key points and features.</c></p>
<p style="Normal"></p>
<p style="Normal"><c props="font-weight:bold">2. AbiWord´s Native File Format</c></p>
<p style="Normal"></p>
<p style="Normal"><c props="font-weight:normal">AbiWord´s native file format is XML-based.  This means that AbiWord´s file format shares much in common with other markup formats such as (X)HTML.  XML DTDs for the AbiWord format can be found at http://www.abisource.com/~sam/awml/</c></p>
<p style="Normal"></p>
<p style="Normal"><c props="font-weight:normal">When viewing the AbiWord DTD, you will see various entities and attributes.  These can be broken into two basic categories:</c></p>
<p level="1" listid="20994" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	Container Containers</c></p>
<p level="1" listid="20994" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	Data Containers</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">A container container (as the name implies) is merely a container which contains 1+ other containers.  An example of this is the fact that any AbiWord document may contain 1 or more sections.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">An example of a data container is the "c" entity tag.  The "&lt;c&gt;" tag contains a run of textual characters meant to be displayed by AbiWord.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p style="Normal"><c props="font-weight:normal">When examining these AbiWord DTDs, you will notice that many of the elements have a shared attribute - namely "</c><c props="font-weight:bold; text-decoration:underline">props</c><c props="font-weight:normal">."  It is inside of these props attributes that the actual formatting parameters are contained.  For example, the following line, when interpreted by AbiWord</c></p>
<p style="Normal"></p>
<p style="Normal" props="margin-left:0.5000in"><c props="font-weight:normal">&lt;c props="font-family:Courier New; font-size:14pt; font-style:italic; font-weight:bold"&gt;Bold Italic Courier New Size 14&lt;/c&gt;</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="font-weight:normal">produces the following output:</c></p>
<p style="Normal" props="margin-left:0.5000in"><c props="font-family:Courier New; font-size:14pt; font-style:italic; font-weight:bold">Bold Italic Courier New Size 14</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal">For an extensive list of what values can be contained inside of any element´s "props" tag, please consult either the AbiWord DTD or the MSWord importer.</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:bold">3. Why an input/ouput system?</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal">AbiWord is an excellent word processor, and its file format is an excellent representation of AbiWord´s capabilities and the expected capabilities of most modern word processors.  But AbiWord does not exist in a vacuum.  There are other viable WP offerings on the market.  A goal of AbiWord is to inter-operate with each of these other WPs as flawlessly and seamlessly as possible.  This is best achieved by being able to both read and write documents in other WPs native formats.</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal">Some applications treat their native format importers/exporters as somewhat "sacred."  By this I mean that they do not recognize their native importer/exporter as "just another" importer or exporter (take gnumeric, for example).  AbiWord does not do this - our ABW importer/exporter is treated as just another importer/exporter class, with the notable exception that it maps </c><c props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:bold; text-decoration:none; text-position:normal">extremely</c><c props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal"> well onto AbiWord´s internal structures with a minimum of fuss.</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in"><c props="font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:bold">4. The import (input) mechanism</c></p>
<p style="Normal" props="margin-left:0.0000in"></p>
<p style="Normal" props="margin-left:0.0000in">When creating an importer class, you must first override/extend the base <c props="font-style:italic">IE_Imp</c> class or a class that extends the <c props="font-style:italic">IE_Imp</c> baseclass.  After overriding the IE_Imp class, you must define several other methods:</p>
<p level="1" listid="10222" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">RecognizeSuffix(const char * szSuffix)</c></p>
<p level="1" listid="10222" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">StaticConstructor(PD_Document * pDocument,  IE_Imp ** ppie)</c></p>
<p level="1" listid="10222" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">SupportsFileType(IEFileType ft)</c></p>
<p level="1" listid="10222" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">GetDlgLabels(const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft)</c></p>
<p level="1" listid="10222" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">RecognizeContents(const char * szBuf, UT_uint32 iNumbytes)</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">The code required to implement these methods is extremely trivial, usually requiring (at most) a few lines of code. For example, the </c><c type="list_label" props="font-style:italic">RecognizeSuffix</c><c type="list_label"> method requires that you perform a case-insensitive comparison of the passed string and your filetype. For MSWord Documents, the code is: </c><c type="list_label" props="font-style:italic">`return (UT_stricmp (szSuffix, ".doc"));´</c><c type="list_label"> In most cases, you can cut-and-paste code from existing importers to implement these methods.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">After that, all that is required is that you implement the </c><c type="list_label" props="font-style:italic">`importFile(const char * szFilename)´</c><c type="list_label"> method.  The importFile method can utilize any number of other functions or methods to import the requested file.  It is assumed by this point that the passed </c><c type="list_label" props="font-style:italic">szFilename</c><c type="list_label"> probably represents your filetype.  If it does not, you can always return </c><c type="list_label" props="font-style:italic">UT_IE_BOGUSDOCUMENT</c><c type="list_label">, meaning that for some reason or another, your importer could not import the given document.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">All importers contain an abstraction class of AbiWord´s document - the </c><c type="list_label" props="font-style:italic">PD_Document</c><c type="list_label"> class-member </c><c type="list_label" props="font-style:italic">m_pDocument</c><c type="list_label">.  </c><c type="list_label" props="font-style:italic">m_pDocument</c><c type="list_label"> has several methods of great interest to us:</c></p>
<p level="1" listid="2184" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">appendFmt ()</c></p>
<p level="1" listid="2184" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">appendStrux ()</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">appendFmt appends the passed formatting properties to the current run of text.  These properties are expected to be identical to those contained/allowed in any AbiWord document.  For example:</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label"><pbr/></c><c type="list_label" props="font-style:italic">XML_Char * buf [3];</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">buf[0] = "props";</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">buf[1] = </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">"font-family:Courier New; font-size:14pt; font-style:italic; font-weight:bold";</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">buf[2] = NULL;</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">m_pDocument-&gt;appendFmt (buf);</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal">The </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">appendStrux()</c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal"> method is used to append a section or paragraph to a given document.  The first parameter is one of the enum </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">{ PTX_Section, PTX_Block };</c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal"> The second parameter is identical in nature to the </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">XML_Char ** buf</c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal"> used in </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">appendFmt ();</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c props="font-weight:bold">4.1 IE_Imp_XML: an exception</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal">A special case of an importer is an XML importer - that is, any class meant to import XML content.  Dom Lachowicz created an abstract </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">IE_Imp_XML</c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal"> baseclass which takes care of many of the necessary details needed to import an XML document.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal">The baseclass utilizes either the LibXML2 or the Expat XML library´s SAX parser to import documents.  In addition to the 5 methods listed above, the XML importer class expects two other methods to exist:</c></p>
<p level="1" listid="7955" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">_startElement (const XML_Char *name, const XML_Char **atts)</c></p>
<p level="1" listid="7955" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="font-style:italic">_endElement </c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">(const XML_Char *name, const XML_Char **atts)</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; text-decoration:none; text-position:normal">Additionally, the XML importer provides one function for writing data into AbiWord:</c></p>
<p level="1" listid="25588" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; list-decimal:.; list-delim:%L; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c type="list_label" props="color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; text-decoration:none; text-position:normal">_charData(const XML_Char *s, int len)</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label">The </c><c type="list_label" props="font-style:italic">_charData</c><c type="list_label" props="font-style:normal"> takes as parameters a string (</c><c type="list_label" props="font-style:italic">XML_Char *s</c><c type="list_label" props="font-style:normal">) and that string´s length (</c><c type="list_label" props="font-style:italic">len</c><c type="list_label" props="font-style:normal">).  It also tries to take into account if white space is significant or not (ABW is, HTML is not). From the source of </c><c type="list_label" props="font-style:italic">_charData</c><c type="list_label" props="font-style:normal">:</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">// parse UTF-8 text and convert to Unicode.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">// also take care of some white-space issues:</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">//    [] convert CRLF to SP.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">//    [] convert CR to SP.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c type="list_label" props="font-style:italic">//    [] convert LF to SP.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c props="font-family:Times New Roman; font-style:italic">_startElement</c><c props="font-family:Times New Roman; font-style:normal"> and </c><c props="font-family:Times New Roman; font-style:italic">_endElement</c><c props="font-family:Times New Roman; font-style:normal"> are called (respectively) whenever a starting or ending tag is encountered in your XML document.  Implementing these methods is extremely easy and makes writing an XML-based importer fairly simple. </c><c props="font-family:Times New Roman; font-style:italic">@name</c><c props="font-family:Times New Roman; font-style:normal"> represents the tag´s name (e.g.: "table") while </c><c props="font-family:Times New Roman; font-style:italic">@atts</c><c props="font-family:Times New Roman; font-style:normal"> represents any attributes that accompany that tag (e.g. "border=0 cellspacing=1 cellpadding=1").  Mapping these </c><c props="font-family:Times New Roman; font-style:italic">@name</c><c props="font-family:Times New Roman; font-style:normal"> tags to integer tokens is simplified (and sped-up) by using the </c><c props="font-family:Times New Roman; font-style:italic">mapNameToToken</c><c props="font-family:Times New Roman; font-style:normal"> function. See and XML-based importer for an example of usage.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c props="font-family:Times New Roman; font-style:normal; font-weight:bold">5. The export (output) mechanism</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c props="font-family:Times New Roman; font-style:normal; font-weight:normal">Writing an exporter is usually slightly more difficult that writing an importer, but many aspects of writing an exporter are similar to those learned by writing an importer.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; margin-left:0.0000in; start-value:1; text-decoration:none; text-indent:0.0000in; text-position:normal"><c props="font-family:Times New Roman; font-style:normal; font-weight:normal">Firstly, your importer must implement several (4) methods:</c></p>
<p level="1" listid="13687" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label" props="font-style:normal"></field><c type="list_label">	</c><c props="font-family:Times New Roman; font-style:italic; font-weight:normal">RecognizeSuffix(const char * szSuffix)</c></p>
<p level="1" listid="13687" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label" props="font-style:normal"></field><c type="list_label" props="font-style:normal">	</c><c props="font-family:Times New Roman; font-style:italic; font-weight:normal">StaticConstructor(PD_Document * pDocument, IE_Exp ** ppie)</c></p>
<p level="1" listid="13687" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label" props="font-style:normal"></field><c type="list_label">	</c><c props="font-family:Times New Roman; font-style:italic; font-weight:normal">SupportsFileType(IEFileType ft)</c></p>
<p level="1" listid="13687" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label" props="font-style:normal"></field><c type="list_label">	GetDlgLabels</c><c props="font-family:Times New Roman; font-style:italic; font-weight:normal">(const char ** pszDesc, const char ** pszSuffixList, IEFileType * ft)</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><c props="font-family:Times New Roman; font-style:normal; font-weight:normal">These should look familiar enough to not explain them.</c></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"></p>
<p level="0" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:italic; font-weight:normal; list-decimal:.; list-delim:%L.; margin-left:0.5000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><c props="font-family:Times New Roman; font-style:normal; font-weight:normal">[TODO]</c></p>
</section>
</abiword>

