Author: jukka
Date: Fri Oct 16 15:48:28 2009
New Revision: 825959
URL: http://svn.apache.org/viewvc?rev=825959&view=rev
Log:
TIKA-301: patch: embedded ODF and office:annotation
Patch by Bart Hanssens
Added:
lucene/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/opendocument/ODFParserTest.java
lucene/tika/trunk/tika-parsers/src/test/resources/test-documents/testODFwithOOo3.odt
(with props)
Modified:
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java
Modified:
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
URL:
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java?rev=825959&r1=825958&r2=825959&view=diff
==============================================================================
---
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
(original)
+++
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
Fri Oct 16 15:48:28 2009
@@ -56,6 +56,9 @@
public static final String TABLE_NS =
"urn:oasis:names:tc:opendocument:xmlns:table:1.0";
+ public static final String OFFICE_NS =
+ "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
+
public static final String XLINK_NS = "http://www.w3.org/1999/xlink";
protected static final char[] TAB = new char[] { '\t' };
@@ -85,6 +88,9 @@
new QName(TEXT_NS, "note"),
new TargetElement(XHTML, "div"));
MAPPINGS.put(
+ new QName(OFFICE_NS, "annotation"),
+ new TargetElement(XHTML, "div"));
+ MAPPINGS.put(
new QName(TEXT_NS, "span"),
new TargetElement(XHTML, "span"));
MAPPINGS.put(
Modified:
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java
URL:
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java?rev=825959&r1=825958&r2=825959&view=diff
==============================================================================
---
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java
(original)
+++
lucene/tika/trunk/tika-parsers/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java
Fri Oct 16 15:48:28 2009
@@ -68,7 +68,7 @@
metadata.set(Metadata.CONTENT_TYPE, type);
} else if (entry.getName().equals("meta.xml")) {
meta.parse(zip, new DefaultHandler(), metadata, context);
- } else if (entry.getName().equals("content.xml")) {
+ } else if (entry.getName().endsWith("content.xml")) {
content.parse(zip, handler, metadata, context);
}
entry = zip.getNextEntry();
Added:
lucene/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/opendocument/ODFParserTest.java
URL:
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/opendocument/ODFParserTest.java?rev=825959&view=auto
==============================================================================
---
lucene/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/opendocument/ODFParserTest.java
(added)
+++
lucene/tika/trunk/tika-parsers/src/test/java/org/apache/tika/parser/opendocument/ODFParserTest.java
Fri Oct 16 15:48:28 2009
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+package org.apache.tika.parser.opendocument;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.sax.BodyContentHandler;
+import org.xml.sax.ContentHandler;
+
+public class ODFParserTest extends TestCase {
+
+ public void testXMLParser() throws Exception {
+ InputStream input = ODFParserTest.class.getResourceAsStream(
+ "/test-documents/testODFwithOOo3.odt");
+ try {
+ Metadata metadata = new Metadata();
+ ContentHandler handler = new BodyContentHandler();
+ new OpenOfficeParser().parse(input, handler, metadata);
+
+ assertEquals(
+ "application/vnd.oasis.opendocument.text",
+ metadata.get(Metadata.CONTENT_TYPE));
+
+ String content = handler.toString();
+ assertTrue(content.contains("Tika is part of the Lucene
project."));
+ assertTrue(content.contains("Solr"));
+ assertTrue(content.contains("one embedded"));
+ } finally {
+ input.close();
+ }
+ }
+
+}
\ No newline at end of file
Added:
lucene/tika/trunk/tika-parsers/src/test/resources/test-documents/testODFwithOOo3.odt
URL:
http://svn.apache.org/viewvc/lucene/tika/trunk/tika-parsers/src/test/resources/test-documents/testODFwithOOo3.odt?rev=825959&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
lucene/tika/trunk/tika-parsers/src/test/resources/test-documents/testODFwithOOo3.odt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream