关于 xsl:try xsl:catch 中的错误信息的问题
Question about error Info in xsl:try xsl:catch
代码来自:try-catch-examples:
<xsl:result-document href="out.xml">
<xsl:variable name="result">
<xsl:call-template name="construct-output"/>
</xsl:variable>
<xsl:try>
<xsl:copy-of select="$result" validation="strict"/>
<xsl:catch>
<xsl:message>Warning: validation of result document failed:
Error code: <xsl:value-of select="$err:code"/>
Reason: <xsl:value-of select="$err:description"/>
</xsl:message>
<xsl:sequence select="$result"/>
</xsl:catch>
</xsl:try>
</xsl:result-document>
$err:code
、$err:description
是什么语法? “$err
”好像是个变量,为什么后面要跟一个冒号?它是什么类型的? code
、description
是什么类型?密钥字符串?
what syntax is the $err:code, $err:description? The "$err" seems to be
a variable, why it's followed by a colon? What type is it? What type
are code,description? a key string?
$somePrefix:localName
是一个变量引用,其名称属于一个命名空间,并且关联了前缀somePrefix
到那个命名空间。
在这种特殊情况下,err
前缀与 the standard error namespace 关联:http://www.w3.org/2005/xqt-errors
具体含义在XSLT 3.0 Specification中有解释:
"Within the select expression, or within the sequence constructor contained by the xsl:catch element, a number of variables are implicitly declared, giving information about the error that occurred. These are lexically scoped to the xsl:catch element. These variables are all in the standard error namespace, and they are initialized as described in the following table:"
上述引文中的短语:“隐式声明了许多变量”是理解如何在 [=21 中捕获错误的关键=]元素
这意味着每当在 xsl:catch
中捕获错误时,XSLT 处理器本身会创建这些变量,并将它们提供给程序员以在 xsl:catch
元素的范围内使用。
我们可以说这些变量中的每一个都是一个“future”,可以由充当“promise[=53=”的 XSLT 处理器创建]"——确切含义见:
"Futures and promises"
代码来自:try-catch-examples:
<xsl:result-document href="out.xml">
<xsl:variable name="result">
<xsl:call-template name="construct-output"/>
</xsl:variable>
<xsl:try>
<xsl:copy-of select="$result" validation="strict"/>
<xsl:catch>
<xsl:message>Warning: validation of result document failed:
Error code: <xsl:value-of select="$err:code"/>
Reason: <xsl:value-of select="$err:description"/>
</xsl:message>
<xsl:sequence select="$result"/>
</xsl:catch>
</xsl:try>
</xsl:result-document>
$err:code
、$err:description
是什么语法? “$err
”好像是个变量,为什么后面要跟一个冒号?它是什么类型的? code
、description
是什么类型?密钥字符串?
what syntax is the $err:code, $err:description? The "$err" seems to be a variable, why it's followed by a colon? What type is it? What type are code,description? a key string?
$somePrefix:localName
是一个变量引用,其名称属于一个命名空间,并且关联了前缀somePrefix
到那个命名空间。
在这种特殊情况下,err
前缀与 the standard error namespace 关联:http://www.w3.org/2005/xqt-errors
具体含义在XSLT 3.0 Specification中有解释:
"Within the select expression, or within the sequence constructor contained by the xsl:catch element, a number of variables are implicitly declared, giving information about the error that occurred. These are lexically scoped to the xsl:catch element. These variables are all in the standard error namespace, and they are initialized as described in the following table:"
上述引文中的短语:“隐式声明了许多变量”是理解如何在 [=21 中捕获错误的关键=]元素
这意味着每当在 xsl:catch
中捕获错误时,XSLT 处理器本身会创建这些变量,并将它们提供给程序员以在 xsl:catch
元素的范围内使用。
我们可以说这些变量中的每一个都是一个“future”,可以由充当“promise[=53=”的 XSLT 处理器创建]"——确切含义见: "Futures and promises"