如何在 Talend tFileOutputXML 中自定义根标签

How to customize Root tags in Talend tFileOutputXML

我创建了使用 tFileOutputXML 输出 xml 文件的 Talend 程序。它工作正常,但问题是我在页脚节点标签中的根标签必须与 header 节点标签不同。

在高级设置中,我将 root 添加为:

代码是自己生成的,长这样:

String[] footers_tFileOutputXML_1 = new String[2];

headers_tFileOutputXML_1[1] = "<"
                    + "rss xmlns:g='http://base.google.com/ns/1.0' version='2.0'"
                    + ">";

footers_tFileOutputXML_1[0] = "</"
                    + "rss xmlns:g='http://base.google.com/ns/1.0' version='2.0'"
                    + ">";

但我需要 footers_tFileOutputXML_1[0] 看起来像这样:

footers_tFileOutputXML_1[0] = "</"
                    + "rss"
                    + ">";

我尝试用 java 编辑器编辑并保存,但它再次生成代码。知道如何解决这个问题吗?

您需要使用 tAdvancedFileOuputXML 组件才能指定命名空间。

单击组件选项卡上的 Configure XML Tree

  1. 将根标签重命名为“rss”
  2. 右键单击将属性命名为“version”并设置一个静态值
  3. 右击设置命名空间。

结果: