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 回答