You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2012/08/05 18:24:10 UTC

svn commit: r1369615 [11/15] - in /tika/site: ./ publish/ publish/0.10/ publish/0.5/ publish/0.6/ publish/0.7/ publish/0.8/ publish/0.9/ publish/1.0/ publish/1.1/ publish/1.2/ publish/css/ src/site/apt/1.2/

Modified: tika/site/publish/1.1/parser_guide.html
URL: http://svn.apache.org/viewvc/tika/site/publish/1.1/parser_guide.html?rev=1369615&r1=1369614&r2=1369615&view=diff
==============================================================================
--- tika/site/publish/1.1/parser_guide.html (original)
+++ tika/site/publish/1.1/parser_guide.html Sun Aug  5 16:24:07 2012
@@ -1,347 +1,349 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-
-
-
-
-
-
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-    <title>Apache Tika - Get Tika parsing up and running in 5 minutes</title>
-    <style type="text/css" media="all">
-      @import url("../css/site.css");
-    </style>
-    <link rel="icon" type="image/png" href="../tikaNoText16.png" />
-    <script type="text/javascript">
-      function selectProvider(form) {
-        provider = form.elements['searchProvider'].value;
-        if (provider == "any") {
-          if (Math.random() > 0.5) {
-            provider = "lucid";
-          } else {
-            provider = "sl";
-          }
-        }
-        if (provider == "lucid") {
-          form.action = "http://search.lucidimagination.com/p:tika";
-        } else if (provider == "sl") {
-          form.action = "http://search-lucene.com/tika";
-        }
-        days = 90;
-        date = new Date();
-        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
-        expires = "; expires=" + date.toGMTString();
-        document.cookie = "searchProvider=" + provider + expires + "; path=/";
-      }
-      function initProvider() {
-        if (document.cookie.length>0) {
-          cStart=document.cookie.indexOf("searchProvider=");
-          if (cStart!=-1) {
-            cStart=cStart + "searchProvider=".length;
-            cEnd=document.cookie.indexOf(";", cStart);
-            if (cEnd==-1) {
-              cEnd=document.cookie.length;
-            }
-            provider = unescape(document.cookie.substring(cStart,cEnd));
-            document.forms['searchform'].elements['searchProvider'].value = provider;
-          }
-        }
-        document.forms['searchform'].elements['q'].focus();
-      }
-    </script>
-  </head>
-  <body onLoad="initProvider();">
-    <div id="body">
-      <div id="banner">
-        <a href="http://tika.apache.org" id="bannerLeft" title="Apache Tika"
-          ><img src="http://tika.apache.org/tika.png" alt="Apache Tika"
-                width="292" height="100"/></a>
-        <a href="http://www.apache.org/" id="bannerRight"
-           title="The Apache Software Foundation"
-          ><img src="http://tika.apache.org/asf-logo.gif" alt="The Apache Software Foundation"
-                width="387" height="100"/></a>
-      </div>
-      <div id="content">
-        <!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements.  See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License.  You may obtain a copy of the License at --><!--  --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!--  --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><div class="section"><h2>Get Tika parsing up and running in 5 minutes<a name="Get_Tika_parsing_up_and_running_in_5_min
 utes"></a></h2><p>This page is a quick start guide showing how to add a new parser to Apache Tika. Following the simple steps listed below your new parser can be running in only 5 minutes.</p><ul><li><a href="#Get_Tika_parsing_up_and_running_in_5_minutes">Get Tika parsing up and running in 5 minutes</a><ul><li><a href="#Getting_Started">Getting Started</a></li><li><a href="#Add_your_MIME-Type">Add your MIME-Type</a></li><li><a href="#Create_your_Parser_class">Create your Parser class</a></li><li><a href="#List_the_new_parser">List the new parser</a></li></ul></li></ul><div class="section"><h3><a name="Getting_Started">Getting Started</a><a name="Getting_Started"></a></h3><p>The <a href="#gettingstarted.html">Getting Started</a> document describes how to build Apache Tika from sources and how to start using Tika in an application. Pay close attention and follow the instructions in the &quot;Getting and building the sources&quot; section.</p></div><div class="section"><h3><a n
 ame="Add_your_MIME-Type">Add your MIME-Type</a><a name="Add_your_MIME-Type"></a></h3><p>You first need to modify <a class="externalLink" href="http://svn.apache.org/repos/asf/tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml">tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml</a> in order to Tika can map the file extension with its MIME-Type. You should add something like this:</p><div><pre> &lt;mime-type type=&quot;application/hello&quot;&gt;
-        &lt;glob pattern=&quot;*.hi&quot;/&gt;
- &lt;/mime-type&gt;</pre></div></div><div class="section"><h3><a name="Create_your_Parser_class">Create your Parser class</a><a name="Create_your_Parser_class"></a></h3><p>Now, you need to create your new parser. This is a class that must implement the Parser interface offered by Tika. A very simple Tika Parser looks like this:</p><div><pre>/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the &quot;License&quot;); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * 
- * @Author: Arturo Beltran
- */
-package org.apache.tika.parser.hello;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Set;
-
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.mime.MediaType;
-import org.apache.tika.parser.ParseContext;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-public class HelloParser implements Parser {
-
-        private static final Set&lt;MediaType&gt; SUPPORTED_TYPES = Collections.singleton(MediaType.application(&quot;hello&quot;));
-        public static final String HELLO_MIME_TYPE = &quot;application/hello&quot;;
-        
-        public Set&lt;MediaType&gt; getSupportedTypes(ParseContext context) {
-                return SUPPORTED_TYPES;
-        }
-
-        public void parse(
-                        InputStream stream, ContentHandler handler,
-                        Metadata metadata, ParseContext context)
-                        throws IOException, SAXException, TikaException {
-
-                metadata.set(Metadata.CONTENT_TYPE, HELLO_MIME_TYPE);
-                metadata.set(&quot;Hello&quot;, &quot;World&quot;);
-
-                XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-                xhtml.startDocument();
-                xhtml.endDocument();
-        }
-
-        /**
-         * @deprecated This method will be removed in Apache Tika 1.0.
-         */
-        public void parse(
-                        InputStream stream, ContentHandler handler, Metadata metadata)
-                        throws IOException, SAXException, TikaException {
-                parse(stream, handler, metadata, new ParseContext());
-        }
-}</pre></div><p>Pay special attention to the definition of the SUPPORTED_TYPES static class field in the parser class that defines what MIME-Types it supports. </p><p>Is in the &quot;parse&quot; method where you will do all your work. This is, extract the information of the resource and then set the metadata.</p></div><div class="section"><h3><a name="List_the_new_parser">List the new parser</a><a name="List_the_new_parser"></a></h3><p>Finally, you should explicitly tell the AutoDetectParser to include your new parser. This step is only needed if you want to use the AutoDetectParser functionality. If you figure out the correct parser in a different way, it isn't needed. </p><p>List your new parser in: <a class="externalLink" href="http://svn.apache.org/repos/asf/tika/trunk/tika-parsers/src/main/resources/META-INF/services/org.apache.tika.parser.Parser">tika-parsers/src/main/resources/META-INF/services/org.apache.tika.parser.Parser</a></p></div></div>
-      </div>
-      <div id="sidebar">
-        <div id="navigation">
-                    <h5>Apache Tika</h5>
-            <ul>
-              
-    <li class="none">
-                    <a href="../index.html">Introduction</a>
-          </li>
-              
-    <li class="none">
-                    <a href="../download.html">Download</a>
-          </li>
-              
-    <li class="none">
-                    <a href="../mail-lists.html">Mailing Lists</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://wiki.apache.org/tika/" class="externalLink">Tika Wiki</a>
-          </li>
-              
-    <li class="none">
-                    <a href="https://issues.apache.org/jira/browse/TIKA" class="externalLink">Issue Tracker</a>
-          </li>
-          </ul>
-              <h5>Documentation</h5>
-            <ul>
-              
-          
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="expanded">
-                    <a href="../1.2/index.html">Apache Tika 1.2</a>
-                  <ul>
-                  
-    <li class="none">
-                    <a href="../1.2/gettingstarted.html">Getting Started</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/formats.html">Supported Formats</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/parser.html">Parser API</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/parser_guide.html">Parser 5min Quick Start Guide</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/detection.html">Content and Language Detection</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/api/">API Documentation</a>
-          </li>
-              </ul>
-        </li>
-              
-                
-                    
-                  
-                  
-                        
-                  
-                  
-              
-            <li class="expanded">
-                    <a href="../1.1/index.html">Apache Tika 1.1</a>
-                  <ul>
-                  
-    <li class="none">
-                    <a href="../1.1/gettingstarted.html">Getting Started</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.1/formats.html">Supported Formats</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.1/parser.html">Parser API</a>
-          </li>
-                  
-    <li class="none">
-              <strong>Parser 5min Quick Start Guide</strong>
-        </li>
-                  
-    <li class="none">
-                    <a href="../1.1/detection.html">Content and Language Detection</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.1/api/">API Documentation</a>
-          </li>
-              </ul>
-        </li>
-              
-                
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="collapsed">
-                    <a href="../1.0/index.html">Apache Tika 1.0</a>
-                </li>
-              
-                
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="collapsed">
-                    <a href="../0.10/index.html">Apache Tika 0.10</a>
-                </li>
-          </ul>
-              <h5>The Apache Software Foundation</h5>
-            <ul>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/" class="externalLink">About</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/licenses/" class="externalLink">License</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/security/" class="externalLink">Security</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
-          </li>
-          </ul>
-      
-          <div id="search">
-            <h5>Search with Apache Solr</h5>
-            <form action="http://search.lucidimagination.com/p:tika"
-                  method="get" id="searchform">
-              <input type="text" id="query" name="q"/>
-              <select name="searchProvider" id="searchProvider">
-                <option value="any">provider</option>
-                <option value="lucid">Lucid Find</option>
-                <option value="sl">Search-Lucene</option>
-              </select>
-              <input type="submit" id="submit" value="Search" name="Search"
-                     onclick="selectProvider(this.form)"/>
-            </form>
-          </div>
-
-          <div id="bookpromo">
-            <h5>Books about Tika</h5>
-            <p>
-              <a href="http://manning.com/mattmann/" title="Tika in Action"
-                ><img src="../mattmann_cover150.jpg"
-                      width="150" height="186"/></a>
-            </p>
-          </div>
-        </div>
-      </div>
-      <div id="footer">
-        <p>
-          Copyright &#169; 2012
-          <a href="http://www.apache.org/">The Apache Software Foundation</a>.
-          Site powered by <a href="http://maven.apache.org/">Apache Maven</a>. 
-          Search powered by
-          <a href="http://www.lucidimagination.com">Lucid Imagination</a>
-          and <a href="http://sematext.com">Sematext</a>.
-          <br/>
-          Apache Tika, Tika, Apache, the Apache feather logo, and the Apache
-          Tika project logo are trademarks of The Apache Software Foundation.
-        </p>
-      </div>
-    </div>
-  </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+
+
+
+
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <title>Get Tika parsing up and running in 5 minutes</title>
+    <style type="text/css" media="all">
+      @import url("../css/site.css");
+    </style>
+    <link rel="icon" type="image/png" href="../tikaNoText16.png" />
+    <script type="text/javascript">
+      function selectProvider(form) {
+        provider = form.elements['searchProvider'].value;
+        if (provider == "any") {
+          if (Math.random() > 0.5) {
+            provider = "lucid";
+          } else {
+            provider = "sl";
+          }
+        }
+        if (provider == "lucid") {
+          form.action = "http://search.lucidimagination.com/p:tika";
+        } else if (provider == "sl") {
+          form.action = "http://search-lucene.com/tika";
+        }
+        days = 90;
+        date = new Date();
+        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+        expires = "; expires=" + date.toGMTString();
+        document.cookie = "searchProvider=" + provider + expires + "; path=/";
+      }
+      function initProvider() {
+        if (document.cookie.length>0) {
+          cStart=document.cookie.indexOf("searchProvider=");
+          if (cStart!=-1) {
+            cStart=cStart + "searchProvider=".length;
+            cEnd=document.cookie.indexOf(";", cStart);
+            if (cEnd==-1) {
+              cEnd=document.cookie.length;
+            }
+            provider = unescape(document.cookie.substring(cStart,cEnd));
+            document.forms['searchform'].elements['searchProvider'].value = provider;
+          }
+        }
+        document.forms['searchform'].elements['q'].focus();
+      }
+    </script>
+  </head>
+  <body onLoad="initProvider();">
+    <div id="body">
+      <div id="banner">
+        <a href="http://tika.apache.org" id="bannerLeft" title="Apache Tika"
+          ><img src="http://tika.apache.org/tika.png" alt="Apache Tika"
+                width="292" height="100"/></a>
+        <a href="http://www.apache.org/" id="bannerRight"
+           title="The Apache Software Foundation"
+          ><img src="http://tika.apache.org/asf-logo.gif" alt="The Apache Software Foundation"
+                width="387" height="100"/></a>
+      </div>
+      <div id="content">
+        <!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements.  See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License.  You may obtain a copy of the License at --><!--  --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!--  --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><div class="section"><h2>Get Tika parsing up and running in 5 minutes<a name="Get_Tika_parsing_up_and_running_in_5_min
 utes"></a></h2><p>This page is a quick start guide showing how to add a new parser to Apache Tika. Following the simple steps listed below your new parser can be running in only 5 minutes.</p><ul><li><a href="#Get_Tika_parsing_up_and_running_in_5_minutes">Get Tika parsing up and running in 5 minutes</a><ul><li><a href="#Getting_Started">Getting Started</a></li><li><a href="#Add_your_MIME-Type">Add your MIME-Type</a></li><li><a href="#Create_your_Parser_class">Create your Parser class</a></li><li><a href="#List_the_new_parser">List the new parser</a></li></ul></li></ul><div class="section"><h3><a name="Getting_Started">Getting Started</a></h3><p>The <a href="#gettingstarted.html">Getting Started</a> document describes how to build Apache Tika from sources and how to start using Tika in an application. Pay close attention and follow the instructions in the &quot;Getting and building the sources&quot; section.</p></div><div class="section"><h3><a name="Add_your_MIME-Type">Add y
 our MIME-Type</a></h3><p>You first need to modify <a class="externalLink" href="http://svn.apache.org/repos/asf/tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml">tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml</a> in order to Tika can map the file extension with its MIME-Type. You should add something like this:</p><div><pre> &lt;mime-type type=&quot;application/hello&quot;&gt;
+        &lt;glob pattern=&quot;*.hi&quot;/&gt;
+ &lt;/mime-type&gt;
+</pre></div></div><div class="section"><h3><a name="Create_your_Parser_class">Create your Parser class</a></h3><p>Now, you need to create your new parser. This is a class that must implement the Parser interface offered by Tika. A very simple Tika Parser looks like this:</p><div><pre>/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the &quot;License&quot;); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @Author: Arturo Beltran
+ */
+package org.apache.tika.parser.hello;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.mime.MediaType;
+import org.apache.tika.parser.ParseContext;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+public class HelloParser implements Parser {
+
+        private static final Set&lt;MediaType&gt; SUPPORTED_TYPES = Collections.singleton(MediaType.application(&quot;hello&quot;));
+        public static final String HELLO_MIME_TYPE = &quot;application/hello&quot;;
+        
+        public Set&lt;MediaType&gt; getSupportedTypes(ParseContext context) {
+                return SUPPORTED_TYPES;
+        }
+
+        public void parse(
+                        InputStream stream, ContentHandler handler,
+                        Metadata metadata, ParseContext context)
+                        throws IOException, SAXException, TikaException {
+
+                metadata.set(Metadata.CONTENT_TYPE, HELLO_MIME_TYPE);
+                metadata.set(&quot;Hello&quot;, &quot;World&quot;);
+
+                XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+                xhtml.startDocument();
+                xhtml.endDocument();
+        }
+
+        /**
+         * @deprecated This method will be removed in Apache Tika 1.0.
+         */
+        public void parse(
+                        InputStream stream, ContentHandler handler, Metadata metadata)
+                        throws IOException, SAXException, TikaException {
+                parse(stream, handler, metadata, new ParseContext());
+        }
+}
+</pre></div><p>Pay special attention to the definition of the SUPPORTED_TYPES static class field in the parser class that defines what MIME-Types it supports. </p><p>Is in the &quot;parse&quot; method where you will do all your work. This is, extract the information of the resource and then set the metadata.</p></div><div class="section"><h3><a name="List_the_new_parser">List the new parser</a></h3><p>Finally, you should explicitly tell the AutoDetectParser to include your new parser. This step is only needed if you want to use the AutoDetectParser functionality. If you figure out the correct parser in a different way, it isn't needed. </p><p>List your new parser in: <a class="externalLink" href="http://svn.apache.org/repos/asf/tika/trunk/tika-parsers/src/main/resources/META-INF/services/org.apache.tika.parser.Parser">tika-parsers/src/main/resources/META-INF/services/org.apache.tika.parser.Parser</a></p></div></div>
+      </div>
+      <div id="sidebar">
+        <div id="navigation">
+                    <h5>Apache Tika</h5>
+            <ul>
+              
+    <li class="none">
+                    <a href="../index.html">Introduction</a>
+          </li>
+              
+    <li class="none">
+                    <a href="../download.html">Download</a>
+          </li>
+              
+    <li class="none">
+                    <a href="../mail-lists.html">Mailing Lists</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://wiki.apache.org/tika/" class="externalLink">Tika Wiki</a>
+          </li>
+              
+    <li class="none">
+                    <a href="https://issues.apache.org/jira/browse/TIKA" class="externalLink">Issue Tracker</a>
+          </li>
+          </ul>
+              <h5>Documentation</h5>
+            <ul>
+              
+          
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="expanded">
+                    <a href="../1.2/index.html">Apache Tika 1.2</a>
+                  <ul>
+                  
+    <li class="none">
+                    <a href="../1.2/gettingstarted.html">Getting Started</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/formats.html">Supported Formats</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/parser.html">Parser API</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/parser_guide.html">Parser 5min Quick Start Guide</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/detection.html">Content and Language Detection</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/api/">API Documentation</a>
+          </li>
+              </ul>
+        </li>
+              
+                
+                    
+                  
+                  
+                        
+                  
+                  
+              
+            <li class="expanded">
+                    <a href="../1.1/index.html">Apache Tika 1.1</a>
+                  <ul>
+                  
+    <li class="none">
+                    <a href="../1.1/gettingstarted.html">Getting Started</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.1/formats.html">Supported Formats</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.1/parser.html">Parser API</a>
+          </li>
+                  
+    <li class="none">
+              <strong>Parser 5min Quick Start Guide</strong>
+        </li>
+                  
+    <li class="none">
+                    <a href="../1.1/detection.html">Content and Language Detection</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.1/api/">API Documentation</a>
+          </li>
+              </ul>
+        </li>
+              
+                
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="collapsed">
+                    <a href="../1.0/index.html">Apache Tika 1.0</a>
+                </li>
+              
+                
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="collapsed">
+                    <a href="../0.10/index.html">Apache Tika 0.10</a>
+                </li>
+          </ul>
+              <h5>The Apache Software Foundation</h5>
+            <ul>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/" class="externalLink">About</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/licenses/" class="externalLink">License</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/security/" class="externalLink">Security</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
+          </li>
+          </ul>
+      
+          <div id="search">
+            <h5>Search with Apache Solr</h5>
+            <form action="http://search.lucidimagination.com/p:tika"
+                  method="get" id="searchform">
+              <input type="text" id="query" name="q"/>
+              <select name="searchProvider" id="searchProvider">
+                <option value="any">provider</option>
+                <option value="lucid">Lucid Find</option>
+                <option value="sl">Search-Lucene</option>
+              </select>
+              <input type="submit" id="submit" value="Search" name="Search"
+                     onclick="selectProvider(this.form)"/>
+            </form>
+          </div>
+
+          <div id="bookpromo">
+            <h5>Books about Tika</h5>
+            <p>
+              <a href="http://manning.com/mattmann/" title="Tika in Action"
+                ><img src="../mattmann_cover150.jpg"
+                      width="150" height="186"/></a>
+            </p>
+          </div>
+        </div>
+      </div>
+      <div id="footer">
+        <p>
+          Copyright &#169; 2012
+          <a href="http://www.apache.org/">The Apache Software Foundation</a>.
+          Site powered by <a href="http://maven.apache.org/">Apache Maven</a>. 
+          Search powered by
+          <a href="http://www.lucidimagination.com">Lucid Imagination</a>
+          and <a href="http://sematext.com">Sematext</a>.
+          <br/>
+          Apache Tika, Tika, Apache, the Apache feather logo, and the Apache
+          Tika project logo are trademarks of The Apache Software Foundation.
+        </p>
+      </div>
+    </div>
+  </body>
+</html>

Modified: tika/site/publish/1.2/detection.html
URL: http://svn.apache.org/viewvc/tika/site/publish/1.2/detection.html?rev=1369615&r1=1369614&r2=1369615&view=diff
==============================================================================
--- tika/site/publish/1.2/detection.html (original)
+++ tika/site/publish/1.2/detection.html Sun Aug  5 16:24:07 2012
@@ -1,256 +1,257 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
- 
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-
-
-
-
-
-
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-    <title>Apache Tika - Content Detection</title>
-    <style type="text/css" media="all">
-      @import url("../css/site.css");
-    </style>
-    <link rel="icon" type="image/png" href="../tikaNoText16.png" />
-    <script type="text/javascript">
-      function selectProvider(form) {
-        provider = form.elements['searchProvider'].value;
-        if (provider == "any") {
-          if (Math.random() > 0.5) {
-            provider = "lucid";
-          } else {
-            provider = "sl";
-          }
-        }
-        if (provider == "lucid") {
-          form.action = "http://search.lucidimagination.com/p:tika";
-        } else if (provider == "sl") {
-          form.action = "http://search-lucene.com/tika";
-        }
-        days = 90;
-        date = new Date();
-        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
-        expires = "; expires=" + date.toGMTString();
-        document.cookie = "searchProvider=" + provider + expires + "; path=/";
-      }
-      function initProvider() {
-        if (document.cookie.length>0) {
-          cStart=document.cookie.indexOf("searchProvider=");
-          if (cStart!=-1) {
-            cStart=cStart + "searchProvider=".length;
-            cEnd=document.cookie.indexOf(";", cStart);
-            if (cEnd==-1) {
-              cEnd=document.cookie.length;
-            }
-            provider = unescape(document.cookie.substring(cStart,cEnd));
-            document.forms['searchform'].elements['searchProvider'].value = provider;
-          }
-        }
-        document.forms['searchform'].elements['q'].focus();
-      }
-    </script>
-  </head>
-  <body onLoad="initProvider();">
-    <div id="body">
-      <div id="banner">
-        <a href="http://tika.apache.org" id="bannerLeft" title="Apache Tika"
-          ><img src="http://tika.apache.org/tika.png" alt="Apache Tika"
-                width="292" height="100"/></a>
-        <a href="http://www.apache.org/" id="bannerRight"
-           title="The Apache Software Foundation"
-          ><img src="http://tika.apache.org/asf-logo.gif" alt="The Apache Software Foundation"
-                width="387" height="100"/></a>
-      </div>
-      <div id="content">
-        <!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements.  See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License.  You may obtain a copy of the License at --><!--  --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!--  --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><div class="section"><h2>Content Detection<a name="Content_Detection"></a></h2><p>This page gives you information on h
 ow content and language detection works with Apache Tika, and how to tune the behaviour of Tika.</p><ul><li><a href="#Content_Detection">Content Detection</a><ul><li><a href="#The_Detector_Interface">The Detector Interface</a></li><li><a href="#Mime_Magic_Detction">Mime Magic Detction</a></li><li><a href="#Resource_Name_Based_Detection">Resource Name Based Detection</a></li><li><a href="#Known_Content_Type_Detection">Known Content Type &quot;Detection</a></li><li><a href="#The_default_Mime_Types_Detector">The default Mime Types Detector</a></li><li><a href="#Container_Aware_Detection">Container Aware Detection</a></li><li><a href="#Language_Detection">Language Detection</a></li></ul></li></ul><div class="section"><h3><a name="The_Detector_Interface">The Detector Interface</a><a name="The_Detector_Interface"></a></h3><p>The <a href="./api/org/apache/tika/detect/Detector.html">org.apache.tika.detect.Detector</a> interface is the basis for most of the content type detection in 
 Apache Tika. All the different ways of detecting content all implement the same common method:</p><div><pre>MediaType detect(java.io.InputStream input,
-                 Metadata metadata) throws java.io.IOException</pre></div><p>The <tt>detect</tt> method takes the stream to inspect, and a <tt>Metadata</tt> object that holds any additional information on the content. The detector will return a <a href="./api/org/apache/tika/mime/MediaType.html">MediaType</a> object describing its best guess as to the type of the file.</p><p>In general, only two keys on the Metadata object are used by Detectors. These are <tt>Metadata.RESOURCE_NAME_KEY</tt> which should hold the name of the file (where known), and <tt>Metadata.CONTENT_TYPE</tt> which should hold the advertised content type of the file (eg from a webserver or a content repository).</p></div><div class="section"><h3><a name="Mime_Magic_Detction">Mime Magic Detction</a><a name="Mime_Magic_Detction"></a></h3><p>By looking for special (&quot;magic&quot;) patterns of bytes near the start of the file, it is often possible to detect the type of the file. For some file types, this is
  a simple process. For others, typically container based formats, the magic detection may not be enough. (More detail on detecting container formats below)</p><p>Tika is able to make use of a a mime magic info file, in the <a class="externalLink" href="http://www.freedesktop.org/standards/shared-mime-info">Freedesktop MIME-info</a> format to peform mime magic detection.</p><p>This is provided within Tika by <a href="./api/org/apache/tika/detect/MagicDetector.html">org.apache.tika.detect.MagicDetector</a>. It is most commonly access via <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>, normally sourced from the <tt>tika-mimetypes.xml</tt> file.</p></div><div class="section"><h3><a name="Resource_Name_Based_Detection">Resource Name Based Detection</a><a name="Resource_Name_Based_Detection"></a></h3><p>Where the name of the file is known, it is sometimes possible to guess the file type from the name or extension. Within the <tt>tika-mimetyp
 es.xml</tt> file is a list of patterns which are used to identify the type from the filename.</p><p>However, because files may be renamed, this method of detection is quick but not always as accurate.</p><p>This is provided within Tika by <a href="./api/org/apache/tika/detect/NameDetector.html">org.apache.tika.detect.NameDetector</a>.</p></div><div class="section"><h3><a name="Known_Content_Type_Detection">Known Content Type &quot;Detection</a><a name="Known_Content_Type_Detection"></a></h3><p>Sometimes, the mime type for a file is already known, such as when downloading from a webserver, or when retrieving from a content store. This information can be used by detectors, such as <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>,</p></div><div class="section"><h3><a name="The_default_Mime_Types_Detector">The default Mime Types Detector</a><a name="The_default_Mime_Types_Detector"></a></h3><p>By default, the mime type detection in Tika is p
 rovided by <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>. This detector makes use of <tt>tika-mimetypes.xml</tt> to power magic based and filename based detection.</p><p>Firstly, magic based detection is used on the start of the file. If the file is an XML file, then the start of the XML is processed to look for root elements. Next, if available, the filename (from <tt>Metadata.RESOURCE_NAME_KEY</tt>) is then used to improve the detail of the detection, such as when magic detects a text file, and the filename hints it's really a CSV. Finally, if available, the supplied content type (from <tt>Metadata.CONTENT_TYPE</tt>) is used to further refine the type.</p></div><div class="section"><h3><a name="Container_Aware_Detection">Container Aware Detection</a><a name="Container_Aware_Detection"></a></h3><p>Several common file formats are actually held within a common container format. One example is the PowerPoint .ppt and Word .doc formats, 
 which are both held within an OLE2 container. Another is Apple iWork formats, which are actually a series of XML files within a Zip file.</p><p>Using magic detection, it is easy to spot that a given file is an OLE2 document, or a Zip file. Using magic detection alone, it is very difficult (and often impossible) to tell what kind of file lives inside the container.</p><p>For some use cases, speed is important, so having a quick way to know the container type is sufficient. For other cases however, you don't mind spending a bit of time (and memory!) processing the container to get a more accurate answer on its contents. For these cases, container aware detectors should be used.</p><p>Tika provides a number of container aware detectors, which cover the main container formats (OLE2, Zip etc). It is possible to call these detectors individually, but it is more common to use <a href="./api/org/apache/tika/detect/DefaultDetector.html">org.apache.tika.detect.DefaultDetector</a> to h
 andle this for you. DefaultDetector works like DefaultParser, and locates available Detectors using the Services Loader, and then tries each in turn to identify the file. If the file isn't a known container, and no specific Detector identifies it, the default <tt>MimeTypes</tt> detector will be used to perform Magic Based Detection.</p><p>Because the container aware detectors needs to read the whole file in order to process the surrounding container, they must be used with a <a href="./api/org/apache/tika/io/TikaInputStream.html">org.apache.tika.io.TikaInputStream</a>. If called with a regular <tt>InputStream</tt>, then all work will be done by the <tt>MimeTypes</tt> detector.</p><p>For more information on container formats and Tika, see <a class="externalLink" href="http://wiki.apache.org/tika/MetadataDiscussion"></a></p></div><div class="section"><h3><a name="Language_Detection">Language Detection</a><a name="Language_Detection"></a></h3><p>Tika is able to help identify th
 e language of a piece of text, which is useful when extracting text from document formats which do not include language information in their metadata.</p><p>The language detection is provided by <a href="./api/org/apache/tika/language/LanguageIdentifier.html">org.apache.tika.language.LanguageIdentifier</a></p></div></div>
-      </div>
-      <div id="sidebar">
-        <div id="navigation">
-                    <h5>Apache Tika</h5>
-            <ul>
-              
-    <li class="none">
-                    <a href="../index.html">Introduction</a>
-          </li>
-              
-    <li class="none">
-                    <a href="../download.html">Download</a>
-          </li>
-              
-    <li class="none">
-                    <a href="../mail-lists.html">Mailing Lists</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://wiki.apache.org/tika/" class="externalLink">Tika Wiki</a>
-          </li>
-              
-    <li class="none">
-                    <a href="https://issues.apache.org/jira/browse/TIKA" class="externalLink">Issue Tracker</a>
-          </li>
-          </ul>
-              <h5>Documentation</h5>
-            <ul>
-              
-          
-                    
-                  
-                  
-                  
-                        
-                  
-              
-            <li class="expanded">
-                    <a href="../1.2/index.html">Apache Tika 1.2</a>
-                  <ul>
-                  
-    <li class="none">
-                    <a href="../1.2/gettingstarted.html">Getting Started</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/formats.html">Supported Formats</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/parser.html">Parser API</a>
-          </li>
-                  
-    <li class="none">
-                    <a href="../1.2/parser_guide.html">Parser 5min Quick Start Guide</a>
-          </li>
-                  
-    <li class="none">
-              <strong>Content and Language Detection</strong>
-        </li>
-                  
-    <li class="none">
-                    <a href="../1.2/api/">API Documentation</a>
-          </li>
-              </ul>
-        </li>
-              
-                
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="collapsed">
-                    <a href="../1.1/index.html">Apache Tika 1.1</a>
-                </li>
-              
-                
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="collapsed">
-                    <a href="../1.0/index.html">Apache Tika 1.0</a>
-                </li>
-              
-                
-                    
-                  
-                  
-                  
-                  
-                  
-              
-        <li class="collapsed">
-                    <a href="../0.10/index.html">Apache Tika 0.10</a>
-                </li>
-          </ul>
-              <h5>The Apache Software Foundation</h5>
-            <ul>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/" class="externalLink">About</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/licenses/" class="externalLink">License</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/security/" class="externalLink">Security</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a>
-          </li>
-              
-    <li class="none">
-                    <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
-          </li>
-          </ul>
-      
-          <div id="search">
-            <h5>Search with Apache Solr</h5>
-            <form action="http://search.lucidimagination.com/p:tika"
-                  method="get" id="searchform">
-              <input type="text" id="query" name="q"/>
-              <select name="searchProvider" id="searchProvider">
-                <option value="any">provider</option>
-                <option value="lucid">Lucid Find</option>
-                <option value="sl">Search-Lucene</option>
-              </select>
-              <input type="submit" id="submit" value="Search" name="Search"
-                     onclick="selectProvider(this.form)"/>
-            </form>
-          </div>
-
-          <div id="bookpromo">
-            <h5>Books about Tika</h5>
-            <p>
-              <a href="http://manning.com/mattmann/" title="Tika in Action"
-                ><img src="../mattmann_cover150.jpg"
-                      width="150" height="186"/></a>
-            </p>
-          </div>
-        </div>
-      </div>
-      <div id="footer">
-        <p>
-          Copyright &#169; 2012
-          <a href="http://www.apache.org/">The Apache Software Foundation</a>.
-          Site powered by <a href="http://maven.apache.org/">Apache Maven</a>. 
-          Search powered by
-          <a href="http://www.lucidimagination.com">Lucid Imagination</a>
-          and <a href="http://sematext.com">Sematext</a>.
-          <br/>
-          Apache Tika, Tika, Apache, the Apache feather logo, and the Apache
-          Tika project logo are trademarks of The Apache Software Foundation.
-        </p>
-      </div>
-    </div>
-  </body>
-</html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+
+
+
+
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <title>Content Detection</title>
+    <style type="text/css" media="all">
+      @import url("../css/site.css");
+    </style>
+    <link rel="icon" type="image/png" href="../tikaNoText16.png" />
+    <script type="text/javascript">
+      function selectProvider(form) {
+        provider = form.elements['searchProvider'].value;
+        if (provider == "any") {
+          if (Math.random() > 0.5) {
+            provider = "lucid";
+          } else {
+            provider = "sl";
+          }
+        }
+        if (provider == "lucid") {
+          form.action = "http://search.lucidimagination.com/p:tika";
+        } else if (provider == "sl") {
+          form.action = "http://search-lucene.com/tika";
+        }
+        days = 90;
+        date = new Date();
+        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
+        expires = "; expires=" + date.toGMTString();
+        document.cookie = "searchProvider=" + provider + expires + "; path=/";
+      }
+      function initProvider() {
+        if (document.cookie.length>0) {
+          cStart=document.cookie.indexOf("searchProvider=");
+          if (cStart!=-1) {
+            cStart=cStart + "searchProvider=".length;
+            cEnd=document.cookie.indexOf(";", cStart);
+            if (cEnd==-1) {
+              cEnd=document.cookie.length;
+            }
+            provider = unescape(document.cookie.substring(cStart,cEnd));
+            document.forms['searchform'].elements['searchProvider'].value = provider;
+          }
+        }
+        document.forms['searchform'].elements['q'].focus();
+      }
+    </script>
+  </head>
+  <body onLoad="initProvider();">
+    <div id="body">
+      <div id="banner">
+        <a href="http://tika.apache.org" id="bannerLeft" title="Apache Tika"
+          ><img src="http://tika.apache.org/tika.png" alt="Apache Tika"
+                width="292" height="100"/></a>
+        <a href="http://www.apache.org/" id="bannerRight"
+           title="The Apache Software Foundation"
+          ><img src="http://tika.apache.org/asf-logo.gif" alt="The Apache Software Foundation"
+                width="387" height="100"/></a>
+      </div>
+      <div id="content">
+        <!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements.  See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License.  You may obtain a copy of the License at --><!--  --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!--  --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><div class="section"><h2>Content Detection<a name="Content_Detection"></a></h2><p>This page gives you information on h
 ow content and language detection works with Apache Tika, and how to tune the behaviour of Tika.</p><ul><li><a href="#Content_Detection">Content Detection</a><ul><li><a href="#The_Detector_Interface">The Detector Interface</a></li><li><a href="#Mime_Magic_Detction">Mime Magic Detction</a></li><li><a href="#Resource_Name_Based_Detection">Resource Name Based Detection</a></li><li><a href="#Known_Content_Type_Detection">Known Content Type &quot;Detection</a></li><li><a href="#The_default_Mime_Types_Detector">The default Mime Types Detector</a></li><li><a href="#Container_Aware_Detection">Container Aware Detection</a></li><li><a href="#Language_Detection">Language Detection</a></li></ul></li></ul><div class="section"><h3><a name="The_Detector_Interface">The Detector Interface</a></h3><p>The <a href="./api/org/apache/tika/detect/Detector.html">org.apache.tika.detect.Detector</a> interface is the basis for most of the content type detection in Apache Tika. All the different ways o
 f detecting content all implement the same common method:</p><div><pre>MediaType detect(java.io.InputStream input,
+                 Metadata metadata) throws java.io.IOException
+</pre></div><p>The <tt>detect</tt> method takes the stream to inspect, and a <tt>Metadata</tt> object that holds any additional information on the content. The detector will return a <a href="./api/org/apache/tika/mime/MediaType.html">MediaType</a> object describing its best guess as to the type of the file.</p><p>In general, only two keys on the Metadata object are used by Detectors. These are <tt>Metadata.RESOURCE_NAME_KEY</tt> which should hold the name of the file (where known), and <tt>Metadata.CONTENT_TYPE</tt> which should hold the advertised content type of the file (eg from a webserver or a content repository).</p></div><div class="section"><h3><a name="Mime_Magic_Detction">Mime Magic Detction</a></h3><p>By looking for special (&quot;magic&quot;) patterns of bytes near the start of the file, it is often possible to detect the type of the file. For some file types, this is a simple process. For others, typically container based formats, the magic detection may not be
  enough. (More detail on detecting container formats below)</p><p>Tika is able to make use of a a mime magic info file, in the <a class="externalLink" href="http://www.freedesktop.org/standards/shared-mime-info">Freedesktop MIME-info</a> format to peform mime magic detection.</p><p>This is provided within Tika by <a href="./api/org/apache/tika/detect/MagicDetector.html">org.apache.tika.detect.MagicDetector</a>. It is most commonly access via <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>, normally sourced from the <tt>tika-mimetypes.xml</tt> file.</p></div><div class="section"><h3><a name="Resource_Name_Based_Detection">Resource Name Based Detection</a></h3><p>Where the name of the file is known, it is sometimes possible to guess the file type from the name or extension. Within the <tt>tika-mimetypes.xml</tt> file is a list of patterns which are used to identify the type from the filename.</p><p>However, because files may be renamed, t
 his method of detection is quick but not always as accurate.</p><p>This is provided within Tika by <a href="./api/org/apache/tika/detect/NameDetector.html">org.apache.tika.detect.NameDetector</a>.</p></div><div class="section"><h3><a name="Known_Content_Type_Detection">Known Content Type &quot;Detection</a></h3><p>Sometimes, the mime type for a file is already known, such as when downloading from a webserver, or when retrieving from a content store. This information can be used by detectors, such as <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>,</p></div><div class="section"><h3><a name="The_default_Mime_Types_Detector">The default Mime Types Detector</a></h3><p>By default, the mime type detection in Tika is provided by <a href="./api/org/apache/tika/mime/MimeTypes.html">org.apache.tika.mime.MimeTypes</a>. This detector makes use of <tt>tika-mimetypes.xml</tt> to power magic based and filename based detection.</p><p>Firstly, magic bas
 ed detection is used on the start of the file. If the file is an XML file, then the start of the XML is processed to look for root elements. Next, if available, the filename (from <tt>Metadata.RESOURCE_NAME_KEY</tt>) is then used to improve the detail of the detection, such as when magic detects a text file, and the filename hints it's really a CSV. Finally, if available, the supplied content type (from <tt>Metadata.CONTENT_TYPE</tt>) is used to further refine the type.</p></div><div class="section"><h3><a name="Container_Aware_Detection">Container Aware Detection</a></h3><p>Several common file formats are actually held within a common container format. One example is the PowerPoint .ppt and Word .doc formats, which are both held within an OLE2 container. Another is Apple iWork formats, which are actually a series of XML files within a Zip file.</p><p>Using magic detection, it is easy to spot that a given file is an OLE2 document, or a Zip file. Using magic detection alone, 
 it is very difficult (and often impossible) to tell what kind of file lives inside the container.</p><p>For some use cases, speed is important, so having a quick way to know the container type is sufficient. For other cases however, you don't mind spending a bit of time (and memory!) processing the container to get a more accurate answer on its contents. For these cases, container aware detectors should be used.</p><p>Tika provides a number of container aware detectors, which cover the main container formats (OLE2, Zip etc). It is possible to call these detectors individually, but it is more common to use <a href="./api/org/apache/tika/detect/DefaultDetector.html">org.apache.tika.detect.DefaultDetector</a> to handle this for you. DefaultDetector works like DefaultParser, and locates available Detectors using the Services Loader, and then tries each in turn to identify the file. If the file isn't a known container, and no specific Detector identifies it, the default <tt>MimeT
 ypes</tt> detector will be used to perform Magic Based Detection.</p><p>Because the container aware detectors needs to read the whole file in order to process the surrounding container, they must be used with a <a href="./api/org/apache/tika/io/TikaInputStream.html">org.apache.tika.io.TikaInputStream</a>. If called with a regular <tt>InputStream</tt>, then all work will be done by the <tt>MimeTypes</tt> detector.</p><p>For more information on container formats and Tika, see <a class="externalLink" href="http://wiki.apache.org/tika/MetadataDiscussion"></a></p></div><div class="section"><h3><a name="Language_Detection">Language Detection</a></h3><p>Tika is able to help identify the language of a piece of text, which is useful when extracting text from document formats which do not include language information in their metadata.</p><p>The language detection is provided by <a href="./api/org/apache/tika/language/LanguageIdentifier.html">org.apache.tika.language.LanguageIdentifie
 r</a></p></div></div>
+      </div>
+      <div id="sidebar">
+        <div id="navigation">
+                    <h5>Apache Tika</h5>
+            <ul>
+              
+    <li class="none">
+                    <a href="../index.html">Introduction</a>
+          </li>
+              
+    <li class="none">
+                    <a href="../download.html">Download</a>
+          </li>
+              
+    <li class="none">
+                    <a href="../mail-lists.html">Mailing Lists</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://wiki.apache.org/tika/" class="externalLink">Tika Wiki</a>
+          </li>
+              
+    <li class="none">
+                    <a href="https://issues.apache.org/jira/browse/TIKA" class="externalLink">Issue Tracker</a>
+          </li>
+          </ul>
+              <h5>Documentation</h5>
+            <ul>
+              
+          
+                    
+                  
+                  
+                  
+                        
+                  
+              
+            <li class="expanded">
+                    <a href="../1.2/index.html">Apache Tika 1.2</a>
+                  <ul>
+                  
+    <li class="none">
+                    <a href="../1.2/gettingstarted.html">Getting Started</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/formats.html">Supported Formats</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/parser.html">Parser API</a>
+          </li>
+                  
+    <li class="none">
+                    <a href="../1.2/parser_guide.html">Parser 5min Quick Start Guide</a>
+          </li>
+                  
+    <li class="none">
+              <strong>Content and Language Detection</strong>
+        </li>
+                  
+    <li class="none">
+                    <a href="../1.2/api/">API Documentation</a>
+          </li>
+              </ul>
+        </li>
+              
+                
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="collapsed">
+                    <a href="../1.1/index.html">Apache Tika 1.1</a>
+                </li>
+              
+                
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="collapsed">
+                    <a href="../1.0/index.html">Apache Tika 1.0</a>
+                </li>
+              
+                
+                    
+                  
+                  
+                  
+                  
+                  
+              
+        <li class="collapsed">
+                    <a href="../0.10/index.html">Apache Tika 0.10</a>
+                </li>
+          </ul>
+              <h5>The Apache Software Foundation</h5>
+            <ul>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/" class="externalLink">About</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/licenses/" class="externalLink">License</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/security/" class="externalLink">Security</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink">Sponsorship</a>
+          </li>
+              
+    <li class="none">
+                    <a href="http://www.apache.org/foundation/thanks.html" class="externalLink">Thanks</a>
+          </li>
+          </ul>
+      
+          <div id="search">
+            <h5>Search with Apache Solr</h5>
+            <form action="http://search.lucidimagination.com/p:tika"
+                  method="get" id="searchform">
+              <input type="text" id="query" name="q"/>
+              <select name="searchProvider" id="searchProvider">
+                <option value="any">provider</option>
+                <option value="lucid">Lucid Find</option>
+                <option value="sl">Search-Lucene</option>
+              </select>
+              <input type="submit" id="submit" value="Search" name="Search"
+                     onclick="selectProvider(this.form)"/>
+            </form>
+          </div>
+
+          <div id="bookpromo">
+            <h5>Books about Tika</h5>
+            <p>
+              <a href="http://manning.com/mattmann/" title="Tika in Action"
+                ><img src="../mattmann_cover150.jpg"
+                      width="150" height="186"/></a>
+            </p>
+          </div>
+        </div>
+      </div>
+      <div id="footer">
+        <p>
+          Copyright &#169; 2012
+          <a href="http://www.apache.org/">The Apache Software Foundation</a>.
+          Site powered by <a href="http://maven.apache.org/">Apache Maven</a>. 
+          Search powered by
+          <a href="http://www.lucidimagination.com">Lucid Imagination</a>
+          and <a href="http://sematext.com">Sematext</a>.
+          <br/>
+          Apache Tika, Tika, Apache, the Apache feather logo, and the Apache
+          Tika project logo are trademarks of The Apache Software Foundation.
+        </p>
+      </div>
+    </div>
+  </body>
+</html>