LOOSE-LEAF PUBLISHING
UsingAntenna House and CSS
Eliot Kimber
Contrext
Balisage 2019
About the Author
ā–  Independent consultant focusing on DITA
analysis, design, and implementation
ā–  Doing SGML and XML for cough 30 years cough
ā–  Founding member of the DITATechnical
Committee
ā–  Founding member of the XMLWorking Group
ā–  Co-editor of HyTime standard (ISO/IEC 10744)
ā–  Primary developer and founder of the DITA for
Publishers project (dita4publishers.org)
ā–  Author of DITA for Practitioners,Vol 1 (XML Press)
Balisage Pre-Conference Symposium 2019 2
Agenda
ā–  What?
ā–  Why?
ā–  CSS paged media
ā–  Producing Point Pages
ā–  Conclusions and Further Work
Balisage Pre-Conference Symposium 2019 3
WHAT?
Balisage Pre-Conference Symposium 2019 4
The Client: Municode
ā–  Leading supplier of
municipal code
ā–  2000+ clients
ā–  Replacing outdated
typesetting system that was
obsolete 20 years ago
– But it does loose leaf
ā–  Shifting focus from print to
digital
ā–  Print still essential
ā–  Looking for process
improvements
Balisage Pre-Conference Symposium 2019 5
Target System
ā–  CSS for pagination
ā–  Antenna House Formatter
for rendering to PDF
ā–  Custom processing to
implement loose leaf
ā–  Same source used for web
delivery
ā–  Source authored as highly-
constrained HTML5
ā–  Change boundaries are
marked manually
– Automatic detection of
changes is not a
requirement
Balisage Pre-Conference Symposium 2019 6
What Is Loose Leaf?
ā–  Pages that reflect changes
from the previously-
published version
ā–  Page numbers are not
changed
ā–  If pages are added, create
ā€œpoint pagesā€: 12.1, 12.2, etc.
Balisage Pre-Conference Symposium 2019 7
WHY LOOSE LEAF?
Balisage Pre-Conference Symposium 2019 8
The Use Case: Municipal Code
ā–  Muncipal code is the codified
laws for a city, town, county
or similar legal entity
ā–  Can be 1000s of pages
ā–  Updated frequently
– Every city council meeting
Balisage Pre-Conference Symposium 2019 9
Balisage Pre-Conference Symposium 2019 10
Why Loose Leaf?
ā–  People who use the code
depend on their paper copies
ā–  Would be impractical to
republish and redistribute for
every update
ā–  Loose leaf is the only
practical solution for paper
updates here
Balisage Pre-Conference Symposium 2019 11
Why CSS for Pagination?
ā–  Client insisted on it
ā–  Authoring directly in HTML5
ā–  Wanted to use a standard
technology
ā–  Did not have XSL-FO skills
and knowledge
ā–  Did not have XSLT skills and
knowledge
ā–  Layout requirements are
challenging but still
achievable (mostly)
ā–  Compelling cost advantages
– Easier to implement
– Separation of concerns
– Can hire CSS people
Balisage Pre-Conference Symposium 2019 12
Why Antenna House Formatter?
ā–  Most complete CSS paged
media implementation
ā–  Demonstrated ability to
meet layout requirements
ā–  Mature product with good
reputation
Balisage Pre-Conference Symposium 2019 13
CSS FOR PAGINATION
Balisage Pre-Conference Symposium 2019 14
CSS Paged Media
ā–  Adds rules, properties,
values, etc. to CSS
specifically for paged media
ā–  Page master definition
ā–  Page edge regions (running
heads and feet, etc.)
ā–  Generated text features
ā–  Additional typographic
features
ā–  Scattered across a number of
different specifications
ā–  Not fully baked
Balisage Pre-Conference Symposium 2019 15
Practical CSS Pagination Realities
ā–  Today only commercial tools
provide sufficiently complete
implementations
ā–  Proprietary extensions are
required to meet many
layout requirements
ā–  Need to preprocess HTML or
generate HTML from non-
XML source
ā–  Specs are constantly
changing
– Hard to find answers to
some questions
– Hard to keep up with
changes
ā–  No single source of practical
instruction (today)
– See Liam Quin and me
Balisage Pre-Conference Symposium 2019 16
CSSValue Proposition
ā–  Easy syntax to learn and use
compared to XSL-FO
ā–  Cleaner separation of
concerns between data
processing and visual design
ā–  Can share core CSS with
browser and paged
deliverables
ā–  CSS is ā€œcoolā€
ā–  XSL-FO is ā€œwhat the heck is
XSL-FO?ā€
ā–  Complexity of required XSLT
much lower
ā–  On balance: compelling
solution
Balisage Pre-Conference Symposium 2019 17
ā€œAugmented HTMLā€ is Required
ā–  CSS can only decorate
ā–  Need to synthesize:
– Tables of contents
– Indexes
– Complex running heads and
feet
ā–  Can simplify CSS by adding
containers or attributes
ā–  CSS has selector limitations
– Can’t look ahead
– May require new classes
based on descendants or
following elements
ā–  May need to reorder or
otherwise modify source as
authored
Balisage Pre-Conference Symposium 2019 18
CSS Example: @page Rule—Defines a
page master
@page portrait-first:right {
size: 8.5in 11in;
margin-left: 7.5pc;
margin-right: 7.5pc;
counter-reset: footnote;
counter-reset: page 1;
@bottom-left {
content: element(updateLabel);
vertical-align: top;
margin-top: 1pc;
font-family: "New Century Schoolbook", serif,
'Arial Unicode';
font-size: 8pt;
}
@bottom-center {
content: string(prefolio, first) '200B’
counter(page) '200B’
string(postfolio, first);
margin-top: 1pc;
vertical-align: top;
font-family: "New Century Schoolbook",
serif, 'Arial Unicode';
font-size: 10pt;
}
@bottom-right {
content: '00a0';
margin-top: 1pc;
vertical-align: top;
font-family: "New Century Schoolbook", serif,
'Arial Unicode';
font-size: 10pt;
}
}
Balisage Pre-Conference Symposium 2019 19
CSS Example: Start A Page Sequence
section[data-type = 'loep'],
section[data-type = 'supphistory']
{
page: portrait-first portrait;
break-before: right;
}
Balisage Pre-Conference Symposium 2019 20
Differences from XSL-FO
ā–  Any element can start a page
sequence
ā–  Edge region model different
(and more limited)
ā–  No table markers
ā–  No index entry features
ā–  No concept of ā€œfolioā€ā€“page
numbers are just counters
ā–  No flow model
ā–  Can use CSS grid (if
implementation supports it)
ā–  See LiamQuin for details
Balisage Pre-Conference Symposium 2019 21
PRODUCING POINT
PAGES
Balisage Pre-Conference Symposium 2019 22
The Challenges
ā–  Identifying pages in the
change set
ā–  Determining page numbers
for pages
– Changing page number
from formatter-assigned
page number
– Constructing point page
numbers
ā–  Ensuring change sets end on
even pages
ā–  Updating page numbers
ā–  Capturing page history
ā–  Generating full-doc tables of
contents
Balisage Pre-Conference Symposium 2019 23
General Solution:
Post Process the AreaTree
ā–  AHF can produce an ā€œarea
treeā€ document
ā–  XML representation of the
formatted pages
ā–  AHF can take area tree as
input to produce final forms
(PDF, etc.)
ā–  Area tree is not standard but
is reasonably stable
ā–  Structure is logical and easy
to understand
Balisage Pre-Conference Symposium 2019 24
<AreaRoot xmlns="http://www.antennahouse.com/names/XSL/AreaTree"
font-size="10pt" is-first="true" is-last="true" version="605.0"
is-CSS="true" display-role="root">
<PageViewportArea output-volume-break="false" generated-by="html" counter-reset="footnote"
is-first="true" is-link-destination="true" id="x99999" width="612pt" height="792pt"
abs-page-number="1" orig-abs-page-number="1" page-number="1" format="1" stacking-context="true"
display-role="root" in-job="false">
<PageReferenceArea generated-by="html" is-first="true" is-last="true" width="612pt"
height="792pt" display-role="block">
<PageRegionViewportArea region="none" generated-by="html" counter-reset="footnote"
is-first="true" is-last="true" top-position="36pt" bottom-position="36pt"
left-position="36pt" right-position="36pt" width="540pt" height="720pt" region-name=""
display-role="root">
<PageRegionReferenceArea generated-by="html" is-first="true" width="540pt" height="720pt"
display-role="block">
<BlockArea line-height="14pt" generated-by="html" text-align="justify"
font-family="&#34;New Century Schoolbook&#34;, serif" display="block" id="x99999"
font-size="10pt" is-first="true" bottom-position="395.75pt" width="540pt"
height="324.25pt" display-role="root">
General Challenge:
Injecting Additional Data Into AreaTree
ā–  Need to capture data needed
for post processing:
– Change set boundaries
– Imposed page numbers
– Source element type types
(section, figure, table,
generated, etc.)
– Page numbers with
structure
ā–  Three basic solutions:
1. Structured IDs
2. Magic character
conventions
3. Data in unused page edge
regions
ā–  Use ā€œmarkerā€ elements to
inject arbitrary information
Balisage Pre-Conference Symposium 2019 25
Markers and Structured IDs
ā–  AHF necessarily captures IDs
of all elements that are not
explicitly omitted
ā–  Use ID values as structured
fields:
<areaTreeMarker
id="take:take-begin:job=S103:d20p61ā€
/>
<areaTreeMarker
id="marker:section:update-
ins:start:portrait:id=instruction_sheet"
>
ā–  Use CSS to key on ID values:
div.section-body
areaTreeMarker[id ^= 'take:take-begin']
{
display: block;
break-before: right;
}
section > section +
areaTreeMarker[id ^= 'take:take-end'],
section > section >
areaTreeMarker[id ^= 'take:take-end'],
div.section-body
areaTreeMarker[id ^= 'take:take-end']
{
display: block;
break-after: right;
}
Balisage Pre-Conference Symposium 2019 26
Magic Characters:
Structured Page Numbers
ā–  Display page numbers have
three parts:
– Prefolio (ā€œCH-1ā€)
– Folio (the page number)
– Postfolio (ā€œ-ā€)
ā–  Need to distinguish for post
processing:
– Find page numbers
– Change the number
ā–  Solution:
– Use @class and @id for page
number references:
<span class="page" id="page:d2816e24">
<span
class="page-number-marker">&#x200B;</span>
<a id="pageref:d2816e27" class="frontmatter"
href="#x8A66ACBA2357"/>
<span class="page-number-markerā€
>&#x200B;</span></span>
ā–  Use non-breaking space to
separate folio parts
Balisage Pre-Conference Symposium 2019 27
ToYour Corner:
Using Page Edge Regions
ā–  Capture page number
format
ā–  Capture numeric page
number
ā–  Use corner regions
<MarginRegionViewportArea
visibility="hidden"
region-name="bottom-right-corner">
<MarginRegionReferenceArea visibility="hidden"
display-role="block">
<BlockArea
visibility="hidden" display-role="block">
<LineArea visibility="hidden" display-role="block">
<TextArea text="^pnf:1" visibility="hidden"/>
</LineArea>
</BlockArea>
</MarginRegionReferenceArea>
</MarginRegionViewportArea>
Balisage Pre-Conference Symposium 2019 28
AreaTree Update Process
1. Set page number and
format
2. Update page numbers
3. Filter pages
4. Renumber absolute page
numbers
5. Final update processing
6. Update page number
database
Balisage Pre-Conference Symposium 2019 29
Updating Page Numbers
ā–  AHF generates normal
integer page numbers
ā–  Will need to change some
– Different start page
– Numbers pulled from page
database
– Point page numbers
ā–  Width of number will likely
change
ā–  In some contexts, need to
adjust the horizontal position
ā–  In particular,ToC entries
ā–  Challenge: how wide is the
new number?
Balisage Pre-Conference Symposium 2019 30
Page Number Widths Solution:
Generate Exemplars in the AreaTree
ā–  HTML preprocess generates
elements for each character
in each font and size:
<char-samples
id="util:char-samples">
<char-sample class="body">
<char-set class="number-set sz8pt"
id="util:char-set:body-sz8pt"
>
<decimal>.</decimal>
<char>0</char>
<char>1</char>
<char>2</char>...
</char-set>
...
</char-sample>
...
</char-samples>
ā–  In area tree, can look up by font
family, size, and character:
<xsl:key name="char-samples"
match="at:BlockArea[starts-with(@id,
'util:char-set:')]//at:TextArea"
use="at:make-char-sample-key(@font-family,
@font-size, @text)"
/>
...
<xsl:variable name="key" as="xs:string"
select="at:make-char-sample-key(
$font-family,
$font-size,
$text)"
/>
<xsl:variable name="result" as="element()?"
select="key('char-samples’,
$key,
root($context))[1]"
/>
Balisage Pre-Conference Symposium 2019 31
Page Number Database
ā–  Two parts:
– Record of each physical
page
– Mapping of elements to the
pages they started on
ā–  Updated when final version
is published
ā–  Serves:
– Update instructions
– List of effective pages
– Supplement history
– Table of contents
ā–  Implemented as a version-
controlled XML file today
Balisage Pre-Conference Symposium 2019 32
SUMMARY
Balisage Pre-Conference Symposium 2019 33
In Summary
ā–  It works!
ā–  Not that hard once I figured
out how to do it
ā–  CSS offers compelling
advantages…
ā–  …but requires commercial
solutions today
ā–  Hand marking of change sets
avoids a hard problem
ā–  Area tree is proprietary but it
is not opaque
Balisage Pre-Conference Symposium 2019 34
More to Be Done
ā–  Automatic detection of
changes
ā–  Auto-insertion of changed
pages
ā–  Better automate capturing
legacy page number data
ā–  Refine inefficient processing
ā–  Clean up area tree before
generating PDF
ā–  More robust page database
Balisage Pre-Conference Symposium 2019 35
Resources
CSS: https://www.w3.org/TR/#tr_Cascading_Style_Sheets_(CSS)_Working_Group
Antenna House Formatter: https://www.antennahouse.com/formatter/
CSS Pagination Book (rough draft): https://drmacro.github.io/css-pagination-book/
CSS training (Liam Quin): https://www.delightfulcomputing.com/course-css-for-
xml-people.html
Graham,Tony. ā€œDecision making in XSL-FO formatting.ā€ Presented at Balisage: The
Markup Conference 2013, MontrƩal, Canada, August 6 - 9, 2013. In Proceedings of
Balisage:The Markup Conference 2013. Balisage Series on MarkupTechnologies, vol.
10 (2013). https://doi.org/10.4242/BalisageVol10.Graham01.
Balisage Pre-Conference Symposium 2019 36

Loose Leaf Publishing Using Antenna House Formatter and CSS for Pagination

  • 1.
    LOOSE-LEAF PUBLISHING UsingAntenna Houseand CSS Eliot Kimber Contrext Balisage 2019
  • 2.
    About the Author ā– Independent consultant focusing on DITA analysis, design, and implementation ā–  Doing SGML and XML for cough 30 years cough ā–  Founding member of the DITATechnical Committee ā–  Founding member of the XMLWorking Group ā–  Co-editor of HyTime standard (ISO/IEC 10744) ā–  Primary developer and founder of the DITA for Publishers project (dita4publishers.org) ā–  Author of DITA for Practitioners,Vol 1 (XML Press) Balisage Pre-Conference Symposium 2019 2
  • 3.
    Agenda ā–  What? ā–  Why? ā– CSS paged media ā–  Producing Point Pages ā–  Conclusions and Further Work Balisage Pre-Conference Symposium 2019 3
  • 4.
  • 5.
    The Client: Municode ā– Leading supplier of municipal code ā–  2000+ clients ā–  Replacing outdated typesetting system that was obsolete 20 years ago – But it does loose leaf ā–  Shifting focus from print to digital ā–  Print still essential ā–  Looking for process improvements Balisage Pre-Conference Symposium 2019 5
  • 6.
    Target System ā–  CSSfor pagination ā–  Antenna House Formatter for rendering to PDF ā–  Custom processing to implement loose leaf ā–  Same source used for web delivery ā–  Source authored as highly- constrained HTML5 ā–  Change boundaries are marked manually – Automatic detection of changes is not a requirement Balisage Pre-Conference Symposium 2019 6
  • 7.
    What Is LooseLeaf? ā–  Pages that reflect changes from the previously- published version ā–  Page numbers are not changed ā–  If pages are added, create ā€œpoint pagesā€: 12.1, 12.2, etc. Balisage Pre-Conference Symposium 2019 7
  • 8.
    WHY LOOSE LEAF? BalisagePre-Conference Symposium 2019 8
  • 9.
    The Use Case:Municipal Code ā–  Muncipal code is the codified laws for a city, town, county or similar legal entity ā–  Can be 1000s of pages ā–  Updated frequently – Every city council meeting Balisage Pre-Conference Symposium 2019 9
  • 10.
  • 11.
    Why Loose Leaf? ā– People who use the code depend on their paper copies ā–  Would be impractical to republish and redistribute for every update ā–  Loose leaf is the only practical solution for paper updates here Balisage Pre-Conference Symposium 2019 11
  • 12.
    Why CSS forPagination? ā–  Client insisted on it ā–  Authoring directly in HTML5 ā–  Wanted to use a standard technology ā–  Did not have XSL-FO skills and knowledge ā–  Did not have XSLT skills and knowledge ā–  Layout requirements are challenging but still achievable (mostly) ā–  Compelling cost advantages – Easier to implement – Separation of concerns – Can hire CSS people Balisage Pre-Conference Symposium 2019 12
  • 13.
    Why Antenna HouseFormatter? ā–  Most complete CSS paged media implementation ā–  Demonstrated ability to meet layout requirements ā–  Mature product with good reputation Balisage Pre-Conference Symposium 2019 13
  • 14.
    CSS FOR PAGINATION BalisagePre-Conference Symposium 2019 14
  • 15.
    CSS Paged Media ā– Adds rules, properties, values, etc. to CSS specifically for paged media ā–  Page master definition ā–  Page edge regions (running heads and feet, etc.) ā–  Generated text features ā–  Additional typographic features ā–  Scattered across a number of different specifications ā–  Not fully baked Balisage Pre-Conference Symposium 2019 15
  • 16.
    Practical CSS PaginationRealities ā–  Today only commercial tools provide sufficiently complete implementations ā–  Proprietary extensions are required to meet many layout requirements ā–  Need to preprocess HTML or generate HTML from non- XML source ā–  Specs are constantly changing – Hard to find answers to some questions – Hard to keep up with changes ā–  No single source of practical instruction (today) – See Liam Quin and me Balisage Pre-Conference Symposium 2019 16
  • 17.
    CSSValue Proposition ā–  Easysyntax to learn and use compared to XSL-FO ā–  Cleaner separation of concerns between data processing and visual design ā–  Can share core CSS with browser and paged deliverables ā–  CSS is ā€œcoolā€ ā–  XSL-FO is ā€œwhat the heck is XSL-FO?ā€ ā–  Complexity of required XSLT much lower ā–  On balance: compelling solution Balisage Pre-Conference Symposium 2019 17
  • 18.
    ā€œAugmented HTMLā€ isRequired ā–  CSS can only decorate ā–  Need to synthesize: – Tables of contents – Indexes – Complex running heads and feet ā–  Can simplify CSS by adding containers or attributes ā–  CSS has selector limitations – Can’t look ahead – May require new classes based on descendants or following elements ā–  May need to reorder or otherwise modify source as authored Balisage Pre-Conference Symposium 2019 18
  • 19.
    CSS Example: @pageRule—Defines a page master @page portrait-first:right { size: 8.5in 11in; margin-left: 7.5pc; margin-right: 7.5pc; counter-reset: footnote; counter-reset: page 1; @bottom-left { content: element(updateLabel); vertical-align: top; margin-top: 1pc; font-family: "New Century Schoolbook", serif, 'Arial Unicode'; font-size: 8pt; } @bottom-center { content: string(prefolio, first) '200B’ counter(page) '200B’ string(postfolio, first); margin-top: 1pc; vertical-align: top; font-family: "New Century Schoolbook", serif, 'Arial Unicode'; font-size: 10pt; } @bottom-right { content: '00a0'; margin-top: 1pc; vertical-align: top; font-family: "New Century Schoolbook", serif, 'Arial Unicode'; font-size: 10pt; } } Balisage Pre-Conference Symposium 2019 19
  • 20.
    CSS Example: StartA Page Sequence section[data-type = 'loep'], section[data-type = 'supphistory'] { page: portrait-first portrait; break-before: right; } Balisage Pre-Conference Symposium 2019 20
  • 21.
    Differences from XSL-FO ā– Any element can start a page sequence ā–  Edge region model different (and more limited) ā–  No table markers ā–  No index entry features ā–  No concept of ā€œfolioā€ā€“page numbers are just counters ā–  No flow model ā–  Can use CSS grid (if implementation supports it) ā–  See LiamQuin for details Balisage Pre-Conference Symposium 2019 21
  • 22.
  • 23.
    The Challenges ā–  Identifyingpages in the change set ā–  Determining page numbers for pages – Changing page number from formatter-assigned page number – Constructing point page numbers ā–  Ensuring change sets end on even pages ā–  Updating page numbers ā–  Capturing page history ā–  Generating full-doc tables of contents Balisage Pre-Conference Symposium 2019 23
  • 24.
    General Solution: Post Processthe AreaTree ā–  AHF can produce an ā€œarea treeā€ document ā–  XML representation of the formatted pages ā–  AHF can take area tree as input to produce final forms (PDF, etc.) ā–  Area tree is not standard but is reasonably stable ā–  Structure is logical and easy to understand Balisage Pre-Conference Symposium 2019 24 <AreaRoot xmlns="http://www.antennahouse.com/names/XSL/AreaTree" font-size="10pt" is-first="true" is-last="true" version="605.0" is-CSS="true" display-role="root"> <PageViewportArea output-volume-break="false" generated-by="html" counter-reset="footnote" is-first="true" is-link-destination="true" id="x99999" width="612pt" height="792pt" abs-page-number="1" orig-abs-page-number="1" page-number="1" format="1" stacking-context="true" display-role="root" in-job="false"> <PageReferenceArea generated-by="html" is-first="true" is-last="true" width="612pt" height="792pt" display-role="block"> <PageRegionViewportArea region="none" generated-by="html" counter-reset="footnote" is-first="true" is-last="true" top-position="36pt" bottom-position="36pt" left-position="36pt" right-position="36pt" width="540pt" height="720pt" region-name="" display-role="root"> <PageRegionReferenceArea generated-by="html" is-first="true" width="540pt" height="720pt" display-role="block"> <BlockArea line-height="14pt" generated-by="html" text-align="justify" font-family="&#34;New Century Schoolbook&#34;, serif" display="block" id="x99999" font-size="10pt" is-first="true" bottom-position="395.75pt" width="540pt" height="324.25pt" display-role="root">
  • 25.
    General Challenge: Injecting AdditionalData Into AreaTree ā–  Need to capture data needed for post processing: – Change set boundaries – Imposed page numbers – Source element type types (section, figure, table, generated, etc.) – Page numbers with structure ā–  Three basic solutions: 1. Structured IDs 2. Magic character conventions 3. Data in unused page edge regions ā–  Use ā€œmarkerā€ elements to inject arbitrary information Balisage Pre-Conference Symposium 2019 25
  • 26.
    Markers and StructuredIDs ā–  AHF necessarily captures IDs of all elements that are not explicitly omitted ā–  Use ID values as structured fields: <areaTreeMarker id="take:take-begin:job=S103:d20p61ā€ /> <areaTreeMarker id="marker:section:update- ins:start:portrait:id=instruction_sheet" > ā–  Use CSS to key on ID values: div.section-body areaTreeMarker[id ^= 'take:take-begin'] { display: block; break-before: right; } section > section + areaTreeMarker[id ^= 'take:take-end'], section > section > areaTreeMarker[id ^= 'take:take-end'], div.section-body areaTreeMarker[id ^= 'take:take-end'] { display: block; break-after: right; } Balisage Pre-Conference Symposium 2019 26
  • 27.
    Magic Characters: Structured PageNumbers ā–  Display page numbers have three parts: – Prefolio (ā€œCH-1ā€) – Folio (the page number) – Postfolio (ā€œ-ā€) ā–  Need to distinguish for post processing: – Find page numbers – Change the number ā–  Solution: – Use @class and @id for page number references: <span class="page" id="page:d2816e24"> <span class="page-number-marker">&#x200B;</span> <a id="pageref:d2816e27" class="frontmatter" href="#x8A66ACBA2357"/> <span class="page-number-markerā€ >&#x200B;</span></span> ā–  Use non-breaking space to separate folio parts Balisage Pre-Conference Symposium 2019 27
  • 28.
    ToYour Corner: Using PageEdge Regions ā–  Capture page number format ā–  Capture numeric page number ā–  Use corner regions <MarginRegionViewportArea visibility="hidden" region-name="bottom-right-corner"> <MarginRegionReferenceArea visibility="hidden" display-role="block"> <BlockArea visibility="hidden" display-role="block"> <LineArea visibility="hidden" display-role="block"> <TextArea text="^pnf:1" visibility="hidden"/> </LineArea> </BlockArea> </MarginRegionReferenceArea> </MarginRegionViewportArea> Balisage Pre-Conference Symposium 2019 28
  • 29.
    AreaTree Update Process 1.Set page number and format 2. Update page numbers 3. Filter pages 4. Renumber absolute page numbers 5. Final update processing 6. Update page number database Balisage Pre-Conference Symposium 2019 29
  • 30.
    Updating Page Numbers ā– AHF generates normal integer page numbers ā–  Will need to change some – Different start page – Numbers pulled from page database – Point page numbers ā–  Width of number will likely change ā–  In some contexts, need to adjust the horizontal position ā–  In particular,ToC entries ā–  Challenge: how wide is the new number? Balisage Pre-Conference Symposium 2019 30
  • 31.
    Page Number WidthsSolution: Generate Exemplars in the AreaTree ā–  HTML preprocess generates elements for each character in each font and size: <char-samples id="util:char-samples"> <char-sample class="body"> <char-set class="number-set sz8pt" id="util:char-set:body-sz8pt" > <decimal>.</decimal> <char>0</char> <char>1</char> <char>2</char>... </char-set> ... </char-sample> ... </char-samples> ā–  In area tree, can look up by font family, size, and character: <xsl:key name="char-samples" match="at:BlockArea[starts-with(@id, 'util:char-set:')]//at:TextArea" use="at:make-char-sample-key(@font-family, @font-size, @text)" /> ... <xsl:variable name="key" as="xs:string" select="at:make-char-sample-key( $font-family, $font-size, $text)" /> <xsl:variable name="result" as="element()?" select="key('char-samples’, $key, root($context))[1]" /> Balisage Pre-Conference Symposium 2019 31
  • 32.
    Page Number Database ā– Two parts: – Record of each physical page – Mapping of elements to the pages they started on ā–  Updated when final version is published ā–  Serves: – Update instructions – List of effective pages – Supplement history – Table of contents ā–  Implemented as a version- controlled XML file today Balisage Pre-Conference Symposium 2019 32
  • 33.
  • 34.
    In Summary ā–  Itworks! ā–  Not that hard once I figured out how to do it ā–  CSS offers compelling advantages… ā–  …but requires commercial solutions today ā–  Hand marking of change sets avoids a hard problem ā–  Area tree is proprietary but it is not opaque Balisage Pre-Conference Symposium 2019 34
  • 35.
    More to BeDone ā–  Automatic detection of changes ā–  Auto-insertion of changed pages ā–  Better automate capturing legacy page number data ā–  Refine inefficient processing ā–  Clean up area tree before generating PDF ā–  More robust page database Balisage Pre-Conference Symposium 2019 35
  • 36.
    Resources CSS: https://www.w3.org/TR/#tr_Cascading_Style_Sheets_(CSS)_Working_Group Antenna HouseFormatter: https://www.antennahouse.com/formatter/ CSS Pagination Book (rough draft): https://drmacro.github.io/css-pagination-book/ CSS training (Liam Quin): https://www.delightfulcomputing.com/course-css-for- xml-people.html Graham,Tony. ā€œDecision making in XSL-FO formatting.ā€ Presented at Balisage: The Markup Conference 2013, MontrĆ©al, Canada, August 6 - 9, 2013. In Proceedings of Balisage:The Markup Conference 2013. Balisage Series on MarkupTechnologies, vol. 10 (2013). https://doi.org/10.4242/BalisageVol10.Graham01. Balisage Pre-Conference Symposium 2019 36