blob: 91fd24d4f5c31792747d9c530a0a83c8e27ff71f [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="de">
<head>
<!-- Generated by javadoc (version 1.7.0_03) on Fri Feb 22 10:27:34 CET 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Overview (ODFDOM API v0.8.9-incubating - http://incubator.apache.org/odftoolkit/)</title>
<meta name="date" content="2013-02-22">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Overview (ODFDOM API v0.8.9-incubating - http://incubator.apache.org/odftoolkit/)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li class="navBarCell1Rev">Overview</li>
<li>Package</li>
<li>Class</li>
<li>Use</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?overview-summary.html" target="_top">Frames</a></li>
<li><a href="overview-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">ODFDOM</h1>
</div>
<div class="header">
<div class="subTitle">
<div class="block"><div class="wikiMainBody"><br />
The ODFDOM project's objective is to provide an easy API for reading, writing and manipulating documents of the OpenDocument format (ODF).</div>
</div>
<p>See: <a href="#overview_description">Description</a></p>
</div>
<div class="contentContainer">
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Packages table, listing packages, and an explanation">
<caption><span>Packages</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/package-summary.html">org.odftoolkit.odfdom</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/doc/package-summary.html">org.odftoolkit.odfdom.doc</a></td>
<td class="colLast">
<div class="block">The "Document Layer" exisit for usability reasons, it gives a feature based view on the document model.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/doc/presentation/package-summary.html">org.odftoolkit.odfdom.doc.presentation</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/doc/table/package-summary.html">org.odftoolkit.odfdom.doc.table</a></td>
<td class="colLast">
<div class="block">Provide convenient methods to manipulate table in ODF text and spreadsheet document.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/package-summary.html">org.odftoolkit.odfdom.dom</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/anim/package-summary.html">org.odftoolkit.odfdom.dom.attribute.anim</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/chart/package-summary.html">org.odftoolkit.odfdom.dom.attribute.chart</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/config/package-summary.html">org.odftoolkit.odfdom.dom.attribute.config</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/db/package-summary.html">org.odftoolkit.odfdom.dom.attribute.db</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/dr3d/package-summary.html">org.odftoolkit.odfdom.dom.attribute.dr3d</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/draw/package-summary.html">org.odftoolkit.odfdom.dom.attribute.draw</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/fo/package-summary.html">org.odftoolkit.odfdom.dom.attribute.fo</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/form/package-summary.html">org.odftoolkit.odfdom.dom.attribute.form</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/grddl/package-summary.html">org.odftoolkit.odfdom.dom.attribute.grddl</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/meta/package-summary.html">org.odftoolkit.odfdom.dom.attribute.meta</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/number/package-summary.html">org.odftoolkit.odfdom.dom.attribute.number</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/office/package-summary.html">org.odftoolkit.odfdom.dom.attribute.office</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/presentation/package-summary.html">org.odftoolkit.odfdom.dom.attribute.presentation</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/script/package-summary.html">org.odftoolkit.odfdom.dom.attribute.script</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/smil/package-summary.html">org.odftoolkit.odfdom.dom.attribute.smil</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/style/package-summary.html">org.odftoolkit.odfdom.dom.attribute.style</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/svg/package-summary.html">org.odftoolkit.odfdom.dom.attribute.svg</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/table/package-summary.html">org.odftoolkit.odfdom.dom.attribute.table</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/text/package-summary.html">org.odftoolkit.odfdom.dom.attribute.text</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/xforms/package-summary.html">org.odftoolkit.odfdom.dom.attribute.xforms</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/xhtml/package-summary.html">org.odftoolkit.odfdom.dom.attribute.xhtml</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/xlink/package-summary.html">org.odftoolkit.odfdom.dom.attribute.xlink</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/attribute/xml/package-summary.html">org.odftoolkit.odfdom.dom.attribute.xml</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/package-summary.html">org.odftoolkit.odfdom.dom.element</a></td>
<td class="colLast">
<div class="block">From the ODF RelaxNG generated Java classes representing the ODF elements</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/anim/package-summary.html">org.odftoolkit.odfdom.dom.element.anim</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/chart/package-summary.html">org.odftoolkit.odfdom.dom.element.chart</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/config/package-summary.html">org.odftoolkit.odfdom.dom.element.config</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/db/package-summary.html">org.odftoolkit.odfdom.dom.element.db</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/dc/package-summary.html">org.odftoolkit.odfdom.dom.element.dc</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/dr3d/package-summary.html">org.odftoolkit.odfdom.dom.element.dr3d</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/draw/package-summary.html">org.odftoolkit.odfdom.dom.element.draw</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/form/package-summary.html">org.odftoolkit.odfdom.dom.element.form</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/math/package-summary.html">org.odftoolkit.odfdom.dom.element.math</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/meta/package-summary.html">org.odftoolkit.odfdom.dom.element.meta</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/number/package-summary.html">org.odftoolkit.odfdom.dom.element.number</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/office/package-summary.html">org.odftoolkit.odfdom.dom.element.office</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/presentation/package-summary.html">org.odftoolkit.odfdom.dom.element.presentation</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/script/package-summary.html">org.odftoolkit.odfdom.dom.element.script</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/style/package-summary.html">org.odftoolkit.odfdom.dom.element.style</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/svg/package-summary.html">org.odftoolkit.odfdom.dom.element.svg</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/table/package-summary.html">org.odftoolkit.odfdom.dom.element.table</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/text/package-summary.html">org.odftoolkit.odfdom.dom.element.text</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/element/xforms/package-summary.html">org.odftoolkit.odfdom.dom.element.xforms</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/rdfa/package-summary.html">org.odftoolkit.odfdom.dom.rdfa</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/style/package-summary.html">org.odftoolkit.odfdom.dom.style</a></td>
<td class="colLast">
<div class="block">Provides classes to create and access ODF styles and ODF style families.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/dom/style/props/package-summary.html">org.odftoolkit.odfdom.dom.style.props</a></td>
<td class="colLast">
<div class="block">Classes representing the style properties.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/doc/draw/package-summary.html">org.odftoolkit.odfdom.incubator.doc.draw</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/doc/number/package-summary.html">org.odftoolkit.odfdom.incubator.doc.number</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/doc/office/package-summary.html">org.odftoolkit.odfdom.incubator.doc.office</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/doc/style/package-summary.html">org.odftoolkit.odfdom.incubator.doc.style</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/doc/text/package-summary.html">org.odftoolkit.odfdom.incubator.doc.text</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/meta/package-summary.html">org.odftoolkit.odfdom.incubator.meta</a></td>
<td class="colLast">
<div class="block">Provide classes to access the metadata of ODF documents.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/incubator/search/package-summary.html">org.odftoolkit.odfdom.incubator.search</a></td>
<td class="colLast">
<div class="block">Provide classes to operate the content and style of the selected text content.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/pkg/package-summary.html">org.odftoolkit.odfdom.pkg</a></td>
<td class="colLast">
<div class="block">Representing the "Package Layer", the physical document handling.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/pkg/dsig/package-summary.html">org.odftoolkit.odfdom.pkg.dsig</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/pkg/manifest/package-summary.html">org.odftoolkit.odfdom.pkg.manifest</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/pkg/rdfa/package-summary.html">org.odftoolkit.odfdom.pkg.rdfa</a></td>
<td class="colLast">&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="org/odftoolkit/odfdom/type/package-summary.html">org.odftoolkit.odfdom.type</a></td>
<td class="colLast">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
<div class="footer"><a name="overview_description">
<!-- -->
</a>
<div class="subTitle">
<div class="block"><div class="wikiMainBody"><p><br />
The ODFDOM project's objective is to provide an easy API for reading, writing and manipulating documents of the OpenDocument format (ODF).
</p><h1><a name='The_ODFDOM_Layers'></a>The ODFDOM Layers</h1>
<p>
<div id='toc' style='border:solid #DEDEDF 1px;background:#EEE;padding:10px;'>
<div id='toctitle' style='padding-bottom:5px;font-weight:bold;'>
<span>Contents</span>
</div>
<div id='toccontents' style='list-style-type:none;'><ul><li>1 <a href='#The_ODFDOM_Layers'>The ODFDOM Layers</a></li></
<ul><li>1.1 <a href='#The_ODF_Package_Layer'>The ODF Package Layer</a></li>
<ul><li>1.1.1 <a href='#The_ODF_Package_API'>The ODF Package API</a></li>
</ul><li>1.2 <a href='#The_ODF_XML_Layer'>The ODF XML Layer</a></li>
<ul><li>1.2.1 <a href='#The_ODF_DOM_API'>The ODF DOM API</a></li>
<li>1.2.2 <a href='#The_ODF_Document_API'>The ODF Document API</a></li>
</ul></ul></ul></div>
</div><p><br />
</p><h1><a name='The_ODFDOM_Layers'></a>The ODFDOM Layers</h1>
<p>
The ODFDOM project's objective is to provide an easy API for reading, writing and manipulating documents of the OpenDocument format (ODF).
To archive this, the ODFDOM API follows a layered approach to access documents, as layered design is the robust foundation for a well-designed modular structure.
</p><p><img src='doc-files/ODFDOM-Layered-Model.png' />
</p><h2><a name='The_ODF_Package_Layer'></a>The ODF Package Layer</h2>
<p>The ODF Package Layer provides access to all resources stored within the ODF package, such as XML streams, images or embedded objects.
</p><h3><a name='The_ODF_Package_API'></a>The ODF Package API</h3>
<p>The ODF Package API covers all features from the <a class='external' href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part3.html">third part of the ODF 1.2 specification</a> defining the ODF Package features. The ODF 1.2 package features are build on top technologies as <a class='external' href="http://www.pkware.com/documents/APPNOTE/APPNOTE_6.2.0.txt">ZIP package handling</a>, <a class='external' href="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/">W3C encryption</a>, <a class='external' href="http://www.w3.org/TR/2008/REC-xmldsig-core-20080610/">W3C signature</a> and <a class='external' href="http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/">W3C metadata</a>.
</p><p>At this layer a document is in general represented by a bundle of named resources zipped to a package.
For instance, an ODF text document like 'myVacation.odt' might contain the following files:
</p><p><img src='doc-files/ODF_Package.jpg' />
</p><p><b>Note:</b>
All file streams aside of the '/Pictures' directory and its content are specified by the ODF standard.
Furthermore, the file streams are similar for all types of ODF documents.
</p><p>The main requirements for this layer in regard of ZIP are:
</p><ul><li> Zip/unzip the file streams of the package
</li><li> Enlist all file streams in the /META-INF/manifest.xml (similar to an inventory)
</li><li> Begin the package with an unzipped 'mimetype' file stream (allowing others to easily identify the package)
</li></ul><p>
All sources of the Package layer are organized in ODFDOM beyond <code>org.odftoolkit.odfdom.pkg.*</code>
</p><p>The following example illustrates how to add a graphic to the package level
(although not shown by an ODF application (like OpenOffice.org), as not used by the shown content):
</p><p><pre>
import org.odftoolkit.odfdom.pkg.OdfPackage;
[...]
// loads the ODF document package from the path
OdfPackage pkg = OdfPackage.loadPackage(&quot;/home/myDocuments/myVacation.odt&quot;);
// loads the image from the URL and inserts the image in the package,
// adapting the manifest
pkg.insert(new URI(&quot;./myHoliday.png&quot;), &quot;Pictures/myHoliday.png&quot;, &quot;image/png&quot;);
pkg.save(&quot;/home/myDocuments/myVacation.odt&quot;);
</pre>
</p><p><br />
</p><h2><a name='The_ODF_XML_Layer'></a>The ODF XML Layer</h2>
<p>The ODF XML Layer provides all the features of an office format, such as tables, images, numbering etc. All features are defined in <a class='external' href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part1.html">the first part of the ODF 1.2 specification</a> describing the ODF XML schema. This layer consists of two APIs representing two different views on the features.
</p><h3><a name='The_ODF_DOM_API'></a>The ODF DOM API</h3>
<p>The ODF DOM API gives access to the XML, the elemental parts of the ODF schema features. With this API it is easy to manipulate all specified XML nodes extending the platform and language independent DOM API <a class='external' href="http://www.w3.org/DOM/">DOM API standardized by the W3C</a> - best-known by its implementation through the browsers. It extends the DOM API using a typed DOM. For every ODF XML element and ODF XML attribute defined by the ODF grammar (the RelaxNG schema) a unique class exists, providing methods for their allowed children. The purpose is to provide the user a corset to easily write valid ODF without consulting the spec constantly. This API is very consistent as instead of laboriously writing all these classes, the sources were generated directly from the ODF schema. This generation guarantees complete coverage of the ODF specification on one side and an easy and accurate upgrade to future ODF specifications on the other.
</p><p>At this level, all XML file streams of the document are accessible via the <a class='external' href="http://www.w3.org/DOM/">W3C DOM API</a>, but only the ODF standardized XML file streams of the document (e.g. content.xml, meta.xml) have their own classes representing their ODF XML elements. Foreign XML within a specified ODF XML file will remain in the document model in general and won't be neglected unless desired ( which still might be a future option).
</p><p>Example of the ODF XML representing a table in ODF:
</p><p><img src='doc-files/FruitTable_code.jpg' />
</p><p><b>Note:</b> In the OpenDocument standard the ODF elements are reused among all document types. The above XML of a table is for instance equally usable in Text and Spreadsheet documents.
</p><p>
This XML would be mapped to a W3C derived ODF DOM class structure:
</p><p><img src='doc-files/800px-Table_fruits_diagramm.jpg' width="670px" height="346px" />
</p><p>All sources of the typed DOM API are organized beyond <code>org.odftoolkit.odfdom.dom.*</code>
</p><p>The sources for the ODF elements are all generated from the ODF grammar (RelaxNG schema) using the following naming conventions in the Java reference implementation:
</p><ul><li> The class name is equal to the element local name using the Namespace as prefix and 'Element' as suffix (e.g. the 'draw:frame' element has the <code>DrawFrameElement</code> class).
</li><li> Elements are stored beyond a sub-package equal to their Namespace used by the OOo. Therefore the frame element 'draw:frame' would be generated in Java as class <code>org.odftoolkit.odfdom.dom.draw.DrawFrameElement</code>.
</li></ul><p><b>Note:</b> The element local names 'h' and 'p' have been renamed to the classes 'Heading' and 'Paragraph' for usability reasons.
</p><p>The following example illustrates how to add a graphic to the ODF document, that it is viewable:
<pre>
import java.net.URI;
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.doc.OdfDocument;
import org.odftoolkit.odfdom.doc.OdfTextDocument;
import org.odftoolkit.odfdom.doc.draw.OdfDrawImage;
import org.odftoolkit.odfdom.dom.element.draw.DrawFrameElement;
import org.odftoolkit.odfdom.dom.element.office.OfficeTextElement;
import org.odftoolkit.odfdom.dom.element.text.TextPElement;
[...]
// Load file
OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument(&quot;ImageIn.odt&quot;);
// get root of all content of a text document
OfficeTextElement officeText = odt.getContentRoot();
// get first paragraph
TextPElement firstParagraph =
OdfElement.findFirstChildNode(TextPElement.class, officeText);
// XPath alternative to get the first paragraph
/*
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(new OdfNamespace());
OdfFileDom dom = odt.getContentDom();
firstParagraph = (TextPElement) xpath.evaluate(&quot;//text:p[1]&quot;, dom, XPathConstants.NODE);
*/
// insert a frame
DrawFrameElement frame = firstParagraph.newDrawFrameElement();
// insert an image: This is a class from the Document API
OdfDrawImage image = (OdfDrawImage) frame.newDrawImageElement();
image.newImage(new URI(&quot;./MySampleImage.png&quot;));
// Save file
odt.save(&quot;ImageOut.odt&quot;);
</pre><br />
Even in this example we had to refer to a class from the Document API. Otherwise our implementation had gotten quite long and complex.
</p><p><br />
</p><h3><a name='The_ODF_Document_API'></a>The ODF Document API</h3>
<p>
The ODF Document API provides a different much more high level view on the ODF schema features. This API is concerned about usability, hiding all ODF XML implementation details from the user, covering frequent user scenarios. For example, changing the content of a certain spreadsheet cell (e.g. Add 'Hello World' to a spreadsheet cell positioned at 'B2'). While in the ODF DOM API in general each class represents an ODF XML node, here a class covers multiple underlying ODF XML elements (&amp; their attributes). Think of puzzle piece consisting of multiple smaller pieces. Therefore the typed DOM tree is being mapped to feature tree.
</p><p>As naming convention all sources of the ODF document functionality layer are organized beyond <code>org.odftoolkit.odfdom.doc.*</code>
The name of a document class is in general similar as the root element from the XML layer feature, only there is the new prefix 'Odf' and the suffix 'Element' has been neglected.
</p><p>For example, the document class for a 'draw:frame' element would be represented in the ODFDOM Java reference implemenation as <code>org.odftoolkit.odfdom.doc.draw.OdfDrawFrame</code> class. Some classes of the Document API differ from this naming convention, e.g. OdfTextParagraph is the subclass of TextPElement. However by browsing the packages you will easily find the classes your looking for.
</p><p><b>Note:</b> The Document API will change. The current inheritance between DOM and DOC elements does not fit any longer in the multiple elements to a single document feature (1:n) pattern. The first Document Object is the table <code>rg.odftoolkit.odfdom.doc.table.OdfTable</code>, others will follow soon.
</p><p>Again let's look at the previous code example for the DOM API: Remember all DOM element classes are abstract and we're really getting objects from the Document API: Even if <code>frame.newDrawFrameElement()</code> is defined to return the DOM class DrawFrameElement, it really returns the DOC subclass OdfDrawFrame. So it's always save to use explicit casting <code>OdfDrawFrame frame = (OdfDrawFrame) firstParagraph.newDrawFrameElement();</code>.
</p><p>However reworking the previous example would just make the code larger, since we're not using any of the document methods provided by the DOC subclasses.
</p><p>Here's an example for working with DOC classes, completely avoiding handling the DOM manually:
</p><p><pre>
[...]
// Load Image
OdfTextDocument odt = (OdfTextDocument) OdfDocument.loadDocument(&quot;ImageIn.odt&quot;);
// Play around with text
odt.addText(&quot;When there is no paragraph, the text will be embedded in a new paragraph&quot;);
odt.newParagraph(&quot;Create new paragraph&quot;);
odt.addText(&quot;\nThis is a new line&quot;);
// Insert Image and make last paragraph its anchor
odt.newImage(new URI(&quot;./MySampleImage.png&quot;));
// Save file
odt.save(&quot;ImageOut.odt&quot;);
</pre>
</p><p><br />
<h2>Further Information</h2>
For further Information about ODFDOM and related topics please visit following pages:
<ol>
<li><a href="http://odftoolkit.org/projects/odfdom/pages/Home">ODFDOM wiki</a></li>
<li><a href="http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1-html/OpenDocument-v1.1.html">ODF 1.1 Specification</a></li>
<li><a href="doc-files/OpenDocument-v1.2-cd05-part1.html">ODF 1.2 Specification - ODF XML Schema (part1 - community draft 5)[LOCAL COPY]</a></li>
<li><a href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part1.html">ODF 1.2 Specification - ODF XML Schema (part1 - latest published version)</a></li>
<li><a href="http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2-part3.html">ODF 1.2 Specification - ODF Package (part3 - latest published version)</a></li>
</ol>
</p>
</div></div>
</div>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li class="navBarCell1Rev">Overview</li>
<li>Package</li>
<li>Class</li>
<li>Use</li>
<li><a href="overview-tree.html">Tree</a></li>
<li><a href="deprecated-list.html">Deprecated</a></li>
<li><a href="index-files/index-1.html">Index</a></li>
<li><a href="help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="index.html?overview-summary.html" target="_top">Frames</a></li>
<li><a href="overview-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2008-2013 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</small></p>
</body>
</html>