Class GeoGebraParser

java.lang.Object
org.apache.tika.parser.geogebra.GeoGebraParser
All Implemented Interfaces:
Serializable, SelfConfiguring, Parser

public class GeoGebraParser extends Object implements Parser
Parser for the zip-based GeoGebra formats: worksheets (*.ggb), Notes/Slides (*.ggs) and tools (*.ggt).

The construction metadata (title, author, date) and the application name/version are read from geogebra.xml (or, for a tool, from geogebra_macro.xml), and the user-visible text (text objects, inline text, captions, tool names and help) is emitted as XHTML paragraphs. For Notes/Slides, each _slideN/geogebra.xml becomes a <div class="slide">, in the order given by structure.json.

The representative rendering of the document, geogebra_thumbnail.png at the root of a worksheet, the icon of a tool (iconFile of its macro), or the first available slide thumbnail of a Notes/Slides file, is emitted as an embedded document marked with TikaCoreProperties.EmbeddedResourceType.THUMBNAIL, so that clients (e.g. the unpacker's sidecar metadata) can pick it as the preview image. Thumbnails of the remaining slides are renderings of content that is already extracted, so they are skipped. The document script geogebra_javascript.js is emitted as a TikaCoreProperties.EmbeddedResourceType.MACRO, and any other embedded file (e.g. inserted pictures) as an embedded document.

A part that cannot be read (an unsupported zip entry, malformed XML) is recorded in the metadata and skipped; the remaining parts are still parsed.

See Also:
  • Field Details

    • GEOGEBRA_PREFIX

      public static final String GEOGEBRA_PREFIX
      See Also:
    • APP_NAME

      public static final Property APP_NAME
      The GeoGebra application flavor the file was written with, e.g. "classic", "notes", "graphing".
    • APP_VERSION

      public static final Property APP_VERSION
      The GeoGebra application version the file was written with.
    • FORMAT_VERSION

      public static final Property FORMAT_VERSION
      The GeoGebra XML format version.
    • ID

      public static final Property ID
      The unique id GeoGebra assigns to the document.
    • DATE

      public static final Property DATE
      The free-form date string of the construction. This is user-entered text, not necessarily a parseable date.
    • TOOL_NAME

      public static final Property TOOL_NAME
      The tool names of the macros in a tool file (or in a worksheet with embedded macros). The name is the toolName attribute of the macro element.
  • Constructor Details

    • GeoGebraParser

      public GeoGebraParser()
  • Method Details

    • getSupportedTypes

      public Set<MediaType> getSupportedTypes(ParseContext context)
      Description copied from interface: Parser
      Returns the set of media types supported by this parser when used with the given parse context.
      Specified by:
      getSupportedTypes in interface Parser
      Parameters:
      context - parse context
      Returns:
      immutable set of media types
    • parse

      public void parse(TikaInputStream tis, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException
      Description copied from interface: Parser
      Parses a document stream into a sequence of XHTML SAX events. Fills in related document metadata in the given metadata object.

      The given document stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller.

      Information about the parsing context can be passed in the context parameter. See the parser implementations for the kinds of context information they expect.

      Specified by:
      parse in interface Parser
      Parameters:
      handler - handler for the XHTML SAX events (output)
      metadata - document metadata (input and output)
      context - parse context
      Throws:
      IOException - if the document stream could not be read
      SAXException - if the SAX events could not be processed
      TikaException - if the document could not be parsed