<!---->
<
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>
Converts images and contains logic for image path recognition and composition.
</
xd:
short>
<
xd:
detail>
For image path customization in typical cases override the variables
<
code>
$graphic.dir</
code>
, <
code>
$graphic.default.extension</
code>
, <
code>
$inline-graphic.extension</
code>
.
</
xd:
detail>
<
xd:
cvsId>
$Revision$</
xd:
cvsId>
</
xd:
doc>
<
xsl:
template match="
graphic">
<
tps:
image comment="
{@xlink:href}"
ref="
{tps:get-graphic-file-path(., $graphic.default.extension)}" />
</
xsl:
template>
<
xsl:
template match="
inline-graphic">
<
tps:
image comment="
{@xlink:href}"
ref="
{tps:get-graphic-file-path(., $inline-graphic.extension)}" />
</
xsl:
template>
<
xsl:
function name="
tps:get-graphic-file-path"
as="
xs:string">
<
xsl:
param name="
graphic"
as="
element()" />
<
xsl:
param name="
extension"
as="
xs:string" />
<
xsl:
variable name="
ref"
select="
$graphic/@xlink:href" />
<
xsl:
sequence select="
concat($graphic.dir, tps:get-file-name-from-path($ref), $extension[not(tps:has-path-extension($ref))])" />
</
xsl:
function>
<
xsl:
function name="
tps:get-file-name-from-path"
as="
xs:string">
<
xsl:
param name="
path"
as="
xs:string" />
<
xsl:
sequence select="
tokenize($path, '/')[last()]" />
</
xsl:
function>
<
xsl:
function name="
tps:has-path-extension"
as="
xs:boolean">
<
xsl:
param name="
path"
as="
xs:string" />
<
xsl:
sequence select="
matches($path, '\.[0-9a-z]{1,5}$')" />
</
xsl:
function>
</
xsl:
stylesheet>
v