Korin API

Converter
in package

Read onlyYes
FinalYes

Converts a document to another version along the chain of adjacent versions (SPEC section 7).

The input is not changed: the steps convert a copy record by record, then the copy is written by the target version's rules; that output, read back on demand, is an ordinary document whose preserve-mode output is the conversion output.

Output conventions: HEAD.GEDC.VERS names the target; 5.x HEAD.CHAR names the output encoding (UTF-8, for 5.5 UTF-16 as "UNICODE"); the BOM follows the target version; every line ends with the source's dominant line terminator. Converting to the version a document already has converts nothing: the result is a copy, written as the input was; a 5.0–5.4 draft, read as 5.5, is written as 5.5 (SPEC section 10: one step), with no rules of its own. Before each step HEAD.GEDC.VERS names the version the step converts from: what the file declared ("4+", "5.01") is not a value of the later versions.

Table of Contents

Methods

__construct()  : mixed
convert()  : ConversionResult
convertFile()  : LossReport
Converts an opened file record by record and writes the output as it goes (SPEC section 7, "Streaming conversion"): byte for byte the output and the losses of {@see self::convert()} of the whole document. In memory: the index, one record and its working copy, HEAD converted (rules of other records read it), and the records the conversion adds, which go before TRLR, in php://temp until TRLR is written. HEAD takes the records it converts with it from the file: the SUBN records 7.0 and 5.5.5 keep in HEAD._SUBN, the SUBM record 5.5.5 puts after HEAD. A file whose first record is not HEAD is converted whole.
supports()  : bool

Methods

__construct()

public __construct([array<int, Step>|null $steps = null ]) : mixed
Parameters
$steps : array<int, Step>|null = null

@internal the library's steps when null

convertFile()

Converts an opened file record by record and writes the output as it goes (SPEC section 7, "Streaming conversion"): byte for byte the output and the losses of {@see self::convert()} of the whole document. In memory: the index, one record and its working copy, HEAD converted (rules of other records read it), and the records the conversion adds, which go before TRLR, in php://temp until TRLR is written. HEAD takes the records it converts with it from the file: the SUBN records 7.0 and 5.5.5 keep in HEAD._SUBN, the SUBM record 5.5.5 puts after HEAD. A file whose first record is not HEAD is converted whole.

public convertFile(IndexedDocument $input, resource $out, Version $to[, ConvertOptions $options = new ConvertOptions() ]) : LossReport
Parameters
$input : IndexedDocument
$out : resource

written from its current position

$to : Version
$options : ConvertOptions = new ConvertOptions()
Tags
throws
ConversionException

when there is no route to the version, or at a loss under LossPolicy::Fail

Return values
LossReport
On this page

Search results