Search in sources :

Example 1 with CompositeMatcher

use of org.apache.tika.sax.xpath.CompositeMatcher in project tika by apache.

the class OpenDocumentMetaParser method getMeta.

private static ContentHandler getMeta(ContentHandler ch, Metadata md, Property property, String element) {
    Matcher matcher = new CompositeMatcher(META_XPATH.parse("//meta:" + element), META_XPATH.parse("//meta:" + element + "//text()"));
    ContentHandler branch = new MatchingContentHandler(new MetadataHandler(md, property), matcher);
    return new TeeContentHandler(ch, branch);
}
Also used : CompositeMatcher(org.apache.tika.sax.xpath.CompositeMatcher) Matcher(org.apache.tika.sax.xpath.Matcher) MatchingContentHandler(org.apache.tika.sax.xpath.MatchingContentHandler) MetadataHandler(org.apache.tika.parser.xml.MetadataHandler) AttributeDependantMetadataHandler(org.apache.tika.parser.xml.AttributeDependantMetadataHandler) AttributeMetadataHandler(org.apache.tika.parser.xml.AttributeMetadataHandler) ElementMetadataHandler(org.apache.tika.parser.xml.ElementMetadataHandler) TeeContentHandler(org.apache.tika.sax.TeeContentHandler) MatchingContentHandler(org.apache.tika.sax.xpath.MatchingContentHandler) TeeContentHandler(org.apache.tika.sax.TeeContentHandler) ContentHandler(org.xml.sax.ContentHandler) CompositeMatcher(org.apache.tika.sax.xpath.CompositeMatcher)

Example 2 with CompositeMatcher

use of org.apache.tika.sax.xpath.CompositeMatcher in project tika by apache.

the class OpenDocumentMetaParser method getUserDefined.

private static ContentHandler getUserDefined(ContentHandler ch, Metadata md) {
    Matcher matcher = new CompositeMatcher(META_XPATH.parse("//meta:user-defined/@meta:name"), META_XPATH.parse("//meta:user-defined//text()"));
    // eg <meta:user-defined meta:name="Info1">Text1</meta:user-defined> becomes custom:Info1=Text1
    ContentHandler branch = new MatchingContentHandler(new AttributeDependantMetadataHandler(md, "meta:name", Metadata.USER_DEFINED_METADATA_NAME_PREFIX), matcher);
    return new TeeContentHandler(ch, branch);
}
Also used : CompositeMatcher(org.apache.tika.sax.xpath.CompositeMatcher) Matcher(org.apache.tika.sax.xpath.Matcher) MatchingContentHandler(org.apache.tika.sax.xpath.MatchingContentHandler) AttributeDependantMetadataHandler(org.apache.tika.parser.xml.AttributeDependantMetadataHandler) TeeContentHandler(org.apache.tika.sax.TeeContentHandler) MatchingContentHandler(org.apache.tika.sax.xpath.MatchingContentHandler) TeeContentHandler(org.apache.tika.sax.TeeContentHandler) ContentHandler(org.xml.sax.ContentHandler) CompositeMatcher(org.apache.tika.sax.xpath.CompositeMatcher)

Aggregations

AttributeDependantMetadataHandler (org.apache.tika.parser.xml.AttributeDependantMetadataHandler)2 TeeContentHandler (org.apache.tika.sax.TeeContentHandler)2 CompositeMatcher (org.apache.tika.sax.xpath.CompositeMatcher)2 Matcher (org.apache.tika.sax.xpath.Matcher)2 MatchingContentHandler (org.apache.tika.sax.xpath.MatchingContentHandler)2 ContentHandler (org.xml.sax.ContentHandler)2 AttributeMetadataHandler (org.apache.tika.parser.xml.AttributeMetadataHandler)1 ElementMetadataHandler (org.apache.tika.parser.xml.ElementMetadataHandler)1 MetadataHandler (org.apache.tika.parser.xml.MetadataHandler)1