0

我有一个主 xsl,它包含两个不同 xsl 的单独引用,如下所示,但问题是 ThaT 在我转换它时会引发异常

请告知我的主要 xsl 格式正确,或者我遗漏了一些东西..

    <xsl:import href="qwe.xsl"/>
    <xsl:import href="qrt.xsl"/>

    <xsl:template match="/abml">
        <cfabcmessage>
            <defflows>
                <xsl:variable name="ttSystem">
                    <xsl:call-template name=ttSystem_template"/>
                </xsl:variable>
                <xsl:choose>
                    <xsl:when test="ttSystem = 'ABC'">
                        <xsl:call-template name="dgddsh_ABC"/>
                    </xsl:when>
                        <xsl:call-template name="hjsgscjkd_DEG"/>
                </xsl:choose>
            </defflows>
        </cfabcmessage>
    </xsl:template>
</xsl:stylesheet>

我已经完成了更正,但仍然在转换时我仍然收到此错误..

21:03:34,892 ERROR [main] JAXPSAXProcessorInvoker  - xsl:when is not allowed in this position in the stylesheet!;
4

3 回答 3

1

您在 之前缺少双引号ttSystem_template,并且您在 thexsl:call-template的结束xsl:when和 的结束之间有一个xsl:choose。将xsl:call-template(1) 移到 内xsl:when, (2) 移到 内xsl:otherwise,或 (3) 移到 外xsl:choose。(你也错过了开始xsl:stylesheet标签,但这可能只是一个复制和粘贴错误。)

这是您的 XSLT 的完整、更正的副本:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:import href="qwe.xsl"/>
  <xsl:import href="qrt.xsl"/>

  <xsl:template match="/abml">
    <cfabcmessage>
      <defflows>
        <xsl:variable name="ttSystem">
          <xsl:call-template name="ttSystem_template"/>
        </xsl:variable>
        <xsl:choose>
          <xsl:when test="ttSystem = 'ABC'">
            <xsl:call-template name="dgddsh_ABC"/>
            <!-- 1. Want call to hjsgscjkd_DEG it here? -->
            <xsl:call-template name="hjsgscjkd_DEG"/>
          </xsl:when>
            <!-- XXX  Call to hjsgscjkd_DEG cannot go here. -->
          <xsl:otherwise>
            <!-- 2. Want call to hjsgscjkd_DEG it here? -->
            <xsl:call-template name="hjsgscjkd_DEG"/>
          </xsl:otherwise>
        </xsl:choose>
        <!-- 3. Want call to hjsgscjkd_DEG it here? -->
        <xsl:call-template name="hjsgscjkd_DEG"/>
      </defflows>
    </cfabcmessage>
  </xsl:template>
</xsl:stylesheet>
于 2013-10-23T16:04:01.627 回答
1

关于新问题,尚不清楚何时要调用第二个“调用模板”,但如果这应该是“其他”条件,那么您需要使用“xsl:otherwise”

            <xsl:choose>
                <xsl:when test="ttSystem = 'ABC'">
                    <xsl:call-template name="dgddsh_ABC"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="hjsgscjkd_DEG"/>
                </xsl:otherwise>
            </xsl:choose>
于 2013-10-23T16:23:17.003 回答
1

您在 name 属性的以下行中缺少双引号:

<xsl:call-template name="ttSystem_template"/>

不确定您是否只是省略了第一行,但您还需要以下内容:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
于 2013-10-23T14:52:02.333 回答