XML Workflows: Tools and Automation

Because we use XML we can’t just dump our code in the browser or the PDF viewer and expect it to appear just like HTML content. We need to prepare our content for conversion to PDF before we can view it. There are also front-end web development best practices to follow. This chapter will discuss tools to accomplish both tasks from one build file. What software we need For this to work you need the following software installed: Java (version 1.7 or later) Node.js (0.10.35 or later) Once you have java installed, you can install the following Java packages Saxon

XML Workflows: CSS Styles for Paged Media

This is the generated CSS from the SCSS style sheets (see the scss/ directory for the source material.) I’ve chosen to document the resulting stylesheet here and document the SCSS source in another document to make life simpler for people who don’t want to deal with SASS or who want to see what the style sheets look like. Typography derived from work done at this URL: http://bit.ly/16N6Y2Q The following scale (also using minor third progression) may also help: http://bit.ly/1DdVbqK Feel free to play with these and use them as starting point for your own work 🙂 The project currently uses

XML Wokflows: From XML to PDF: Part 2: CSS

With the HTML ready, we can no look at the CSS stylesheet to process it into PDF. The extensions, pseudo elements and attributes we use are all part of the CSS Paged Media or Generated Content for Paged Media specifications. Where appropriate I’ve translated them to work on both PDF and HTML. Book defaults The first step in creating the default structure for the book using @page at-element. Our base definition does the following: Size the page to letter (8.5 by 11 inches), width first Use CSS notation for margins. In this case the top and bottom margin are 0.5

XML Wokflows: From XML to PDF: Part 1: Special Transformation

Rather than having to deal with XSL-FO, another XML based vocabulary to create PDF content, we’ll use XSLT to create another HTML file and process it with CSS Paged Media and the companion Generated Content for Paged Media specifications to create PDF content. I’m not against XSL-FO but the structure of document is not the easiest or most intuitive. An example of XSL-FO looks like this: <?xml version=”1.0″ encoding=”iso-8859-1″?> (1) <fo:root xmlns:fo=”http://www.w3.org/1999/XSL/Format”> (2) <fo:layout-master-set> (3) <fo:simple-page-master master-name=”my-page”> <fo:region-body margin=”1in”/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference=”my-page”> (4) <fo:flow flow-name=”xsl-region-body”> (5) <fo:block>Hello, world!</fo:block> (6) </fo:flow> </fo:page-sequence> </fo:root> This is an XML declaration. XSL FO

XML workflows: Converting our content to HTML

One of the biggest advantages of working with XML is that we can convert the abstract tags into other markups. For the purposes of this project we’ll convert the XML created to match the schema we just created to HTML and then use tools like PrinceXML or AntenaHouse we’ll convert the HTML/CSS files to PDF Why HTML HTML is the default format for the web and for most web/html based content such as ePub and Kindle. As such it makes a perfect candidate to explore how to generate it programmatically from a single source file. HTML will also act as