<!---->
<
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>
Processes the most basic article elements such as <
code>
sec</
code>
, <
code>
sec/label</
code>
, <
code>
sec/title</
code>
and paragraphs.
</
xd:
short>
<
xd:
detail>
Also contains functions involved in evaluation of paragraph styles.
</
xd:
detail>
<
xd:
cvsId>
$Revision$</
xd:
cvsId>
</
xd:
doc>
<
xsl:
template match="
body">
<
xsl:
apply-templates select="
element()" />
</
xsl:
template>
<
xsl:
template match="
body//sec">
<
xsl:
apply-templates select="
element() except label" />
</
xsl:
template>
<
xsl:
template match="
body//sec/label">
<
xsl:
apply-templates />
<
xsl:
text>
</
xsl:
text>
</
xsl:
template>
<
xsl:
template match="
body//sec/title">
<
tps:
p type="
{tps:get-body-title-para-type(.)}">
<
xsl:
apply-templates select="
../label" />
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
body//sec/title[tps:is-stacked-title(.)]"
priority="
10">
<
tps:
p type="
{concat(tps:get-body-title-para-type(.), $body.title.stacked.para.type.postfix)}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
function name="
tps:is-stacked-title"
as="
xs:boolean">
<
xsl:
param name="
title"
as="
element(title)" />
<
xsl:
sequence select="
empty($title/preceding-sibling::element()) and exists($title/../preceding-sibling::element()[1][self::title])" />
</
xsl:
function>
<
xsl:
function name="
tps:get-body-title-para-type"
as="
xs:string">
<
xsl:
param name="
title"
as="
element(title)" />
<
xsl:
sequence select="
concat(tps:get-body-title-para-type-prefix($title), tps:get-body-title-para-type-root($title), tps:get-body-title-para-type-postfix($title))" />
</
xsl:
function>
<
xsl:
function name="
tps:get-body-title-para-type-prefix"
as="
xs:string?">
<
xsl:
param name="
title"
as="
element(title)" />
</
xsl:
function>
<
xsl:
function name="
tps:get-body-title-para-type-root"
as="
xs:string">
<
xsl:
param name="
title"
as="
element(title)" />
<
xsl:
sequence select="
$body.title.para.type" />
</
xsl:
function>
<
xsl:
function name="
tps:get-body-title-para-type-postfix"
as="
xs:string?">
<
xsl:
param name="
title"
as="
element(title)" />
<
xsl:
variable name="
result"
as="
xs:string">
<
xsl:
number value="
count($title/ancestor::sec)"
format="
{$body.title.level.pattern}" />
</
xsl:
variable>
<
xsl:
sequence select="
$result" />
</
xsl:
function>
<
xsl:
template match="
body/p[1] | body//sec/p[1]"
priority="
10">
<
tps:
p type="
{$body.p.first.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
body/p | body//sec/p">
<
tps:
p type="
{$body.p.para.type}">
<
xsl:
apply-templates />
</
tps:
p>
</
xsl:
template>
</
xsl:
stylesheet>
v