[Replying to docbook-apps where this belongs...]
On 18.9.2014 15:38, Peter Fleck wrote:
Is it possible to do a lot of the work to make audio epubs using
stylesheets?
Everything is possible, it depends on effort you can put into it :-)
First, how to auto generate ids for each para? I'm sure that is
straightforward. (Or if more granularity is needed then id's at the
sentence or word level as needed).
Putting following into your customization layer should do the trick:
xsl:param name=generate.id.attributes select=1/
xsl:param name=generate.consistent.ids select=1/
xsl:template name=id.attribute
xsl:param name=node select=./
xsl:param name=conditional select=0/
xsl:choose
xsl:when test=$generate.id.attributes = 0
!-- No id attributes when this param is zero --
/xsl:when
xsl:when test=$conditional = 0 or $node/@id or $node/@xml:id
xsl:attribute name=id
xsl:call-template name=object.id
xsl:with-param name=object select=$node/
/xsl:call-template
/xsl:attribute
/xsl:when
/xsl:choose
/xsl:template
However if you change your DocBook source autogenerated IDs will change.
Second, populate the smil file with the ids
smil xmlns=http://www.w3.org/ns/SMIL;
xmlns:epub=http://www.idpf.org/2007/ops; version=3.0
body
seq id=id1 epub:textref=index.xhtml epub:type=bodymatter
chapter
par id=paragraph1
text src=index.xhtml#para-id1/
audio src=audio/file.mp3 clipBegin=0:00:02.000
clipEnd=0:00:15.000/
/par
par id=paragraph2
text src=index.xhtml#para-id2/
audio src=audio/file.mp3 clipBegin=0:00:15.000
clipEnd=0:00:25.000/
/par
/seq
/body
/smil
The smil file would need manually editing for the clipBegin and clipEnd
for each but that's fine. The audio src could be passed as a parameter.
Then add something like .-epub-media-overlay-active {background-color:
#abc;} to the css.
Have you considered generating this SMIL file automatically? I can
imagine putting custom attributes into DocBook document, something like:
chapter my:audio=file.mp3
titleFoo/title
para my:begin=0:00:02.000 my:end=0:00:15.000.../para
para my:begin=0:00:15.000 my:end=0:00:25.000.../para
...
From such markup you can quite easily generate SMIL file automatically.
Finally modify the package.opf to add
meta property=media:duration
refines=#chapter1_overlay0:04:30.000/meta
meta property=media:duration
refines=#chapter2_overlay0:03:30.000/meta
meta property=media:duration0:08:00.000/meta
meta property=media:narratorNarrator Name/meta
meta property=media:active-class-epub-media-overlay-active/meta
/metadata
manifest
item id=ncx href=toc.ncx media-type=application/x-dtbncx+xml/
item id=htmltoc properties=nav
media-type=application/xhtml+xml href=ar01-toc.xhtml/
item media-type=text/css id=docbook-css href=docbook-epub.css/
item id=id-idm21776 href=index.xhtml
media-type=application/xhtml+xml media-overlay=chapter1_overlay/
item id=chapter1_overlay href=chapter1_overlay.smil
media-type=application/smil+xml/
Is something like this doable?
Yes, generation of OPF file is split into set of relative small
templates which you can easily override. Look into
epub3/epu3-element-mods.xsl file. For example metadata part is generated
by the following template:
xsl:template name=package.metadata
xsl:element name=metadata namespace={$opf.namespace}
xsl:call-template name=metadata.identifier/
xsl:call-template name=metadata.title/
xsl:call-template name=metadata.language/
xsl:call-template name=metadata.modified/
xsl:call-template name=metadata.cover/
xsl:call-template name=metadata.other.info/
/xsl:element
/xsl:template
You can generate this template manually, or put your custom elements
inside info elements and handle them in special opf.metadata mode.
info
...
media:narratorNarrator Name/media:narrator
/info
xsl:template match=media:* mode=opf.metadata
meta property=media:{local-name(.)}xsl:value-of select=.//meta
/xsl:template
HTH,
Jirka
--
--
Jirka Kosek e-mail: ji...@kosek.cz http://xmlguru.cz
--
Professional XML consulting and training services
DocBook customization, custom XSLT/XSL-FO document processing
--
OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
--
Bringing you XML Prague conferencehttp://xmlprague.cz
--
signature.asc
Description: OpenPGP digital signature