Robert
Robert

Reputation: 325

Java setParameter in XSL file

I have a problem with printing PDF file from a Java project that is adding parameters in the XLS file. The project read the XML file, then he is generate a PDF file from the XSL style sheet. See below for the content of the files.
As you see in the XLS file I want to specified at “studentNumber”, but the problem is that is specified “studentNumber” need to set in the Java project. I have tried a lot of thing and search on internet but I cannot find the answer. Any idea want I need to change to make this project proper.

XML file:

<?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 file:

<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 code:

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

Upvotes: 0

Views: 1951

Answers (1)

Costi Ciudatu
Costi Ciudatu

Reputation: 38195

For reading the parameter value, you need to prefix it with a $ sign:

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

Upvotes: 2

Related Questions