【问题标题】:How do I index XML data within a content node?如何索引内容节点中的 XML 数据?
【发布时间】:2019-05-20 17:22:10
【问题描述】:

我正在转换一个 XML 文档,并希望将整个内容转储到转换器的内容节点中。

<xsl:template match="/">
  <vce>
    <document>
      <content name="xml">
        <xsl:copy-of select="." />
      </content>
    </document>
  </vce>
</xsl:template>

这给了我一个名为“XML”的节点和我的整个 xml 内容。但是,当归一化转换器运行时,这将被删除。我需要做一些特别的事情来为内容中的 XML 编制索引吗?

【问题讨论】:

    标签: ibm-watson watson-explorer


    【解决方案1】:

    我能够引用转换器:'vse-converter-xml-to-vxml' 来创建索引 xml 的模板:

    <xsl:template match="/">
    
      <vce>
        <document>
          <content name="xml">
            <xsl:apply-templates select="*" mode="xml-to-plain-text" />
          </content>
        </document>
      </vce>
    </xsl:template>
    
    <xsl:template match="*" mode="xml-to-plain-text">
      <xsl:text><![CDATA[<]]></xsl:text>
      <xsl:value-of select="name()" />
      <xsl:text> </xsl:text>
      <xsl:choose>
        <xsl:when test="text()|*|comment()">
          <xsl:text>></xsl:text>
          <xsl:apply-templates select="text()|*|comment()" mode="xml-to-plain-text" />
          <xsl:text><![CDATA[</]]></xsl:text>
          <xsl:value-of select="name()" />
          <xsl:text>></xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>/></xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多