OMDoc Java Objects

The org.omdoc.jomdoc.lang package contains Java objects representing the OMDoc elements. There is a parser that can parse an XML file and create a representation of it with the JOMDoc objects, and a serializer that given a document in JOMDoc representation exports it to XML.

The general structure is represented by the OMDoc* classes under the lang package

  • OMDocNode - root of all nodes
  • OMDocElement - represents an OMDoc element
  • OMDocDocument - the root <omdoc> element
  • OMDocText - text node
  • OMDocRaw - a raw XML (XOM) node
  • OMDocComment - an XML comment

All OMDoc Java objects form a tree structure, such that each element contains a list of children nodes, and each node has exactly one parent. Each object contains fields for it's attributes, and appropriate get/set methods. Many complex operations are built into the object themselves, like for example flattening of a Theory or OMDocDocument, translation of Morphisms, resolving of references, etc.

Parsing

Parsing is the process of creating the OMDoc data structure from an XML representation. Whole documents or individual elements can be parsed. Parsing is as simple as:

// parse document
OMDocDocument omdoc = Parser.parse(inputDocument);

// parse element
OMDocElement element = Parser.parse(xomElement);

Serialization

Serialization is the process of transforming the OMDoc internal structure to XML representation. Any OMDocNode can be directly serialized. For example:

// serialize document to file
Serializer.serialize(omdoc, new File("outputFile"));

// serialize OMDocElement to XOM Element
Element xomElement = omdocElement.serialize();