避免自我关闭标记 - Biztalk信封模式

时间:2015-03-16 10:43:25

标签: xml xslt biztalk

在我的XSLT调用模板下面,我想避免在值为空时自行关闭标记。

如果没有值,则Error标记的输出为:

<ns0:Error />

但是我想把输出作为

<ns0:Error></ns0:Error>  

1 个答案:

答案 0 :(得分:0)

您拥有的一个选项是将输出方法更改为&#39; html&#39;,这应该会阻止自动关闭代码:

<xsl:output method="html" indent="yes" />

如果这不是一个选项,因为输出不是html,我认为它不是来自你的例子,那么你可能想通过在元素中添加空白内容来欺骗XSLT。

<xsl:variable name="blank" select="''"/>
<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()" />
    <xsl:value-of select="$blank"/>
  </xsl:copy>
</xsl:template>