|  | # Cheshire3 Objects: Transformer

## Description

A Transformer is the opposite of a Parser. It takes a Record and produces a Document. In many cases this can be handled by an XSLT implementation but other instances might include one that returns a binary file based on the information in the record. Transformers might be used in an indexing chain, but are more likely to be used to render a record in a format or schema requested by the end user.

## Implementations

There is only one pre-configured implementations as most types of Transformer are highly data dependent.
This may be used out-of-the-box in configurations for Workflows, or in code by getting the object from a Server.

- XmlTransformer
  A simple Transformer that returns raw XML for the Record.

## API

Module: cheshire3.transformer
Classes:

- XmlTransformer
  Transforms the Record into raw XML form. Similar to record.get_xml(session) but returns a Document rather than a string.
- SaxTransformer
  Returns a Document containing a serialized version of the raw SAX events.
- LxmlXsltTransformer
  Using a configured stylesheet, transform the record into new XML using the Python binding for libxml2's processor.
- LxmlOffsetQueryTermHighlightingTransformer
  Uses character offsets from Record's resultSetItem's proximity information to highlight query term matches.
  Note: this only works when the Record has been retrieved as the result of searching a ProximityIndex, otherwise returns same as XmlTransformer
- MarcTransformer
  Converts Records in marc21xml to MARC.
- WorkflowTransformer Uses a Workflow to transform the Record into a Document. This allows a multiple transformers to be chained together in places where it is only possible to configure a single transformer (e.g. inTransformer setting on a RecordStore.)

Methods:

Function | Parameters | Returns | Description
--- | --- | --- | ---
__init__ | config, parent |  |
process_record | session, record | Document | Return a Document after some transformation of the Record

### Sub-Packages

Sub-Package: graph
Module: cheshire3.graph.transformer

- RdfXmlTransformer
  Given a GraphRecord, serialize it. Must be configured with appropriate format setting, currently supports :
  - xml
  - trix
  - nt
  - n3
  - rdfa

Sub-package: web
Module: cheshire3.web.transformer

- GRS1Transformer
  Given a record, step through it and turn it into the equivalent GRS1 tree for Z39.50