<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:d="http://www.daisy.org/ns/pipeline/data" xmlns:pf="http://www.daisy.org/ns/pipeline/functions" version="2.0"> <xsl:include href="http://www.daisy.org/pipeline/modules/file-utils/library.xsl"/> <xsl:param name="epub-base" required="yes" as="xs:string"/> <xsl:param name="ebraille-compatibility" required="yes" as="xs:string?"/> <xsl:param name="delete-original-rendition" required="yes" as="xs:boolean"/> <xsl:param name="content-media-types" required="yes" as="xs:string*"/> <xsl:variable name="original-base" as="xs:string" select="pf:longest-common-uri( //d:file[not(@media-type='application/oebps-package+xml') and not($ebraille-compatibility and @role='nav')] /resolve-uri(@href,base-uri(.)))"/> <xsl:variable name="braille-base" as="xs:string" select="if ($ebraille-compatibility) then resolve-uri('ebraille/',$epub-base) else if ($delete-original-rendition) then $epub-base else resolve-uri('braille/',$epub-base)"/> <xsl:template match="/"> <d:fileset> <xsl:apply-templates select="//d:file"/> </d:fileset> </xsl:template> <xsl:template match="d:fileset/d:file"> <xsl:choose> <xsl:when test="@media-type='application/oebps-package+xml'"> <xsl:variable name="original-href" select="resolve-uri(@href,pf:base-uri(.))"/> <xsl:variable name="braille-href" select="if ($ebraille-compatibility) then resolve-uri('package.opf',$epub-base) else resolve-uri('package.opf',$braille-base)"/> <xsl:element name="d:file"> <xsl:attribute name="href" select="$braille-href"/> <xsl:attribute name="original-href" select="$original-href"/> </xsl:element> </xsl:when> <xsl:otherwise> <xsl:variable name="original-href" select="resolve-uri(@href,pf:base-uri(.))"/> <xsl:variable name="braille-href" select="if ($ebraille-compatibility and @role='nav') then resolve-uri('index.html',$epub-base) else resolve-uri(pf:relativize-uri($original-href,$original-base), $braille-base)"/> <xsl:element name="d:file"> <xsl:attribute name="href" select="$braille-href"/> <xsl:attribute name="original-href" select="$original-href"/> </xsl:element> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>