<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pf="http://www.daisy.org/ns/pipeline/functions" xmlns:opf="http://www.idpf.org/2007/opf" xmlns="http://www.idpf.org/2007/opf" version="3.0" xpath-default-namespace="http://www.idpf.org/2007/opf" exclude-result-prefixes="#all"> <xsl:include href="http://www.daisy.org/pipeline/modules/common-utils/library.xsl"/> <xsl:param name="brailleCellType" as="xs:string"/> <xsl:param name="brailleSystem" as="xs:string*"/> <xsl:param name="ebraille-compatibility" as="xs:string?"/> <xsl:variable name="metadata-input" as="document-node()?" select="collection()[2]"/> <xsl:template match="/"> <metadata> <xsl:if test="$ebraille-compatibility='strict'"> <dc:format>eBraille 1.0</dc:format> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not($metadata-input//dc:identifier[not(@refines)])"> <dc:identifier id="pub-id">@@@</dc:identifier> </xsl:if> <xsl:if test="not($metadata-input//dc:date[not(@refines)])"> <dc:date> <xsl:value-of select="format-dateTime( adjust-dateTime-to-timezone(current-dateTime(),xs:dayTimeDuration('PT0H')), '[Y0001]-[M01]-[D01]')"/> </dc:date> </xsl:if> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not(collection()//dc:creator[not(@refines)])"> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'dc:creator unknown'"/> </xsl:call-template> <dc:creator>Unknown</dc:creator> </xsl:if> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not(collection()//meta[@property='dcterms:dateCopyrighted'][not(@refines)])"> <meta property="dcterms:dateCopyrighted"> <xsl:variable name="date" as="xs:string?"> <xsl:choose> <xsl:when test="some $src in collection()//dc:source[not(@refines)] satisfies $src/../meta[@property='dcterms:date'] [@refines=concat('#',$src/@id)]"> <xsl:sequence select="(for $src in collection()//dc:source[not(@refines)] return $src/../meta[@property='dcterms:date'] [@refines=concat('#',$src/@id)] )[1]/string(.)"/> </xsl:when> <xsl:when test="not(collection()//dc:source[not(@refines)]) and //dc:date[not(@refines)]"> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'dcterms:dateCopyrighted taken from original rendition''s dc:date'"/> </xsl:call-template> <xsl:sequence select="//dc:date[not(@refines)]/string(.)[1]"/> </xsl:when> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="empty($date)"> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'dcterms:dateCopyrighted unknown'"/> </xsl:call-template> <xsl:text>Unknown</xsl:text> </xsl:when> <xsl:when test="matches($date,'^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$')"> <xsl:value-of select="$date"/> </xsl:when> <xsl:otherwise> <xsl:variable name="dateTime" as="xs:dateTime?"> <xsl:try> <xsl:sequence select="parse-ietf-date($date)"/> <xsl:catch> <xsl:try> <xsl:sequence select="xs:dateTime($date)"/> <xsl:catch/> </xsl:try> </xsl:catch> </xsl:try> </xsl:variable> <xsl:choose> <xsl:when test="exists($dateTime)"> <xsl:value-of select="format-dateTime($dateTime,'[Y0001]-[M01]-[D01]')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$date"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </meta> </xsl:if> </xsl:if> <xsl:if test="$ebraille-compatibility"> <meta property="a11y:brailleCellType"> <xsl:value-of select="$brailleCellType"/> </meta> <xsl:for-each select="$brailleSystem"> <meta property="a11y:brailleSystem"> <xsl:value-of select="."/> </meta> </xsl:for-each> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not(collection()//meta[@property='a11y:completeTranscription'])"> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'a11y:completeTranscription unknown, assuming true'"/> </xsl:call-template> <meta property="a11y:completeTranscription">true</meta> </xsl:if> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:choose> <xsl:when test="collection()//meta[@property='a11y:producer'][not(@refines)]"> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'a11y:producer taken from original''s a11y:producer'"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="pf:warn"> <xsl:with-param name="msg" select="'a11y:producer unknown'"/> </xsl:call-template> <meta property="a11y:producer">Unknown</meta> </xsl:otherwise> </xsl:choose> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not(collection()//meta[@property='a11y:tactileGraphics'][not(@refines)])"> <meta property="a11y:tactileGraphics">none</meta> </xsl:if> </xsl:if> <xsl:if test="$ebraille-compatibility"> <xsl:if test="not(collection()//dc:source[not(@refines)])"> <xsl:variable name="epub-id" as="xs:string?" select="//dc:identifier[@id=/package/@unique-identifier]/string()"/> <xsl:if test="$epub-id"> <dc:source id="epub"> <xsl:value-of select="string($epub-id)"/> </dc:source> <xsl:variable name="date" as="xs:string?" select="//dc:date/string()"/> <xsl:if test="$date"> <meta property="dcterms:date" refines="#epub"> <xsl:value-of select="$date"/> </meta> </xsl:if> <xsl:variable name="publisher" as="xs:string?" select="//dc:publisher/string()"/> <xsl:if test="$publisher"> <meta property="dcterms:publisher" refines="#epub"> <xsl:value-of select="$publisher"/> </meta> </xsl:if> <xsl:variable name="rights" as="xs:string?" select="//dc:rights/string()"/> <xsl:if test="$rights"> <meta property="dcterms:rights" refines="#epub"> <xsl:value-of select="$rights"/> </meta> </xsl:if> </xsl:if> </xsl:if> </xsl:if> <xsl:sequence select="//meta[not(@refines)] [@property='schema:accessMode'] [not(normalize-space(.)=('tactile','textual'))]"/> <meta property="schema:accessMode">tactile</meta> </metadata> </xsl:template> </xsl:stylesheet>