Christine took on the majority of the work by independently implementing and testing the code, while occasionally consulting with Martin throughout the process. But she did not need to start from scratch. A CSS parser was already part of our transpect framework, but had to be extended for the PrintCSS grammar.
The CSS parser is based on an EBNF schema. EBNF is the abbreviation of Extended Backus-Naur form and is a declarative syntax to express a syntax (metasyntax) of a formal language. Christine has extended our CSS EBNF schema. For example, here is an EBNF code snippet that declares the syntax for specifying page rules in CSS:
pagerule ::= '@page' S* (pageclass | pagename)? pagename ::= IDENT pageclass ::= ':' ('first'|'blank'|'left'|'right')
Using Gunther Rademacher's REx Parser Generator [15], the EBNF was later converted to XSLT. The XSLT is applied on the CSS file and creates an XML document including the CSS rules. The example below shows the XML representation (CSS XML) of a page rule:
<atrule origin="/tmp/style.css" type="page"> <raw-css xml:space="preserve"> @page {
 size:A4;
 margin: 2cm 2cm 3cm 2cm;
 } </raw-css> <declaration property="size" value="A4"/> <shorthand property="margin" value="2cm 2cm 3cm 2cm" num="2"/> <declaration property="margin-top" value="2cm" shorthand="2"/> <declaration property="margin-right" value="2cm" shorthand="2"/> <declaration property="margin-bottom" value="3cm" shorthand="2"/> <declaration property="margin-left" value="2cm" shorthand="2"/> </atrule>
Later, the CSS rules are applied to the content by evaluating the CSS selectors and inserted back into the source file as CSS attributes (CSSa) [16]:
<p>The result of a Delta-DOR measurement provides knowledge of the spacecraft’s angular position in the inertial reference frame defined by the quasars (CCSDS <a href="#j_astro-2022-0200_ref_002" >2019</a>).</p>
This CSS parser is encapsulated in a simple XProc step, which takes an XHTML document and an XSLT parser stylesheet as inputs. It produces both the CSS XML representation and an XHTML document with embedded CSS attributes (XHTML/CSSa):
<css:expand> <p:input port="source" primary="true"/> <p:input port="stylesheet"/> <p:output port="result" primary="true"/> <p:output port="xml-representation"/> <p:output port="report" sequence="true"/> </css:expand>
[15] 7 Guter Rademacher (2025): REx Parser Generator. Available at https://github.com/GuntherRademacher/rex-parser-generator (Accessed May 15, 2025)
[16] 8 Gerrit Imsieke (2013). Conveying Layout Information with CSSa (Talk held at XML Prague). Available at https://archive.xmlprague.cz/2013/presentations/Conveying_Layout_Information_with_CSSa/CSSa_xmlprague_gimsieke.html#/step-1 (Accessed May 15, 2025)