Skip to content

How to compile a style 1 time at Citeproc->__contruct() instead of each Citeproc->render() ? #204

@glorieux-f

Description

@glorieux-f

Compilation of a style is done by those lines, called at each render() of CSL data.

$this->styleSheetXml = new SimpleXMLElement($this->styleSheet);
$this->parse($this->styleSheetXml);

This design do not allow to use a CiteProc to render one item at a time, for example in a complex PHP page aggregating multiple references. In another web language, for example Java, a compiled CiteProc should have been shared in a cache at server level, so that each request should not have to recompile the CSL style at each call. Even in PHP, such compiled CiteProc could be cached with APCu or MemCache.

A little experiment shows that compilation can’t be done easily in the constructor of a CiteProc, a Context object seems needed in lots of places, carrying information accross nodes of the CSL style, but carrying also, the mode requested by user in render(), and the data itself. This could be a huge refactoring, but maybe a goal for for a V3, to think about separation between the style compiled and the data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions