xslt 文档功能问题 [英] xslt document function question

查看:21
本文介绍了xslt 文档功能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果使用文档功能并打开可能不存在的文件,例如

If one is using the document function and opening up files that might not exist e.g.

<xsl:variable name="input" select="document($A)/document/input"/>

处理错误的优雅方式是什么?如果无法打开文件,我想要变量的默认值.

what is the graceful way of handling the error? I would like a default value for the variable if the file can't be opened.

推荐答案

我相信你可以像这样写你的:

I believe you can write your <xsl:variable> like so:

<xsl:variable name="input">
 <xsl:choose>
  <xsl:when test="document($A)/document/testElementCondition = 'foo'">
   <xsl:value-of select="document($A)/document/input" />
  </xsl:when>
  <xsl:otherwise>
   <!-- add some default source document and logic that will then direct to an error message. -->
  </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

很糟糕的是,您经常不得不被黑客攻击才能在 XSL 中完成工作.

It is too bad that you often have to result to hacks to get things done in XSL.

这篇关于xslt 文档功能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆