1

パラメータに関連する私のJavaコードは次のとおりです。

    transformer.setParameter("limad","1234");
    transformer.transform(text, new StreamResult(response.getOutputStream()));

私のxsltには次のものがあります:

<xsl:template match="/">
    <xsl:param name="limad"/>
    .... lots of stuff here...
                                <td>
                                    <xsl:value-of select="$limad"/>
                                </td>
    .... lots of stuff here...
</xsl:template>

私の結果は次のとおりです: <td></td>

何か案は?どうすればこれをデバッグできますか?

4

1 に答える 1

3

私は Java の専門家ではありませんが、パラメーターを xslt に渡そうとする場合は、それらを template-match="/" の外に置く必要があります。

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">


<!-- Imports -->
<xsl:import href="test.xslt"/>

<xsl:output method="html"
                  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
                  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
                  indent="yes" standalone="yes"/>

 <!-- Parameters-->
<xsl:param name="limad"/>

<!-- Templates Match-->
<xsl:template match="/">
    .... lots of stuff here...
                                <td>
                                    <xsl:value-of select="$limad"/>
                                </td>
    .... lots of stuff here...
</xsl:template>
</xsl:stylesheet>
于 2012-08-03T21:05:22.310 に答える