<!---->
<
xsl:
stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
xmlns:tps="
http://www.typefi.com/ContentXML"
xmlns:xlink="
http://www.w3.org/1999/xlink"
xmlns:xd="
http://www.pnp-software.com/XSLTdoc"
version="
2.0"
exclude-result-prefixes="
#all">
<
xd:
doc type="
stylesheet">
<
xd:
short>
Covers processing of figures, their content, detection of target <
code>
tps:context/@type</
code>
and <
code>
tps:context/@variant</
code>
.
</
xd:
short>
<
xd:
cvsId>
$Revision$</
xd:
cvsId>
</
xd:
doc>
<
xsl:
template match="
fig">
<
tps:
context type="
{tps:get-fig-context-type(.)}"
id="
{generate-id()}">
<
xsl:
copy-of select="
tps:create-attribute('variant', tps:get-fig-variant(.))" />
<
xsl:
apply-templates select="
element() except label" />
</
tps:
context>
</
xsl:
template>
<
xsl:
function name="
tps:get-fig-context-type"
as="
xs:string">
<
xsl:
param name="
fig"
as="
element(fig)" />
<
xsl:
variable name="
content-type"
select="
$fig/@fig-type" />
<
xsl:
variable name="
mapped-context-type"
select="
tps:get-mapped-value($content-type, $fig.context.type.mapping)" />
<
xsl:
sequence select="
($mapped-context-type[$fig.context.type.mapping.enabled], $content-type, $fig.context.type.default)[1]" />
</
xsl:
function>
<
xsl:
function name="
tps:get-fig-variant"
as="
xs:string?">
<
xsl:
param name="
fig"
as="
element(fig)" />
<
xsl:
variable name="
mapped-variant"
select="
tps:get-mapped-value(tps:get-fig-variant-input($fig), $fig.variant.mapping)" />
<
xsl:
sequence select="
($mapped-variant[$fig.variant.mapping.enabled], $fig.variant.default)[1]" />
</
xsl:
function>
<
xsl:
function name="
tps:get-fig-variant-input"
as="
item()?">
<
xsl:
param name="
fig"
as="
element(fig)" />
<
xsl:
sequence select="
$fig/processing-instruction('Figure')" />
</
xsl:
function>
<
xsl:
template match="
fig/label">
<
xsl:
apply-templates />
<
xsl:
text>
. </
xsl:
text>
</
xsl:
template>
<
xsl:
template match="
fig/caption">
<
tps:
p type="
{$fig.caption.para.type}">
<
xsl:
copy-of select="
parent::fig/@id" />
<
xsl:
apply-templates select="
parent::fig/label" />
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
fig/graphic">
<
tps:
image comment="
{@xlink:href}"
ref="
{tps:get-graphic-file-path(., $fig.graphic.extension)}" />
</
xsl:
template>
<
xsl:
template match="
fig/p[1]">
<
tps:
p type="
{$fig.p.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
fig/p">
<
tps:
p type="
{$fig.p.first.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
fig/attrib">
<
tps:
p type="
{$fig.attrib.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
</
xsl:
stylesheet>
v