使用xslt对常见的分离XML输入进行DVM转换

时间:2016-01-12 07:43:31

标签: xslt xslt-1.0

我们正在处理一些奇怪的要求并寻找你的帮助。这是问题陈述。

作为对我们流程的请求,我们正在输入

foo :: (Integer -> Integer -> Integer) -> (Integer -> Integer -> Integer) -> Integer -> Integer -> Integer
foo f g x y = f (g x y) y

现在我们需要一个XSLT,DVM(SOA 11g)来将这些值转换为输出

<element1>A,B,C</element1>

我们需要在XSLT中实现这一点。

1 个答案:

答案 0 :(得分:0)

在我研究这个create-nodeset-from-delimited-string()函数时,这是一个纯XSLT 1.0解决方案。它似乎是一个oracle扩展?

此模板将采用给定的pText(例如/ element1 / text()),并将命名模板(FUNC)与分隔字符串的每个部分调用为ARG1。

您可能希望根据需要对其进行编辑。

<xsl:template name="split">
  <xsl:param name="pText"/>
  <xsl:param name="separator" select="','" />
  <xsl:choose>
    <xsl:when test="string-length($pText) = 0"/>
    <xsl:when test="contains($pText, $separator)">
      <xsl:call-template name="FUNC">
        <xsl:with-param name="ARG1" select="substring-before($pText, $separator)"/>
      </xsl:call-template>

      <xsl:call-template name="split">
        <xsl:with-param name="pText" select="substring-after($pText, $separator)"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="FUNC">
        <xsl:with-param name="ARG1" select="$pText"/>
      </xsl:call-template>

    </xsl:otherwise>
  </xsl:choose>
</xsl:template>