<
xsl:stylesheet xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform" xmlns:xs=
"http://www.w3.org/2001/XMLSchema" xmlns:html=
"http://www.w3.org/1999/xhtml" xmlns:opf=
"http://www.idpf.org/2007/opf" xmlns:dc=
"http://purl.org/dc/elements/1.1/" xmlns:pf=
"http://www.daisy.org/ns/pipeline/functions" xmlns=
"http://www.w3.org/1999/xhtml" version=
"2.0" xpath-default-namespace=
"" exclude-result-prefixes=
"#all">
<
xsl:import href=
"http://www.daisy.org/pipeline/modules/smil-utils/clock-functions.xsl"/>
<
xsl:variable name=
"ncc.body" select=
"collection()[position()=2]/*"/>
<
xsl:variable name=
"smil" select=
"collection()[position()>2]/*"/>
<
xsl:template match=
"text()"/>
<
xsl:template match=
"opf:metadata">
<
head>
<
meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8"/>
<
title>
<
xsl:for-each select=
"dc:title[1]">
<
xsl:copy-of select=
"@scheme|@http-equiv|@lang|@dir"/>
<
xsl:if test=
"@xml:lang">
<
xsl:attribute name=
"lang" select=
"@xml:lang"/>
</
xsl:if>
<
xsl:copy-of select=
"normalize-space(.)"/>
</
xsl:for-each>
</
title>
<
meta name=
"dc:format" content=
"Daisy 2.02"/>
<
xsl:for-each select=
"dc:identifier[@id=/*/@unique-identifier]">
<
xsl:call-template name=
"meta">
<
xsl:with-param name=
"name" select=
"name()"/>
</
xsl:call-template>
</
xsl:for-each>
<
meta name=
"dc:date" content=
"{(dc:date,format-date(current-date(),'[Y0001]-[M01]-[D01]'))[1]}"/>
<
meta name=
"ncc:charset" content=
"utf-8"/>
<
meta name=
"ncc:tocItems" content=
"{count($ncc.body/*)}"/>
<
meta name=
"ncc:pageFront" content=
"{count($ncc.body/html:span['page-front'=tokenize(@class,'\s+')])}"/>
<
meta name=
"ncc:pageNormal" content=
"{count($ncc.body/html:span['page-normal'=tokenize(@class,'\s+')])}"/>
<
meta name=
"ncc:pageSpecial" content=
"{count($ncc.body/html:span['page-special'=tokenize(@class,'\s+')])}"/>
<
meta name=
"ncc:sidebars" content=
"0"/>
<
meta name=
"ncc:prodNotes" content=
"0"/>
<
meta name=
"ncc:footnotes" content=
"{count($ncc.body/html:span['noteref'=tokenize(@class,'\s+')])}"/>
<
meta name=
"ncc:totalTime" content=
"{pf:smil-seconds-to-full-clock-value( sum($smil/body/seq/@dur/xs:decimal(replace(.,'^(.+)s$','$1'))))}"/>
<
xsl:for-each select=
"*[not(self::opf:*| self::dc:format| self::dc:date| self::dc:identifier)]">
<
xsl:call-template name=
"meta">
<
xsl:with-param name=
"name" select=
"name()"/>
</
xsl:call-template>
</
xsl:for-each>
<
xsl:for-each select=
"opf:meta[@property and not(@refines)]">
<
xsl:call-template name=
"meta">
<
xsl:with-param name=
"name" select=
"@property"/>
</
xsl:call-template>
</
xsl:for-each>
</
head>
</
xsl:template>
<
xsl:template name=
"meta">
<
xsl:param name=
"name" required=
"yes"/>
<
xsl:choose>
<
xsl:when test=
"$name=$allowed-meta or starts-with($name,'prod:')">
<
meta name=
"{$name}" content=
"{normalize-space(.)}">
<
xsl:copy-of select=
"@scheme|@http-equiv|@lang|@dir"/>
<
xsl:if test=
"@xml:lang">
<
xsl:attribute name=
"lang" select=
"@xml:lang"/>
</
xsl:if>
</
meta>
</
xsl:when>
<
xsl:otherwise>
<
xsl:message select=
"concat('meta element "',$name,'" was omitted')"/>
</
xsl:otherwise>
</
xsl:choose>
</
xsl:template>
<
xsl:variable name=
"allowed-meta" as=
"xs:string*" select=
"('dc:contributor', 'dc:coverage', 'dc:creator', 'dc:date', 'dc:description', 'dc:format', 'dc:identifier', 'dc:language', 'dc:publisher', 'dc:relation', 'dc:rights', 'dc:source', 'dc:subject', 'dc:title', 'dc:type', 'ncc:charset', 'ncc:depth', 'ncc:files', 'ncc:footnotes', 'ncc:generator', 'ncc:kByteSize', 'ncc:maxPageNormal', 'ncc:multimediaType', 'ncc:narrator', 'ncc:pageFront', 'ncc:pageNormal', 'ncc:pageSpecial', 'ncc:prodNotes', 'ncc:producedDate', 'ncc:producer', 'ncc:revision', 'ncc:revisionDate', 'ncc:setInfo', 'ncc:sidebars', 'ncc:sourceDate', 'ncc:sourceEdition', 'ncc:sourcePublisher', 'ncc:sourceRights', 'ncc:sourceTitle', 'ncc:tocItems', 'ncc:totalTime' )"/>
</
xsl:stylesheet>