<p:declare-stepxmlns:p="http://www.w3.org/ns/xproc"xmlns:px="http://www.daisy.org/ns/pipeline/xproc"xmlns:cx="http://xmlcalabash.com/ns/extensions"xmlns:c="http://www.w3.org/ns/xproc-step"xmlns:d="http://www.daisy.org/ns/pipeline/data"xmlns:xs="http://www.w3.org/2001/XMLSchema"version="1.0"type="px:dtbook-to-zedai.script"name="main"px:input-filesets="dtbook"px:output-filesets="zedai"exclude-inline-prefixes="#all">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h1px:role="name">DTBook to ZedAI</h1><ppx:role="desc">Transforms DTBook XML into ZedAI XML.</p>
<apx:role="homepage"href="http://daisy.github.io/pipeline/Get-Help/User-Guide/Scripts/dtbook-to-zedai/">
Online documentation
</a>
<address>
Authors:
<dlpx:role="author">
<dt>Name:</dt>
<ddpx:role="name">Marisa DeMeglio</dd>
<dt>E-mail:</dt>
<dd><ahref="mailto:marisa.demeglio@gmail.com">marisa.demeglio@gmail.com</a></dd>
<dt>Organization:</dt>
<ddpx:role="organization">DAISY Consortium</dd>
</dl>
</address>
</p:documentation>
<p:inputport="source"primary="true"sequence="true"px:media-type="application/x-dtbook+xml">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">DTBook file(s)</h2><ppx:role="desc">One or more DTBook files to be transformed. In the case of multiple files, a merge will be performed.</p>
</p:documentation>
</p:input><p:optionname="result"required="true"px:output="result"px:type="anyDirURI"px:media-type="text">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">ZedAI</h2><ppx:role="desc">The resulting ZedAI XML file.</p>
</p:documentation>
</p:option><p:optionname="zedai-filename"required="false"px:type="string"select="'zedai.xml'"px:reusable="false">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">ZedAI filename</h2><ppx:role="desc">Filename for the generated ZedAI file</p>
</p:documentation>
</p:option><p:optionname="validation"select="'abort'"required="false"><p:pipeinfo><px:type>
<choicexmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<value>off</value>
<a:documentationxml:lang="en">No validation</a:documentation>
<value>report</value>
<a:documentationxml:lang="en">Report validation issues</a:documentation>
<value>abort</value>
<a:documentationxml:lang="en">Abort on validation issues</a:documentation>
</choice>
</px:type></p:pipeinfo><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Validation</h2><ppx:role="desc">Whether to abort on validation issues.</p>
</p:documentation>
</p:option><p:optionname="nimas"select="'false'"required="false"px:type="boolean"px:reusable="false"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">NIMAS input</h2><ppx:role="desc"xml:space="preserve">Whether the input DTBook is a NIMAS 1.1-conformant XML content file.
A [NIMAS 1.1](https://aem.cast.org/nimas-nimac/nimas-technical-specification)-conformant XML file is
a valid DTBook (DAISY/NISO Z39.86 2005) file, with the exception that the `head` element is required
to be empty.</p>
</p:documentation>
</p:option><p:outputport="validation-report"sequence="true"px:media-type="application/vnd.pipeline.report+xml"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Validation reports</h2>
</p:documentation>
<p:pipestep="load"port="validation-report"/>
<p:pipestep="result"port="validation-report"/>
</p:output><p:outputport="status"px:media-type="application/vnd.pipeline.status+xml">
<p:pipestep="result"port="status"/>
</p:output><p:optionname="mods-filename"required="false"px:type="string"select="'zedai-mods.xml'">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">MODS filename</h2><ppx:role="desc">Filename for the generated MODS file</p>
</p:documentation>
</p:option><p:optionname="css-filename"required="false"px:type="string"select="'zedai-css.css'">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">CSS filename</h2><ppx:role="desc">Filename for the generated CSS file</p>
</p:documentation>
</p:option><p:optionname="language"select="''"required="false"px:type="string"px:reusable="false"><p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Language code</h2><ppx:role="desc"xml:space="preserve">Language code of the input document.
Must be an [RFC 5646](https://tools.ietf.org/html/rfc5646) language tag such as "zh" or "fr-CA".</p>
</p:documentation>
</p:option><p:optionname="copy-external-resources"required="false"px:type="boolean"select="'true'">
<p:documentationxmlns="http://www.w3.org/1999/xhtml">
<h2px:role="name">Copy external resources</h2><ppx:role="desc">Include any referenced external resources like images and CSS-files to the output.</p>
</p:documentation>
</p:option>
<p:importhref="http://www.daisy.org/pipeline/modules/dtbook-utils/library.xpl">
<p:documentation>
px:dtbook-load
</p:documentation>
</p:import>
<p:importhref="http://www.daisy.org/pipeline/modules/fileset-utils/library.xpl">
<p:documentation>
px:fileset-add-entries
px:fileset-store
</p:documentation>
</p:import>
<p:importhref="dtbook-to-zedai.convert.xpl">
<p:documentation>
px:dtbook-to-zedai
</p:documentation>
</p:import>
<p:sink/>
<px:fileset-add-entriesmedia-type="application/x-dtbook+xml"name="dtbook">
<p:inputport="entries">
<p:pipestep="main"port="source"/>
</p:input>
</px:fileset-add-entries>
<px:dtbook-loadname="load">
<p:inputport="source.in-memory">
<p:pipestep="dtbook"port="result.in-memory"/>
</p:input>
<p:with-optionname="validation"select="not($validation='off')"/>
<p:with-optionname="nimas"select="$nimas='true'"/>
</px:dtbook-load>
<p:sink/>
<p:identity>
<p:inputport="source">
<p:pipestep="load"port="validation-status"/>
</p:input>
</p:identity>
<p:choose>
<p:whentest="/d:validation-status[@result='error']">
<p:choose>
<p:whentest="$validation='abort'">
<p:identitypx:message="The input contains an invalid DTBook file. See validation report for more info."px:message-severity="ERROR"/>
</p:when>
<p:otherwise>
<p:identitypx:message="The input contains an invalid DTBook file. See validation report for more info."px:message-severity="WARN"/>
</p:otherwise>
</p:choose>
</p:when>
<p:otherwise>
<p:identity/>
</p:otherwise>
</p:choose>
<p:choosename="result">
<p:whentest="/d:validation-status[@result='error'] and $validation='abort'">
<p:outputport="status"primary="true"/>
<p:outputport="validation-report"sequence="true">
<p:empty/>
</p:output>
<p:identity/>
</p:when>
<p:otherwise>
<p:outputport="status"primary="true"/>
<p:outputport="validation-report"sequence="true">
<p:pipestep="convert"port="validation-report"/>
</p:output>
<p:variablename="dtbook-is-valid"cx:as="xs:boolean"select="not($validation='off') and exists(/d:validation-status[@result='ok'])"/>
<p:sink/>
<px:dtbook-to-zedainame="convert">
<p:inputport="source.fileset">
<p:pipestep="load"port="result.fileset"/>
</p:input>
<p:inputport="source.in-memory">
<p:pipestep="load"port="result.in-memory"/>
</p:input>
<p:with-optionname="output-dir"select="$result"/>
<p:with-optionname="zedai-filename"select="$zedai-filename"/>
<p:with-optionname="mods-filename"select="$mods-filename"/>
<p:with-optionname="css-filename"select="$css-filename"/>
<p:with-optionname="lang"select="$language"/>
<p:with-optionname="validation"select="$validation"/>
<p:with-optionname="dtbook-is-valid"select="$dtbook-is-valid"/>
<p:with-optionname="output-validation"select="($validation[.='off'],'report')[1]"/>
<p:with-optionname="nimas"select="$nimas='true'"/>
<p:with-optionname="copy-external-resources"select="$copy-external-resources='true'"/>
</px:dtbook-to-zedai>
<px:fileset-storename="store">
<p:inputport="in-memory.in">
<p:pipestep="convert"port="result.in-memory"/>
</p:input>
</px:fileset-store>
<p:identitycx:depends-on="store">
<p:inputport="source">
<p:pipestep="convert"port="validation-status"/>
</p:input>
</p:identity>
</p:otherwise>
</p:choose>
</p:declare-step>