我有xml文件,其中有一些css属性,我想在表上应用
XML文件如下: -
<code>
<reportConfiguration>
<details_background_color>white</details_background_color>
<page_header_horizontal_align>center</page_header_horizontal_align>
<page_header_font_size>12pt</page_header_font_size>
</reportConfiguration>
</code>
我想使用details_background_color,details_bold在表中应用值,代码如下但不能正常工作
<code>
<fo:block>
<xsl:for-each select="element_1">
<fo:block font-size="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size" font-weight="document('xmlFile_reportConfig.xml')/reportConfiguration/details_bold" text-align="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_horizontal_align" vertical-align="middle">
select="document('file:///D:/DATA/Marquee/dial_stats_UK.xml')/UK_Products_Pipeline/LastFinishCode"
<xsl:value-of select="."/>
</fo:block>
</xsl:for-each>
</fo:block>
</code>
答案 0 :(得分:0)
我假设您向我们展示的XML文件不是您正在应用XSLT的主要文档,而是除了主要文档之外还需要引用的辅助文档,否则将不需要使用{ {1}}功能。
(我还假设您的问题中显示的document
标签也不应该存在。)
无论如何,这就是您目前正在尝试引用外部文档的方式
<code>
当您尝试使用表达式设置属性的值时,您需要使用Attribute Value Templates,否则属性的值将是您编写的字面值。换句话说,您需要将表达式括在花括号中以表明它是要计算的表达式:
<fo:block
font-size="document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size"
如果您需要从中访问多个值,那么在变量中保存对文档的引用可能会稍微容易一些。例如:
<fo:block
font-size="{document('xmlFile_reportConfig.xml')/reportConfiguration/page_header_font_size}"
请注意,这确实假设您的报表配置XML与XSLT文件位于同一目录中。