<!---->
<
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="
xs tps">
<
xd:
doc type="
stylesheet">
<
xd:
short>
Contains conversion logic for math elements like <
xd:
xml><
disp-formula /></
xd:
xml>
.
</
xd:
short>
<
xd:
cvsId>
$Revision$</
xd:
cvsId>
</
xd:
doc>
<
xsl:
template match="
disp-formula[not(tps:follows-disp-formula(.)) and not(tps:precedes-disp-formula(.))]"
priority="
20">
<
tps:
p type="
{$disp-formula.single.para.type}">
<
xsl:
apply-templates select="
attribute()" />
<
xsl:
call-template name="
insert-disp-formula-content" />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
disp-formula[not(tps:follows-disp-formula(.))]"
priority="
10">
<
tps:
p type="
{$disp-formula.first.para.type}">
<
xsl:
apply-templates select="
attribute()" />
<
xsl:
call-template name="
insert-disp-formula-content" />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
disp-formula[not(tps:precedes-disp-formula(.))]"
priority="
10">
<
tps:
p type="
{$disp-formula.last.para.type}">
<
xsl:
apply-templates select="
attribute()" />
<
xsl:
call-template name="
insert-disp-formula-content" />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
disp-formula">
<
tps:
p type="
{$disp-formula.middle.para.type}">
<
xsl:
apply-templates select="
attribute()" />
<
xsl:
call-template name="
insert-disp-formula-content" />
</
tps:
p>
</
xsl:
template>
<
xsl:
template match="
disp-formula/@id">
<
xsl:
copy-of select="
." />
</
xsl:
template>
<
xsl:
function name="
tps:follows-disp-formula"
as="
xs:boolean">
<
xsl:
param name="
el"
as="
element()" />
<
xsl:
sequence select="
exists($el/preceding-sibling::node()[tps:non-empty-nodes(.)][1][self::disp-formula])" />
</
xsl:
function>
<
xsl:
function name="
tps:precedes-disp-formula"
as="
xs:boolean">
<
xsl:
param name="
el"
as="
element()" />
<
xsl:
sequence select="
exists($el/following-sibling::node()[tps:non-empty-nodes(.)][1][self::disp-formula])" />
</
xsl:
function>
<
xsl:
template name="
insert-disp-formula-content">
<
tps:
t />
<
xsl:
apply-templates select="
node() except label, label" />
</
xsl:
template>
<
xsl:
template match="
disp-formula/label">
<
tps:
t />
<
xsl:
apply-templates />
</
xsl:
template>
</
xsl:
stylesheet>
v