使用xslt对公共分离XML输入进行DVM转换

使用xslt对公共分离XML输入进行DVM转换,xslt,xslt-1.0,Xslt,Xslt 1.0,我们正在处理一些奇怪的需求,并寻求您的帮助。这是问题陈述 作为对我们流程的请求,我们作为 <element1>A,B,C</element1> A、B、C 现在我们需要一个XSLT、DVM(SOA11G)来转换这些值,以便像 <output>X,Y,Z</output> X,Y,Z 我们需要在XSLT中实现这一点。在我研究create-nodeset-from-delimited-string()函数时,这里有一个纯XSLT1.0解决方案。

我们正在处理一些奇怪的需求,并寻求您的帮助。这是问题陈述

作为对我们流程的请求,我们作为

<element1>A,B,C</element1>
A、B、C
现在我们需要一个XSLT、DVM(SOA11G)来转换这些值,以便像

<output>X,Y,Z</output>
X,Y,Z

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

在我研究create-nodeset-from-delimited-string()函数时,这里有一个纯XSLT1.0解决方案。它似乎是oracle的扩展

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

您可能需要根据自己的需要对其进行编辑

<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>

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

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

您可能需要根据自己的需要对其进行编辑

<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>


I a尝试使用create-nodeset-from-delimited-string()函数拆分逗号分隔的输入,稍后我们需要转换该字符串。I a尝试使用create-nodeset-from-delimited-string()函数拆分逗号分隔的输入,稍后我们需要转换该字符串。