【发布时间】:2021-12-13 11:03:36
【问题描述】:
所以我将 XSLT 应用到 XML 代码并让它显示我需要的输出,
显示了完整的 XML 代码,但是当我将其打印为 html/pdf 时,仅显示第一页并且底部被切断。
有人知道为什么不显示吗?
作为参考,这是我的 XSLT 代码
<xsl:stylesheet xmlns="http://www.w3.org/2000/svg" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
<xsl:output indent="yes"/>
<xsl:variable name="svg-width" select="1200"/>
<xsl:variable name="svg-height" select="900"/>
<xsl:variable name="max-bar-length" select="$svg-width - 400"/>
<xsl:variable name="bar-height" select="20"/>
<xsl:variable name="bar-spacing" select="50"/>
<xsl:variable name="bar-start" select="200"/>
<xsl:variable name="bar-width1" select="gdp_agri"/>
<xsl:variable name="bar-width2" select="gdp_ind"/>
<xsl:variable name="bar-width3" select="gdp_serv"/>
<xsl:variable name="gdp_agri" select="gdp_agri"/>
<xsl:variable name="gdp_ind" select="gdp_ind"/>
<xsl:variable name="gdp_serv" select="gdp_serv"/>
<xsl:template match="/">
<html>
<body>
<svg viewBox="0 0 {$svg-width} {$svg-height}" width="{$svg-width}px" height="{$svg-height}px">
<g id="bar-chart" font-size="16" transform="translate(20,100)">
<xsl:apply-templates select="child::mondial/child::country[child::encompassed[attribute::continent='europe']]">
<xsl:sort order="ascending" select="name"/>
</xsl:apply-templates>
</g>
</svg>
</body>
</html>
</xsl:template>
<xsl:template match="country">
<xsl:variable name="bar-width" select="gdp_agri"/>
<g id="bar_{position()}" transform="translate(0, {(position() - 1) * ($bar-height + $bar-spacing)})">
<text x="0" y="{($bar-height + $bar-spacing) div 2}">
<xsl:number format="1. " value="position()"/>
<xsl:value-of select="name"/>
</text>
<rect x="{$bar-start}" y="0" width="{$bar-width}" height="{$bar-height}" fill="green"/>
<text x="{$bar-width +$bar-start + 5}" y="{0.2*($bar-height + $bar-spacing) div 2}">Agri GDP: <xsl:value-of select="gdp_agri"/>%</text>
</g>
<xsl:variable name="bar-width2" select="gdp_ind"/>
<g id="bar_{position()}" transform="translate(0, {(position() - 1) * ($bar-height + $bar-spacing)})">
<text x="0" y="{($bar-height + $bar-spacing) div 2}">
<xsl:number format="1. " value="position()"/>
<xsl:value-of select="name"/>
</text>
<rect x="{$bar-start}" y="20" width="{$bar-width2}" height="{$bar-height}" fill="brown"/>
<text x="{$bar-width2 +$bar-start + 5}" y="{($bar-height + $bar-spacing) div 2}">Ind GDP: <xsl:value-of select="gdp_ind"/>%</text>
</g>
<xsl:variable name="bar-width3" select="gdp_serv"/>
<g id="bar_{position()}" transform="translate(0, {(position() - 1) * ($bar-height + $bar-spacing)})">
<text x="0" y="{($bar-height + $bar-spacing) div 2}">
<xsl:number format="1. " value="position()"/>
<xsl:value-of select="name"/>
</text>
<rect x="{$bar-start}" y="40" width="{$bar-width3}" height="{$bar-height}" fill="yellow"/>
<text x="{$bar-width3 +$bar-start + 5}" y="{($bar-height + $bar-spacing) div 1.2}">Serv. GDP: <xsl:value-of select="gdp_serv"/>%</text>
</g>
</xsl:template>
</xsl:stylesheet>
当我稍后应用转换时,它会运行,但只显示输出的第一页。我正在运行的其他国家/地区没有出现(这是 mondial 数据库);它们出现在 XML 输出中,但当我打印为 html / pdf 甚至在存在数据库输出中时不会出现
【问题讨论】:
-
好吧 SVG 不是流动的内容,而您的内容是 900 像素高。
-
这不是 eXist-db 特定的问题