gpt4 book ai didi

XSL 文件中的 Java setParameter

转载 作者:行者123 更新时间:2023-12-02 08:02:53 25 4
gpt4 key购买 nike

我在从正在 XLS 文件中添加参数的 Java 项目打印 PDF 文件时遇到问题。该项目读取 XML 文件,然后从 XSL 样式表生成 PDF 文件。文件内容见下文。
正如您在XLS文件中看到的,我想在“studentNumber”处指定,但问题是指定的“studentNumber”需要在Java项目中设置。我尝试了很多事情并在互联网上搜索,但我找不到答案。任何想法我都需要改变以使这个项目正确。

XML 文件:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="studentResultXLS.xsl"?>
<cursus>
<enroll>
<studentnumber>s484766</studentnumber>
<cursuscode>ISDTCEX.B627</cursuscode>
<enrolldate dateformat="eejjmmdd">20111121</enrolldate>
<acquire>ja</acquire>
<grade>4</grade>
<result></result>
</enroll>
<enroll>
<studentnumber>s484766</studentnumber>
<cursuscode>ISDTSIP.T470</cursuscode>
<enrolldate dateformat="eejjmmdd">20111116</enrolldate>
<acquire>ja</acquire><grade>2</grade>
<result></result>
</enroll>
<enroll>
<studentnumber>s484767</studentnumber>
<cursuscode>ISDTSIP.T470</cursuscode>
<enrolldate dateformat="eejjmmdd">20111116</enrolldate>
<acquire>ja</acquire><grade>2</grade>
<result></result>
</enroll>

</cursus>

XLS 文件:

<xsl:param name="studentnumber"/>.....

<fo:table-body>
<xsl:for-each select="/cursus/enroll[studentnumber='s484766']">
<fo:table-row>

<fo:table-cell>
<fo:block> <xsl:value-of select="studentnumber"/> </fo:block>
</fo:table-cell>

<fo:table-cell>
<fo:block> <xsl:value-of select="cursuscode"/> </fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>

Java代码:

 transformer.setParameter("studentnumber", "s484766");

最佳答案

要读取参数值,您需要在其前面加上 $ 符号:

<xsl:value-of select="$studentnumber"/>

关于XSL 文件中的 Java setParameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8635705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com