我想使用相同的 xslt 并针对不同的输出(即 xml、html、xhtml 和文本)进行测试;当然我正在这样做:
<xsl:output method="xml" indent="yes"/>
OR
<xsl:output method="html" indent="yes"/>
但我想通过一个通知参数动态更改,如果我省略它,则默认为 xml。
我试过这个:
<xsl:param name="outputMethod" select="xml" />
<xsl:output method="$outputMethod"indent="yes"/>
没有成功,输出是:
XTSE0020: Invalid value for serialization method: must be
xml|html|xhtml|text|json|adaptive, or a QName in '{uri}local' form
并尝试了这种更复杂的方式,我知道:
<xsl:variable name="thisDocument" select="document('')" />
<xsl:param name="outputMethod" select="xml" />
<xsl:variable name="myOutputMethod" select="$outputMethod"/>
<xsl:output method="$thisDocument/xsl:stylesheet/myOutputMethod" indent="yes"/>
也没有成功,输出是:
Static error at xsl:output on line 10 column 85 of CopyingNodes.xslt:
XTSE0020: Both the prefix {$thisDocument/xsl} and the local part
{stylesheet/myOutputMethod} are invalid
Errors were reported during stylesheet compilation
那么,有更正吗?建议?
或者是否无法动态更改 xsl:output 方法?
TIA