SlideShare a Scribd company logo
XSLT 3 for EPUB and Print
Liam Quin
Delightful Computing
ebookcraft 2019/Logistics
– Restrooms
– Breaks
– Refreshments
ebookcraft 2019/Schedule
●
This is all about using XSLT 3;
●
It’s a lot of fun
●
Are you in the right place? Of course you are!
Agenda
●
Introductions;
●
Background: XML, XPath, XSLT
●
Version Two: XQuery, XSD, Maturity
●
Version Three: Floods of Joy
●
Helpful Resources
●
Discussion & Doing Together
Introductions
●
I’m Liam Quin, former XML Activity lead at
W3C, background in digital typography,
programming, computer science, information
architecture. See www.delightfulcomputing.com
.
●
More important: who are you? Who is using
XSLT? Who isn’t? Who is making ebooks?
What’s XSLT
●
Functional Programming Language
●
Super Easy and Fun
●
Domain-Specific Language for Trees
●
Text Processing without programming
●
Batch way to convert tons of stuff to other stuff!
●
W3C Standard: books, tutorials, people
Functional Programming Language
●
Don’t be intimidated, you can ignore this slide.
●
Buzzword compliance: referential transparency,
lambda expressions, declarative, implicit
dispatch, domain-specific language…
●
The only important one: declarative…
Declarative Programming
●
It’s about telling the computer the result you
want, and letting the computer figure out how to
get there all by itself!
●
As opposed to imperative languages (Python,
Java, C, JavaScript, …) where you have to say
how to get there but never describe the result.
The Computer is Your Happy Slave
●
Is it really programming if the computer does
the hard parts?
●
Yes, but you don’t have to be a programmer!
●
It is as powerful as an imperative language?
●
Yes, and it’s ideally suited for ebooks!
Time for an example
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="book">
<hello>Hello, EBookCraft!</hello>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="book">
<hello>Hello, EBookCraft!</hello>
</xsl:template>
</xsl:stylesheet>
Eg01.xsl
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
It’s a stylesheet; you can call it xsl:transform if you prefer.
XSLT was originally designed for formatting and publishing.
</xsl:stylesheet>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
It’s a stylesheet; you can call it xsl:transform if you prefer.
XSLT was originally designed for formatting and publishing.
</xsl:stylesheet>
Eg01.xsl
<xsl:template match="book">
<hello>Hello, EBookCraft!</hello>
</xsl:template>
Any elements in the input called book should be
transformed into “hello” elements in the output.
<xsl:template match="book">
<hello>Hello, EBookCraft!</hello>
</xsl:template>
Any elements in the input called book should be
transformed into “hello” elements in the output.
Run the example
Domain-specific language
●
XSLT uses an XML syntax overall;
●
Expressions are in a W3C language called
XPath;
●
XPath has functions, data types, operators,
if/else, but most importantly it’s a domain-
specific language itself! For navigating trees!
●
This is so awesome!
Some sample XPath expressions
(: this is a comment, between smiles! :)
/book/chapter[3]/footnote
A list of all footnotes in the third chapter element
(//table//td[. = 300]/following-sibling::td)[1]
The first in a list of td elements with the same parent
as, and following, a td with content of 300
somewhere in a table!
Talk about Trees
Computer Science Trees
●
Computer scientists all live in basements with no
windows, and we think trees grow down from the
ground, with the roots at the top and the leaves
far, far, beneath our feet.
●
A tree is a way of representing information in a
computer: as a hierarchy.
●
Maybe computer scientists can’t spell hier… um?
A Document Tree
Eg01.xml
Eg01 with tree
eg01.xml tree
It’s all about Relationships
●
XPath axes are not about “Turtle Graphics” but
about the relationships between nodes in the
tree.
●
Our tree came from XML. In XSLT 3 it might
have come from JSON or even RDF.
●
There can be many trees in a forest.
XSLT 3 Inputs
●
Default input is still a single XML file;
●
A different SAX parser might read e.g. HTML;
●
Can now read binary file, text and JSON;
●
EXPath extension functions can read ZIP;
●
Can make a tree from XML in a ZIP archive!
●
A W E S O M E N E S S I N C A R N A T E
Reading an EPUB file
<xsl:variable name="thebook"
select="file:read-binary($inputfile)" />
<xsl:variable name="container"
select="archive:extract-text(
$thebook, 'META-INF/container.xml')" />
<xsl:variable name="cxml" as="document-node()"
select="parse-xml($container)" />
Reminder
Finding the OPF file
<xsl:variable name="where-to-look" as="xs:string"
select="$cxml//*:rootfile/@full-path" />
<xsl:variable name="the-opf" as="document-node()"
select="parse-xml(archive:extract-text(
$thebook, $where-to-look))" />
<xsl:value-of select="$the-opf//dc:title" />
What have we done?
●
We read an epub zip file into memory;
●
We extracted container.xml from it;
●
We looked inside container.xml and found the
name of the content.opf file;
●
We looked in that and found the title of the book
that’s in the epub zip file!
What else could we do?
●
We can write to a zip archive too;
●
We can update an existing zip archive;
●
We can merge zip archives, so that we can
handle different compression for different files;
●
With this, we can write an epub file!
Asweome Moreness!
The single most important new feature in
XSLT 3
Is called . . .
Are You Ready?
fn:transform()
●
Run another transformation from within XSLT:
<xsl:sequence select='transform(
map {
"stylesheet-location" : "mkcards.xsl",
"source-node" : $toc
}
)?output' />
Maps
●
Before we can understand fn:tranform we need
to grok maps and arrays
●
Arrays are in XPath 3.1, maps in 3.0 and 3.1
●
Array: let $a := [ 4, 5, 6 ] return $a(1)
●
Let $b := map { "venue" : "Toronto", "coolness" :
11 } return $b?”venue”
Fn:transform return value
●
The fn:transform() function returns a map
whose keys are URIs (filenames!) with
corresponding values being the file contents.
●
The special key “output” gives the direct result
of the stylesheet.
●
Xsl:result-document goes to the map; file:write
happens directly.
So What?
●
XSLT 3 can read an epub file, write an epub file,
read and write JSON, XML, HTML, text,
images, zip archives…
●
You don’t need external scripts or pipelines to
make ebooks any more! One stylesheet! And
it’s not even very complicated.
All-XSLT advantages
●
Character encodings are handled in the Web
way at every stage;
●
Namespace URIs, XHTML syntax, consistent
treatment of text..
●
Same person can maintain entire workflow;
●
XSLT is a domain-specific language for markup!
So can we really…
…write zip files?
●
First, read a zip file:
<xsl:variable name="base-archive"
as="xs:base64Binary"
select="file:read-binary('mimetype.zip')" />
…zip ties are fun…
●
So now $base-archive contains a zip archive.
Let’s add some more files to it:
arch:update(
$archive as xs:base64Binary,
$entries as xs:string*,
$new as xs:base64Binary*) as xs:base64Binary
Zippitty doohdah
<xsl:variable name="the-zip-archive"
as="xs:base64Binary"
select="archive:update($base-archive,
$filenames,
$contents-of-those-files-in-base64
)" />
Zippitty doohdah
<xsl:variable name="the-zip-archive"
as="xs:base64Binary"
select="archive:update($base-archive,
$name-value-list[ ( position() mod 2) eq 1 ],
$name-value-list[ ( position() mod 2) eq 0 ]
)" />
Big Fat Zip
●
So now $the-zip-archive is a zip archive full of
happy stuff. Let’s write it out:
<xsl:value-of select="file:write-binary(
'hairyplodder.epub', $the-zip-archive)" />
Time to rest for a moment
XSLT 3 More Betterness
●
Parse-xml(), parse-json(), serialize();
●
Lots of new functions;
●
More regular expression support;
●
Contains-token() for HTML class attributes;
●
HTML 5 output (read HTML e.g. with TagSoup)
●
Parse-date() helps with metadata
not(xslt = boring)
●
R

More Related Content

What's hot

Django
DjangoDjango
Django
Kangjin Jun
 
Effective modern c++ 5
Effective modern c++ 5Effective modern c++ 5
Effective modern c++ 5
uchan_nos
 
Html ppt
Html pptHtml ppt
Html ppt
Ruchi Kumari
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
BBDITM LUCKNOW
 
파이썬 Numpy 선형대수 이해하기
파이썬 Numpy 선형대수 이해하기파이썬 Numpy 선형대수 이해하기
파이썬 Numpy 선형대수 이해하기
Yong Joon Moon
 
Html color codes
Html color codesHtml color codes
Html color codes
Niraj Bharambe
 
CSS corso base (classi seconde, mod 1)
CSS corso base (classi seconde, mod 1)CSS corso base (classi seconde, mod 1)
CSS corso base (classi seconde, mod 1)
Matteo Ziviani
 
Boyer more algorithm
Boyer more algorithmBoyer more algorithm
Boyer more algorithm
Kritika Purohit
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentationAdhoura Academy
 
Interop with c in clojure
Interop with c in clojureInterop with c in clojure
Interop with c in clojure
EunPyoung Kim
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
상욱 송
 
Typedef
TypedefTypedef
Typedef
vaseemkhn
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Mahzad Zahedi
 
C# File IO Operations
C# File IO OperationsC# File IO Operations
C# File IO Operations
Prem Kumar Badri
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentationarnolambert
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular ExpressionMasudul Haque
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 

What's hot (20)

Django
DjangoDjango
Django
 
Effective modern c++ 5
Effective modern c++ 5Effective modern c++ 5
Effective modern c++ 5
 
Html ppt
Html pptHtml ppt
Html ppt
 
Compiler unit 2&3
Compiler unit 2&3Compiler unit 2&3
Compiler unit 2&3
 
파이썬 Numpy 선형대수 이해하기
파이썬 Numpy 선형대수 이해하기파이썬 Numpy 선형대수 이해하기
파이썬 Numpy 선형대수 이해하기
 
Html color codes
Html color codesHtml color codes
Html color codes
 
CSS corso base (classi seconde, mod 1)
CSS corso base (classi seconde, mod 1)CSS corso base (classi seconde, mod 1)
CSS corso base (classi seconde, mod 1)
 
Boyer more algorithm
Boyer more algorithmBoyer more algorithm
Boyer more algorithm
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Interop with c in clojure
Interop with c in clojureInterop with c in clojure
Interop with c in clojure
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Let's Go (golang)
Let's Go (golang)Let's Go (golang)
Let's Go (golang)
 
Typedef
TypedefTypedef
Typedef
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
 
C# File IO Operations
C# File IO OperationsC# File IO Operations
C# File IO Operations
 
Regex Presentation
Regex PresentationRegex Presentation
Regex Presentation
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 

Similar to XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft 2019

Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet LanguageJussi Pohjolainen
 
XML XSLT
XML XSLTXML XSLT
The Case for Authoring and Producing Books in (X)HTML5
The Case for Authoring and Producing Books in (X)HTML5The Case for Authoring and Producing Books in (X)HTML5
The Case for Authoring and Producing Books in (X)HTML5
Sanders Kleinfeld
 
CTDA Workshop on XSL
CTDA Workshop on XSLCTDA Workshop on XSL
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
BookNet Canada
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
Mahmoud Allam
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & Servlets
Anton Keks
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
TUSHAR VARSHNEY
 
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
BookNet Canada
 
Xslt
XsltXslt
Xml iet 2015
Xml iet 2015Xml iet 2015
Xml iet 2015
kiransurariya
 
Chapter4
Chapter4Chapter4
Chapter4
Fahad Sheref
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
Kumar
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
Dr.Saranya K.G
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2Marco Gralike
 
03 x files
03 x files03 x files
03 x files
Baskarkncet
 

Similar to XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft 2019 (20)

Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet Language
 
XML XSLT
XML XSLTXML XSLT
XML XSLT
 
The Case for Authoring and Producing Books in (X)HTML5
The Case for Authoring and Producing Books in (X)HTML5The Case for Authoring and Producing Books in (X)HTML5
The Case for Authoring and Producing Books in (X)HTML5
 
CTDA Workshop on XSL
CTDA Workshop on XSLCTDA Workshop on XSL
CTDA Workshop on XSL
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
 
Introduction to XSLT
Introduction to XSLTIntroduction to XSLT
Introduction to XSLT
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & Servlets
 
Introduction of xml and xslt
Introduction of xml and xsltIntroduction of xml and xslt
Introduction of xml and xslt
 
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
You Want to Go XML-First: Now What? Building an In-House XML-First Workflow -...
 
Xslt
XsltXslt
Xslt
 
Xslt
XsltXslt
Xslt
 
Xml iet 2015
Xml iet 2015Xml iet 2015
Xml iet 2015
 
Chapter4
Chapter4Chapter4
Chapter4
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
 
XML Bible
XML BibleXML Bible
XML Bible
 
Xslt
XsltXslt
Xslt
 
XML Bible
XML BibleXML Bible
XML Bible
 
03 x files
03 x files03 x files
03 x files
 

More from BookNet Canada

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
BookNet Canada
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
BookNet Canada
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
BookNet Canada
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
BookNet Canada
 
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
BookNet Canada
 
Transcript: Book industry state of the nation 2024 - Tech Forum 2024
Transcript: Book industry state of the nation 2024 - Tech Forum 2024Transcript: Book industry state of the nation 2024 - Tech Forum 2024
Transcript: Book industry state of the nation 2024 - Tech Forum 2024
BookNet Canada
 
Book industry state of the nation 2024 - Tech Forum 2024
Book industry state of the nation 2024 - Tech Forum 2024Book industry state of the nation 2024 - Tech Forum 2024
Book industry state of the nation 2024 - Tech Forum 2024
BookNet Canada
 
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
BookNet Canada
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
BookNet Canada
 
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
BookNet Canada
 
Show and tell: What’s in your tech stack? - Tech Forum 2023
Show and tell: What’s in your tech stack? - Tech Forum 2023Show and tell: What’s in your tech stack? - Tech Forum 2023
Show and tell: What’s in your tech stack? - Tech Forum 2023
BookNet Canada
 
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
BookNet Canada
 
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada
 

More from BookNet Canada (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
Transcript: Green paths: Learning from publishers’ sustainability journeys - ...
 
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
Green paths: Learning from publishers’ sustainability journeys - Tech Forum 2024
 
Transcript: Book industry state of the nation 2024 - Tech Forum 2024
Transcript: Book industry state of the nation 2024 - Tech Forum 2024Transcript: Book industry state of the nation 2024 - Tech Forum 2024
Transcript: Book industry state of the nation 2024 - Tech Forum 2024
 
Book industry state of the nation 2024 - Tech Forum 2024
Book industry state of the nation 2024 - Tech Forum 2024Book industry state of the nation 2024 - Tech Forum 2024
Book industry state of the nation 2024 - Tech Forum 2024
 
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
Trending now: Book subjects on the move in the Canadian market - Tech Forum 2024
 
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...Transcript: Trending now: Book subjects on the move in the Canadian market - ...
Transcript: Trending now: Book subjects on the move in the Canadian market - ...
 
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...Transcript: New stores, new views: Booksellers adapting engaging and thriving...
Transcript: New stores, new views: Booksellers adapting engaging and thriving...
 
Show and tell: What’s in your tech stack? - Tech Forum 2023
Show and tell: What’s in your tech stack? - Tech Forum 2023Show and tell: What’s in your tech stack? - Tech Forum 2023
Show and tell: What’s in your tech stack? - Tech Forum 2023
 
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
Transcript: Show and tell: What’s in your tech stack? - Tech Forum 2023
 
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
 

Recently uploaded

Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 

Recently uploaded (17)

Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 

XSLT 3 for EPUB and Print - Liam R.E. Quin (Barefoot Computing) - ebookcraft 2019

  • 1. XSLT 3 for EPUB and Print Liam Quin Delightful Computing
  • 3. ebookcraft 2019/Schedule ● This is all about using XSLT 3; ● It’s a lot of fun ● Are you in the right place? Of course you are!
  • 4. Agenda ● Introductions; ● Background: XML, XPath, XSLT ● Version Two: XQuery, XSD, Maturity ● Version Three: Floods of Joy ● Helpful Resources ● Discussion & Doing Together
  • 5. Introductions ● I’m Liam Quin, former XML Activity lead at W3C, background in digital typography, programming, computer science, information architecture. See www.delightfulcomputing.com . ● More important: who are you? Who is using XSLT? Who isn’t? Who is making ebooks?
  • 6. What’s XSLT ● Functional Programming Language ● Super Easy and Fun ● Domain-Specific Language for Trees ● Text Processing without programming ● Batch way to convert tons of stuff to other stuff! ● W3C Standard: books, tutorials, people
  • 7. Functional Programming Language ● Don’t be intimidated, you can ignore this slide. ● Buzzword compliance: referential transparency, lambda expressions, declarative, implicit dispatch, domain-specific language… ● The only important one: declarative…
  • 8. Declarative Programming ● It’s about telling the computer the result you want, and letting the computer figure out how to get there all by itself! ● As opposed to imperative languages (Python, Java, C, JavaScript, …) where you have to say how to get there but never describe the result.
  • 9. The Computer is Your Happy Slave ● Is it really programming if the computer does the hard parts? ● Yes, but you don’t have to be a programmer! ● It is as powerful as an imperative language? ● Yes, and it’s ideally suited for ebooks!
  • 10. Time for an example <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="book"> <hello>Hello, EBookCraft!</hello> </xsl:template> </xsl:stylesheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="book"> <hello>Hello, EBookCraft!</hello> </xsl:template> </xsl:stylesheet>
  • 11. Eg01.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> It’s a stylesheet; you can call it xsl:transform if you prefer. XSLT was originally designed for formatting and publishing. </xsl:stylesheet> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> It’s a stylesheet; you can call it xsl:transform if you prefer. XSLT was originally designed for formatting and publishing. </xsl:stylesheet>
  • 12. Eg01.xsl <xsl:template match="book"> <hello>Hello, EBookCraft!</hello> </xsl:template> Any elements in the input called book should be transformed into “hello” elements in the output. <xsl:template match="book"> <hello>Hello, EBookCraft!</hello> </xsl:template> Any elements in the input called book should be transformed into “hello” elements in the output.
  • 14. Domain-specific language ● XSLT uses an XML syntax overall; ● Expressions are in a W3C language called XPath; ● XPath has functions, data types, operators, if/else, but most importantly it’s a domain- specific language itself! For navigating trees! ● This is so awesome!
  • 15. Some sample XPath expressions (: this is a comment, between smiles! :) /book/chapter[3]/footnote A list of all footnotes in the third chapter element (//table//td[. = 300]/following-sibling::td)[1] The first in a list of td elements with the same parent as, and following, a td with content of 300 somewhere in a table!
  • 17. Computer Science Trees ● Computer scientists all live in basements with no windows, and we think trees grow down from the ground, with the roots at the top and the leaves far, far, beneath our feet. ● A tree is a way of representing information in a computer: as a hierarchy. ● Maybe computer scientists can’t spell hier… um?
  • 22. It’s all about Relationships ● XPath axes are not about “Turtle Graphics” but about the relationships between nodes in the tree. ● Our tree came from XML. In XSLT 3 it might have come from JSON or even RDF. ● There can be many trees in a forest.
  • 23. XSLT 3 Inputs ● Default input is still a single XML file; ● A different SAX parser might read e.g. HTML; ● Can now read binary file, text and JSON; ● EXPath extension functions can read ZIP; ● Can make a tree from XML in a ZIP archive! ● A W E S O M E N E S S I N C A R N A T E
  • 24. Reading an EPUB file <xsl:variable name="thebook" select="file:read-binary($inputfile)" /> <xsl:variable name="container" select="archive:extract-text( $thebook, 'META-INF/container.xml')" /> <xsl:variable name="cxml" as="document-node()" select="parse-xml($container)" />
  • 26. Finding the OPF file <xsl:variable name="where-to-look" as="xs:string" select="$cxml//*:rootfile/@full-path" /> <xsl:variable name="the-opf" as="document-node()" select="parse-xml(archive:extract-text( $thebook, $where-to-look))" /> <xsl:value-of select="$the-opf//dc:title" />
  • 27. What have we done? ● We read an epub zip file into memory; ● We extracted container.xml from it; ● We looked inside container.xml and found the name of the content.opf file; ● We looked in that and found the title of the book that’s in the epub zip file!
  • 28. What else could we do? ● We can write to a zip archive too; ● We can update an existing zip archive; ● We can merge zip archives, so that we can handle different compression for different files; ● With this, we can write an epub file!
  • 29. Asweome Moreness! The single most important new feature in XSLT 3 Is called . . .
  • 31. fn:transform() ● Run another transformation from within XSLT: <xsl:sequence select='transform( map { "stylesheet-location" : "mkcards.xsl", "source-node" : $toc } )?output' />
  • 32. Maps ● Before we can understand fn:tranform we need to grok maps and arrays ● Arrays are in XPath 3.1, maps in 3.0 and 3.1 ● Array: let $a := [ 4, 5, 6 ] return $a(1) ● Let $b := map { "venue" : "Toronto", "coolness" : 11 } return $b?”venue”
  • 33. Fn:transform return value ● The fn:transform() function returns a map whose keys are URIs (filenames!) with corresponding values being the file contents. ● The special key “output” gives the direct result of the stylesheet. ● Xsl:result-document goes to the map; file:write happens directly.
  • 34. So What? ● XSLT 3 can read an epub file, write an epub file, read and write JSON, XML, HTML, text, images, zip archives… ● You don’t need external scripts or pipelines to make ebooks any more! One stylesheet! And it’s not even very complicated.
  • 35. All-XSLT advantages ● Character encodings are handled in the Web way at every stage; ● Namespace URIs, XHTML syntax, consistent treatment of text.. ● Same person can maintain entire workflow; ● XSLT is a domain-specific language for markup!
  • 36. So can we really…
  • 37. …write zip files? ● First, read a zip file: <xsl:variable name="base-archive" as="xs:base64Binary" select="file:read-binary('mimetype.zip')" />
  • 38. …zip ties are fun… ● So now $base-archive contains a zip archive. Let’s add some more files to it: arch:update( $archive as xs:base64Binary, $entries as xs:string*, $new as xs:base64Binary*) as xs:base64Binary
  • 41. Big Fat Zip ● So now $the-zip-archive is a zip archive full of happy stuff. Let’s write it out: <xsl:value-of select="file:write-binary( 'hairyplodder.epub', $the-zip-archive)" />
  • 42. Time to rest for a moment
  • 43. XSLT 3 More Betterness ● Parse-xml(), parse-json(), serialize(); ● Lots of new functions; ● More regular expression support; ● Contains-token() for HTML class attributes; ● HTML 5 output (read HTML e.g. with TagSoup) ● Parse-date() helps with metadata