gpt4 book ai didi

xslt - 如何在 without "select" attribute? 上强制出错

转载 作者:行者123 更新时间:2023-12-04 18:25:43 24 4
gpt4 key购买 nike

如果我使用 <xsl:param>不指定值,转换器假定该值为空字符串。

换句话说,如果我忘记指定一个值(例如 <xsl:param name="N"/> ),编译器不会发出错误信号。这可能会导致我的程序静默失败,这是一件坏事。

如何指定我的 <xsl:param> 必须有明确的值?例如,这段代码应该给我一个错误,因为没有指定明确的值:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="F1"></xsl:call-template>
<html>
<head>
<title></title>
</head>
<body>stuff</body>
</html>
</xsl:template>
<xsl:template name="F1">
<xsl:param name="N"/> <!-- I Should Get An Error Here! -->
</xsl:template>
</xsl:stylesheet>

正在寻找 XSLT 1.0 和 XSLT 2.0 中的解决方案。

最佳答案

当然,在 XSLT 2.0 中,您可以说 <xsl:param required="yes"> ,所以问题就消失了。

关于xslt - 如何在 <xsl :param> without "select" attribute? 上强制出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6531449/

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