Search in sources :

Example 1 with AttributeDependantMetadataHandler

use of org.apache.tika.parser.xml.AttributeDependantMetadataHandler 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)1 TeeContentHandler (org.apache.tika.sax.TeeContentHandler)1 CompositeMatcher (org.apache.tika.sax.xpath.CompositeMatcher)1 Matcher (org.apache.tika.sax.xpath.Matcher)1 MatchingContentHandler (org.apache.tika.sax.xpath.MatchingContentHandler)1 ContentHandler (org.xml.sax.ContentHandler)1