<!---->
<
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:xd="
http://www.pnp-software.com/XSLTdoc"
version="
2.0"
exclude-result-prefixes="
#all">
<
xd:
doc type="
stylesheet">
<
xd:
short>
Contains code for special processing of <
xd:
xml><
boxed-text /></
xd:
xml>
and content within it.
</
xd:
short>
<
xd:
cvsId>
$Revision$</
xd:
cvsId>
</
xd:
doc>
<
xsl:
template match="
boxed-text">
<
tps:
context type="
{tps:get-boxed-text-context-type(.)}"
id="
{generate-id()}">
<
xsl:
copy-of select="
tps:create-attribute('variant', tps:get-boxed-text-variant(.))" />
<
xsl:
apply-templates select="
element() except label" />
</
tps:
context>
</
xsl:
template>
<
xsl:
function name="
tps:get-boxed-text-context-type"
as="
xs:string">
<
xsl:
param name="
boxed-text"
as="
element(boxed-text)" />
<
xsl:
variable name="
content-type"
select="
$boxed-text/@content-type" />
<
xsl:
variable name="
mapped-context-type"
select="
tps:get-mapped-value($content-type, $boxed-text.context.type.mapping)" />
<
xsl:
sequence select="
($mapped-context-type[$boxed-text.context.type.mapping.enabled], $content-type, $boxed-text.context.type.default)[1]" />
</
xsl:
function>
<
xsl:
function name="
tps:get-boxed-text-variant"
as="
xs:string?">
<
xsl:
param name="
boxed-text"
as="
element(boxed-text)" />
<
xsl:
variable name="
mapped-variant"
select="
tps:get-mapped-value(tps:get-boxed-text-variant-input($boxed-text), $boxed-text.variant.mapping)" />
<
xsl:
sequence select="
($mapped-variant[$boxed-text.variant.mapping.enabled], $boxed-text.variant.default)[1]" />
</
xsl:
function>
<
xsl:
function name="
tps:get-boxed-text-variant-input"
as="
item()?">
<
xsl:
param name="
boxed-text"
as="
element(boxed-text)" />
<
xsl:
sequence select="
$boxed-text/processing-instruction('Box')" />
</
xsl:
function>
<
xsl:
template match="
boxed-text/label">
<
xsl:
apply-templates />
<
xsl:
text>
. </
xsl:
text>
</
xsl:
template>
<
xsl:
template match="
boxed-text/caption">
<
tps:
p type="
{$boxed-text.caption.para.type}">
<
xsl:
copy-of select="
parent::boxed-text/@id" />
<
xsl:
apply-templates select="
../label" />
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text/caption/p">
<
xsl:
apply-templates />
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group">
<
xsl:
apply-templates select="
element() except label" />
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group/label">
<
xsl:
apply-templates />
<
xsl:
text>
. </
xsl:
text>
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group/title">
<
tps:
p type="
{$boxed-text.fn-group.title.para.type}">
<
xsl:
apply-templates select="
../label" />
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group/fn[1]"
priority="
10">
<
tps:
p type="
{$boxed-text.fn.first.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group/fn">
<
tps:
p type="
{$boxed-text.fn.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text//fn-group/fn/label">
<
xsl:
apply-templates />
<
tps:
t />
</
xsl:
template>
<
xsl:
template match="
boxed-text/p[tps:is-first-boxed-text-p(.)] | boxed-text/sec/p[tps:is-first-boxed-text-p(.)]"
priority="
10">
<
tps:
p type="
{$boxed-text.p.first.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text/p | boxed-text/sec/p">
<
tps:
p type="
{$boxed-text.p.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
function name="
tps:is-first-boxed-text-p"
as="
xs:boolean">
<
xsl:
param name="
p"
as="
element(p)" />
<!---->
<
xsl:
variable name="
nesting-boxed-text"
select="
$p/ancestor::boxed-text[1]"
as="
element(boxed-text)?" />
<
xsl:
sequence select="
$nesting-boxed-text and empty($nesting-boxed-text/descendant::p[. << $p])" />
</
xsl:
function>
<
xsl:
template match="
boxed-text/statement/title" />
<
xsl:
template match="
boxed-text/statement/p">
<
tps:
p type="
{$boxed-text.statement.p.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
boxed-text//attrib">
<
tps:
p type="
{$boxed-text.attrib.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
</
xsl:
stylesheet>
v