Formatting JATS
as easy as 1-2-3
Tony Graham
Mentea
13 Kelly’s Bay Beach
Skerries, Co Dublin, Ireland
info@mentea.net
@MenteaXML
http://www.mentea.net
Version 1.0 – 2 April 2014
© 2014 Mentea
All rights reserved. The author grants the U.S. National Library of
Medicine permission to archive and post a copy of this paper on the
Journal Article Tag Suite Conference proceedings website.
Enable pdf thumbnails in - Library application class:C# PDF Thumbnail Create SDK: Draw thumbnail images for PDF in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
Enable pdf thumbnails in - Library application class:VB.NET PDF Thumbnail Create SDK: Draw thumbnail images for PDF in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Support Thumbnail Generation with Various Options for Quick PDF Navigation
www.rasteredge.com
Library application class:VB.NET PDF File Compress Library: Compress reduce PDF size in vb.
Embedded page thumbnails. outputFilePath = Program.RootPath + "\\" 3_optimized.pdf"; 'create optimizing for Monochrome Image 'to enable dowmsampling for
www.rasteredge.com
Library application class:C# PDF File Compress Library: Compress reduce PDF size in C#.net
Embedded page thumbnails. outputFilePath = Program.RootPath + "\\" 3_optimized.pdf"; // create optimizing Monochrome Image -- // to enable downsampling for
www.rasteredge.com
Formatting JATS
as easy as 1-2-3
JATS Preview stylesheets
5
Aside: GitHub
11
XSLT 1.0: Government body
11
XSLT 2.0: PLOS ONE
15
XSLT 3.0: xslt3testbed
21
References
24
Appendix A – 
About
25
Formatting JATS
Library application class:C# HTML5 PDF Viewer SDK to view, annotate, create and convert PDF
framework class. An advanced PDF editor enable C# users to edit PDF text, image and pages in Visual Studio .NET project. Support to
www.rasteredge.com
Library application class:C# HTML5 PDF Viewer SDK deployment on IIS in .NET
and set the “Physical path” to the place where you store XDoc.PDF.HTML5 Viewer Demo. Pool Defaults…" in the right panel, and set the value "Enable 32-Bit
www.rasteredge.com
Mentea
4
© 2014 Mentea
Library application class:VB.NET PDF - VB.NET HTML5 PDF Viewer Deployment on IIS
and set the “Physical path” to the place where you store XDoc.PDF.HTML5 Viewer Demo. Pool Defaults…" in the right panel, and set the value "Enable 32-Bit
www.rasteredge.com
Library application class:C# PDF Page Rotate Library: rotate PDF page permanently in C#.net
Enable batch changing PDF page orientation without other PDF reader control. Support to overwrite PDF and save rotation changes to original PDF file.
www.rasteredge.com
Formatting JATS: as easy as 1-2-3
1
• JATS Preview stylesheets
• XSLT 1.0
• XSLT 2.0
• XSLT 3.0
The 1-2-3 comes from using JATS with three versions of XSLT.
JATS Preview stylesheets
2
https://github.com/NCBITools/JATSPreviewStylesheets
• XSLT 1.0
• Public domain
• No copyright issues
• Developed for NCBI by Mulberry Technologies
JATS Preview with “selfie”
3
Paper for this talk formatted using JATS Preview stylesheet with picture of paper formatted
using JATS preview stylesheets.
(‘selfie’ was added to the OED in 2013 so maybe it doesn’t need quotes)
Formatting JATS
Library application class:C# Create PDF from OpenOffice to convert odt, odp files to PDF in
with XDoc.PDF SDK. Enable C#.NET Users to Create PDF OpenOffice Document (Odt, Ods, Odp) from PDF with .NET PDF Library in C# Class.
www.rasteredge.com
Library application class:VB.NET PDF metadata library: add, remove, update PDF metadata in
VB.NET PDF - Read and Write PDF Metadata in VB.NET. Enable VB.NET Users to Read, Write, Edit, Delete and Update PDF Document Metadata in Visual Basic .NET.
www.rasteredge.com
Reconstructed timeline
4
2000
2010
2015
2005
XSLT 1.0
Initial design
NLM Preview
release
JATS Preview 1.0
XSLT 2.0
XSLT 3.0 ?
Reconstructed from comments in code, downloads, and emails with Kim Tryka and Tommie
Usdin.
Why still XSLT 1.0 in 2012?
5
• XSLT 1.0 still dominant on some platforms
• .NET
• Linux/Unix
• Also tested with XSLT 2.0
• NLM stylesheets developed circa 2006/2007
• One well-known XSLT 2.0 processor
• Java only
What does it do?
6
• Preprocessing
• Convert OASIS tables to HTML tables
• Massage citation format
• Some require XSLT 2.0
• Formatting
• XML to HTML
• XML to XSL-FO for formatting as PDF
• Post-processing
• HTML to XHTML for MathML
The only part that I’ve needed to use, and the only part being covered, is the transformation
to XSL-FO and formatting to PDF.
Mentea
6
© 2014 Mentea
Library application class:VB.NET PDF Text Extract Library: extract text content from PDF
Enable extracting PDF text to another PDF file, and other formats such as TXT and SVG form. OCR text from scanned PDF by working with XImage.OCR SDK.
www.rasteredge.com
Library application class:C# PDF Text Extract Library: extract text content from PDF file in
Enable extracting PDF text to another PDF file, TXT and SVG formats. Support extracting OCR text from PDF by working with XImage.OCR SDK.
www.rasteredge.com
Customizability
7
“These stylesheets are provided as a point of entry for JATS users who may not have the
resources to create them from scratch. Because there are many varied implementations of JATS,
you should have no expectation that these stylesheets will create production ready files in any
arbitrary system. Instead, the stylesheets should be customized for your particular needs.”
“Because we view these stylesheets as a template for a customized solution, not the solution
itself, we will accept changes that fix an actual bug, but we will not merge in changes that we view
as “customization”. For example, we will accept changes that fix a problem which otherwise leads
to failure in creating a final output file, but we will not accept changes that focus on presentational
aspects of the final output (such as font changes, margin changes, graphics sizing, etc).”
Statement about customisation from JATSPreviewStylesheets README with added
emphasis.
XSLT features supporting customizability
8
• Templates
• Modular stylesheets
• Named attribute sets
Templates
9
• match matches a context in source XML
• Content of xsl:template instantiated when template is applied
<xsl:template match="td">
<fo:table-cell xsl:use-attribute-sets="td">
<xsl:call-template name="process-table-cell"/>
</fo:table-cell>
</xsl:template>
Elements in the body of the template not in the XSLT namespace are copied to the result,
and elements and attributes in the XSLT namespace are acted on by the XSLT processor.
Formatting JATS
Modular stylesheets
10
<xsl:include
href = uri-reference />
• href refers to other stylesheet
• Children of other xsl:stylesheet replace xsl:include
<xsl:import
href = uri-reference />
• href refers to other stylesheet
• Imported definitions and template rules not part of importing stylesheet
• Have lower import precedence
Imports in JATS XSL-FO preview
11
xhtml-tables-fo.xsl
xsl:include
xsl:import
jats-xslfo.xsl
There are more interesting block diagrams later.
Overriding templates
12
• Template in importing stylesheet overrides same context in imported
• Good when overriding complete function of template
• Extra overhead if you just want to change one little thing
Mentea
8
© 2014 Mentea
Attribute sets
13
• Named set of attribute definitions
• Use in multiple places
• Definitions evaluated in each context where used
<xsl:attribute-set name="fig">
<xsl:attribute name="keep-together.within-page"
>always</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="generate-id()" />
</xsl:attribute>
</xsl:attribute-set>
Since attribute definitions in attribute sets are evaluated each time the attribute set is used,
the value of the id attribute will be unique to each context.
JATS Preview supporting customizability
14
• Global variables
• Attribute sets
• Named templates
Formatting JATS
Example customization
15
• Add to attribute set from JATS stylesheets
<xsl:attribute-set name="td">
<xsl:attribute name="line-stacking-strategy"
>max-height</xsl:attribute>
</xsl:attribute-set>
• New attribute set reusing merged td attribute set
<xsl:attribute-set name="td-small"
use-attribute-sets="td">
<xsl:attribute name="line-height">10pt</xsl:attribute>
<xsl:attribute name="border">none</xsl:attribute>
<xsl:attribute name="padding-top">0pt</xsl:attribute>
<xsl:attribute name="padding-bottom">0pt</xsl:attribute>
</xsl:attribute-set>
• Override JATS stylesheet in more-specific context
<xsl:template
match="td[ancestor::table[@style = 'small']]">
<fo:table-cell xsl:use-attribute-sets="td-small">
<xsl:call-template name="process-table-cell"/>
</fo:table-cell>
</xsl:template>
The xsl:attribute-set extends the ‘td’ defined in the JATS Preview stylesheet.
The new ‘td-small’ attribute set includes the attribute definitions from all declarations for the
‘td’ attribute set plus the definitions contained in its definition.
The template matches on a more-specific context than the general-purpose template for td
in the JATS Preview stylesheets, so in those particular contexts, the XSLT processor uses this
template, which adds a different set of attributes to the generated fo:table-cell but
which still uses the ‘process-table-cell” named template from the JATS Preview stylesheets as
is used in the original template for td.
This illustrates in a nutshell how a customisation is able to extend, override, and reuse the
constructs in the core JATS Preview stylesheets.
Summary: JATS Preview
16
• XSLT 1.0
• Not accepting customisations into core
• Stylesheet structure facilitates customisations
Mentea
10
© 2014 Mentea
Documents you may be interested
Documents you may be interested