<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:px="http://www.daisy.org/ns/pipeline/xproc" xmlns:cx="http://xmlcalabash.com/ns/extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dtbook="http://www.daisy.org/z3986/2005/dtbook/" xmlns:d="http://www.daisy.org/ns/pipeline/data" xmlns:m="http://www.w3.org/1998/Math/MathML" version="1.0" type="px:dtbook-to-daisy3" name="main" exclude-inline-prefixes="#all"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h1>DTBook to DAISY 3</h1> <p>Converts a single dtbook to DAISY 3 format</p> </p:documentation> <p:input port="in-memory.in" primary="true" sequence="true"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>2005 DTBook file</h2> <p>It contains the DTBook file to be transformed. Any other document will be ignored.</p> </p:documentation> </p:input> <p:input port="tts-config"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Text-To-Speech configuration file</h2> <p>Configuration file with voice mappings, PLS lexicons and annotations.</p> </p:documentation> <p:inline><d:config/></p:inline> </p:input> <p:option name="stylesheet" select="''"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>CSS style sheets as space separated list of absolute URIs.</p> </p:documentation> </p:option> <p:option name="lexicon" cx:as="xs:anyURI*" select="()"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>PLS lexicons as list of absolute URIs.</p> </p:documentation> </p:option> <p:output port="in-memory.out" primary="true" sequence="true"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Output documents</h2> <p>The SMIL files, the NCX file, the resource file, the OPF file and the input DTBook file updated in order to be linked with the SMIL files.</p> </p:documentation> <p:pipe step="convert" port="in-memory"/> </p:output> <p:output port="temp-audio-files" sequence="true"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>List of audio files</h2> <p>List of audio files generated by the TTS step. May be deleted when the result fileset is stored.</p> </p:documentation> <p:pipe step="convert" port="temp-audio-files"/> </p:output> <p:output port="validation-status" px:media-type="application/vnd.pipeline.status+xml"> <p:pipe step="convert" port="validation-status"/> </p:output> <p:option name="include-tts-log" select="'false'"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>Whether or not to make the TTS log available on the "tts-log" port.</p> </p:documentation> </p:option> <p:output port="tts-log" sequence="true"> <p:pipe step="convert" port="tts-log"/> </p:output> <p:input port="fileset.in"> <p:documentation> A fileset containing references to all the DTBook files and any resources they reference (images etc.). The xml:base is also set with an absolute URI for each file, and is intended to represent the "original file", while the href can change during conversions to reflect the path and filename of the resource in the output fileset. </p:documentation> </p:input> <p:output port="fileset.out"> <p:documentation> A fileset containing references to the DTBook files and any resources it references (images etc.). For each file that is not stored in memory, the xml:base is set with an absolute URI pointing to the location on disk where it is stored. This lets the href reflect the path and filename of the resulting resource without having to store it. This is useful for chaining conversions. </p:documentation> <p:pipe step="convert" port="fileset"/> </p:output> <p:option name="publisher" required="false" select="''"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Publisher</h2> <p>The agency responsible for making the Digital Talking Book available. If left blank, it will be retrieved from the DTBook meta-data.</p> </p:documentation> </p:option> <p:option name="output-fileset-base" required="true"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Ouput fileset's base</h2> <p>fileset.out's base directory, which is the directory where the DAISY 3 publication will be stored if the user intends to store it with no further transformation.</p> </p:documentation> </p:option> <p:option name="audio" required="false" cx:as="xs:boolean" select="true()"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Enable text-to-speech</h2> <p>Whether to use a speech synthesizer to produce audio files.</p> </p:documentation> </p:option> <p:option name="audio-only" required="false" cx:as="xs:boolean" select="true()"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <h2>Audio only</h2> <p>SMIL files are not attached to any DTBook</p> </p:documentation> </p:option> <p:option name="audio-file-type" select="'audio/mpeg'"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>The desired file type of the generated audio files, specified as a MIME type.</p> <p>Examples:</p> <ul> <li>"audio/mpeg"</li> <li>"audio/x-wav"</li> </ul> </p:documentation> </p:option> <p:option name="word-detection" required="false" cx:as="xs:boolean" select="true()"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>Whether to detect and mark up words with <code><w></code> tags.</p> </p:documentation> </p:option> <p:option name="date" required="false" select="''"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>Date of publication of the DTB</p> <p>Format must be YYYY[-MM[-DD]]</p> <p>Defaults to the date in the DTBook, or the current date.</p> </p:documentation> </p:option> <p:option name="temp-dir" required="false" select="''"> <p:documentation xmlns="http://www.w3.org/1999/xhtml"> <p>Empty directory dedicated to this step. If set, the directory will be used to store audio files. If not set, the audio files will be stored in temporary directory that is automatically created.</p> </p:documentation> </p:option> <p:import href="http://www.daisy.org/pipeline/modules/common-utils/library.xpl"> <p:documentation> px:assert </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/daisy3-utils/library.xpl"> <p:documentation> px:daisy3-prepare-dtbook px:daisy3-create-ncx px:daisy3-create-opf px:daisy3-create-res-file px:daisy3-create-smils </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl"> <p:documentation> px:fileset-rebase px:fileset-load px:fileset-copy px:fileset-move px:fileset-create px:fileset-add-entry px:fileset-join px:fileset-filter </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/dtbook-tts/library.xpl"> <p:documentation> px:tts-for-dtbook </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/smil-utils/library.xpl"> <p:documentation> px:audio-clips-to-fileset px:audio-clips-update-files </p:documentation> </p:import> <p:import href="http://www.daisy.org/pipeline/modules/file-utils/library.xpl"> <p:documentation> px:set-base-uri </p:documentation> </p:import> <p:identity> <p:input port="source"> <p:pipe step="main" port="fileset.in"/> </p:input> </p:identity> <px:assert message="No DTBook document found." error-code="PEZE00"> <p:with-option name="test" select="exists(/*/d:file[@media-type='application/x-dtbook+xml'])"/> </px:assert> <px:assert message="More than one DTBook found in fileset." error-code="PEZE00"> <p:with-option name="test" select="count(/*/d:file[@media-type='application/x-dtbook+xml'])=1"/> </px:assert> <px:fileset-rebase name="fileset.in"> <p:with-option name="new-base" select="/*/d:file[@media-type='application/x-dtbook+xml']/resolve-uri(@href,base-uri(/*))"/> </px:fileset-rebase> <px:fileset-load media-types="application/x-dtbook+xml"> <p:input port="in-memory"> <p:pipe step="main" port="in-memory.in"/> </p:input> </px:fileset-load> <px:assert message="Other versions than DTBook-2005 are not supported." error-code="C0051" name="dtbook"> <p:with-option name="test" select="(//dtbook:dtbook)[1]/@version/starts-with(., '2005')"/> </px:assert> <p:group name="convert"> <p:output port="fileset" primary="true"/> <p:output port="in-memory" sequence="true"> <p:pipe step="daisy3.in-memory" port="result"/> </p:output> <p:output port="validation-status"> <p:pipe step="validation-status" port="result"/> </p:output> <p:output port="tts-log" sequence="true"> <p:pipe step="tts" port="log"/> </p:output> <p:output port="temp-audio-files" sequence="true"> <p:pipe step="audio" port="mapping"/> </p:output> <p:variable name="uid" select="concat((//dtbook:meta[@name='dtb:uid'])[1]/@content, '-packaged')"/> <px:daisy3-prepare-dtbook name="prepare-dtbook"> <p:with-option name="uid" select="$uid"/> <p:with-option name="output-base-uri" select="concat($output-fileset-base, replace(base-uri(/),'^.*/([^/]+)$','$1'))"/> <p:input port="mathml-altimg-fallback"> <p:pipe step="mathml-altimg-fallback" port="result.fileset"/> </p:input> </px:daisy3-prepare-dtbook> <p:sink/> <px:fileset-filter media-types="text/css"> <p:input port="source"> <p:pipe step="fileset.in" port="result"/> </p:input> </px:fileset-filter> <px:fileset-copy name="css"> <p:input port="source.in-memory"> <p:pipe step="main" port="in-memory.in"/> </p:input> <p:with-option name="target" select="$output-fileset-base"/> </px:fileset-copy> <p:sink/> <px:fileset-join> <p:input port="source"> <p:pipe step="prepare-dtbook" port="result.fileset"/> <p:pipe step="css" port="result.fileset"/> </p:input> </px:fileset-join> <px:tts-for-dtbook process-css="true" name="tts" px:progress="1"> <p:input port="source.in-memory"> <p:pipe step="prepare-dtbook" port="result.in-memory"/> <p:pipe step="css" port="result.in-memory"/> </p:input> <p:input port="config"> <p:pipe step="main" port="tts-config"/> </p:input> <p:with-option name="stylesheet" select="$stylesheet"/> <p:with-option name="lexicon" select="$lexicon"/> <p:with-option name="audio" select="if ($audio) then 'true' else 'false'"/> <p:with-option name="audio-file-type" select="$audio-file-type"/> <p:with-option name="include-log" select="$include-tts-log"/> <p:with-option name="word-detection" select="if ($word-detection) then 'true' else 'false'"/> <p:with-option name="temp-dir" select="$temp-dir"/> </px:tts-for-dtbook> <px:fileset-load media-types="application/x-dtbook+xml" name="tts-enriched-dtbook"> <p:input port="in-memory"> <p:pipe step="tts" port="result.in-memory"/> </p:input> </px:fileset-load> <p:sink/> <p:rename match="/*" new-name="d:validation-status" name="validation-status"> <p:input port="source"> <p:pipe step="tts" port="status"/> </p:input> </p:rename> <p:sink/> <px:audio-clips-to-fileset> <p:input port="source"> <p:pipe step="tts" port="audio-map"/> </p:input> </px:audio-clips-to-fileset> <px:fileset-move flatten="true" name="audio"> <p:with-option name="target" select="$output-fileset-base"/> </px:fileset-move> <p:sink/> <px:audio-clips-update-files name="audio-map"> <p:input port="source"> <p:pipe step="tts" port="audio-map"/> </p:input> <p:input port="mapping"> <p:pipe step="audio" port="mapping"/> </p:input> </px:audio-clips-update-files> <p:sink/> <px:daisy3-create-smils name="mo" px:message="Generating SMIL files..."> <p:input port="source.fileset"> <p:pipe step="tts" port="result.fileset"/> </p:input> <p:input port="source.in-memory"> <p:pipe step="tts-enriched-dtbook" port="result"/> </p:input> <p:input port="audio-map"> <p:pipe step="audio-map" port="result"/> </p:input> <p:with-option name="smil-dir" select="$output-fileset-base"/> <p:with-option name="uid" select="$uid"/> <p:with-option name="audio-only" select="if ($audio-only) then 'true' else 'false'"/> </px:daisy3-create-smils> <p:sink/> <px:daisy3-create-ncx name="ncx"> <p:input port="content"> <p:pipe step="mo" port="dtbook.in-memory"/> </p:input> <p:input port="audio-map"> <p:pipe step="audio-map" port="result"/> </p:input> <p:with-option name="ncx-dir" select="$output-fileset-base"/> <p:with-option name="uid" select="$uid"/> </px:daisy3-create-ncx> <p:sink/> <px:daisy3-create-res-file name="res-file"> <p:with-option name="output-base-uri" select="concat($output-fileset-base,'resources.res')"/> </px:daisy3-create-res-file> <p:sink/> <p:choose name="mathml-xslt-fallback"> <p:xpath-context> <p:pipe step="tts-enriched-dtbook" port="result"/> </p:xpath-context> <p:when test="$audio-only or not(exists(//m:math))"> <p:output port="fileset" sequence="true"/> <p:identity> <p:input port="source"> <p:empty/> </p:input> </p:identity> </p:when> <p:otherwise> <p:output port="fileset" sequence="true"/> <px:fileset-create> <p:with-option name="base" select="$output-fileset-base"/> </px:fileset-create> <px:fileset-add-entry media-type="application/xslt+xml"> <p:with-option name="href" select="'mathml-fallback.xsl'"/> <p:with-option name="original-href" select="resolve-uri('mathml-fallback.xsl', static-base-uri())"/> <p:with-param port="file-attributes" name="role" select="'mathml-xslt-fallback'"/> </px:fileset-add-entry> </p:otherwise> </p:choose> <p:sink/> <px:fileset-create> <p:with-option name="base" select="$output-fileset-base"/> </px:fileset-create> <px:fileset-add-entry media-type="image/png" name="mathml-altimg-fallback"> <p:with-option name="href" select="'math-formulae.png'"/> <p:with-option name="original-href" select="resolve-uri('../images/math_formulae.png', static-base-uri())"/> </px:fileset-add-entry> <p:sink/> <px:fileset-join> <p:input port="source"> <p:pipe step="mo" port="result.fileset"/> <p:pipe step="audio" port="result.fileset"/> <p:pipe step="mathml-xslt-fallback" port="fileset"/> <p:pipe step="ncx" port="result.fileset"/> <p:pipe step="res-file" port="result.fileset"/> </p:input> </px:fileset-join> <p:choose> <p:when test="$audio-only"> <px:fileset-filter not-media-types="application/x-dtbook+xml text/css"/> </p:when> <p:otherwise> <p:identity name="fileset"/> <p:sink/> <px:fileset-filter media-types="image/gif image/jpeg image/png image/svg+xml application/pls+xml audio/mpeg audio/mp4"> <p:input port="source"> <p:pipe step="fileset.in" port="result"/> </p:input> </px:fileset-filter> <px:fileset-copy name="resources-fileset"> <p:with-option name="target" select="$output-fileset-base"/> </px:fileset-copy> <p:sink/> <px:fileset-join> <p:input port="source"> <p:pipe step="fileset" port="result"/> <p:pipe step="resources-fileset" port="result.fileset"/> </p:input> </px:fileset-join> </p:otherwise> </p:choose> <p:identity name="daisy3.fileset-without-opf"/> <px:daisy3-create-opf name="opf"> <p:input port="source.in-memory"> <p:pipe step="mo" port="result.in-memory"/> </p:input> <p:with-option name="output-base-uri" select="concat($output-fileset-base, 'book.opf')"/> <p:with-option name="uid" select="$uid"/> <p:with-param port="dc-metadata" name="dc:Date" select="$date"/> <p:with-param port="dc-metadata" name="dc:Publisher" select="$publisher"/> </px:daisy3-create-opf> <p:sink/> <p:identity name="daisy3.in-memory"> <p:input port="source"> <p:pipe step="mo" port="result.in-memory"/> <p:pipe step="ncx" port="result"/> <p:pipe step="res-file" port="result.in-memory"/> <p:pipe step="opf" port="result"/> </p:input> </p:identity> <p:sink/> <px:fileset-join> <p:input port="source"> <p:pipe step="daisy3.fileset-without-opf" port="result"/> <p:pipe step="opf" port="result.fileset"/> </p:input> </px:fileset-join> </p:group> </p:declare-step>