PTC ALD in Arbortext Styler > Components of Documents and Templates > JavaScript > Overview of the Formatting Object Model
Overview of the Formatting Object Model
The Formatting Object Model (FOM) is PTC Arbortext Layout Developer’s JavaScript API and represents a large part of PTC Arbortext Layout Developer’s formatting capabilities. Although not complete, it provides sufficient functionality to support most template building tasks. The Formatting Object Model is divided into four main groups of objects, each representing an area of PTC Arbortext Layout Developer’s capability.
With the exception of the File object, FOM objects are prefixed with the lowercase f to differentiate them from other object models.
Formatting Objects
Formatting objects represent the formatting process and the objects PTC Arbortext Layout Developer uses to format content. This includes style objects for inline styles, paragraphs, blocks, and tables and other objects referenced by the style objects, such as colors, rules, and fonts. It also includes references, used by PTC Arbortext Layout Developer as markers in the content for creating or calling other functionality such as footnotes, indexes, and accolades. Formatting objects are temporary and only exist while the formatting process is taking place. They do not create tags.
The high-level object in this group is the fFormatting object. This allows JavaScript to access the formatting state as the formatting process proceeds, and provides numerous properties and methods:
Properties — provide access to the current state of the formatting objects
Methods — provide ways to start and end various formatting objects or to apply a command to perform a particular task
The formatting process must be active to access formatting objects. Running a script that contains calls to formatting objects when the formatting process is not active generates errors. The formatting process is only active during a template.format() process or when refreshing a page.
This document includes references to the formatting object. This alias of the fFormatting object is used to simplify code development. Other aliases are used too, including the application alias of the current fApplication object and template as an alias to the fApplication.currentTemplate object.
Content Objects
Content objects represent many of the tags within a document or template. Content objects can be considered as the building blocks from which pages and documents are built.
The high-level object in the Content group is fContent. This object provides access to the different tag types represented by the FOM plus methods to create and manage those tags. There are get and create methods for many of the different tag types. These methods allow JavaScript to access a particular tag or to create one. fContent also provides tools for loading external content into the document.
Application Objects
Application objects provide access to the PTC Arbortext Layout Developer instance that is currently running. Included in this group are the file access object and, most importantly, the fTemplate object. fTemplate represents a template (or a document, since there is no differentiation in FOM) and provides access to its content. The current active document is accessed through fApplication.activeTemplate which, to simplify code development, is provided by the global JavaScript variable template.
This manual includes references to template.content in code examples. This is an alias of fApplication.activeTemplate.content.
DOM Objects
PTC Arbortext Layout Developer provides W3C DOM Level 2 Core support for accessing the XML DOMs of XML content, with extensions to meet PTC Arbortext Layout Developer’s capabilities and requirements. PTC Arbortext Layout Developer DOM objects that extend DOM are prefixed with fx. These objects inherit the W3C DOM object properties and methods of the same name.