[英]Pentaho Data Integration (Spoon) Import XML with nested elements
I have the following xml data structure and I'm trying to create a transformation in Pentaho that gives the output shown in the linked image.我有以下 xml 数据结构,我正在尝试在 Pentaho 中创建一个转换,以提供链接图像中显示的 output。 The data has elements nested in elements and I can only seem to set the Loop XPath option to get either the main_components or the sub_components.
数据中有嵌套在元素中的元素,我似乎只能设置 Loop XPath 选项来获取 main_components 或 sub_components。
<?xml version="1.0" encoding="UTF-8"?>
<components>
<main_component>
<name>Engine</name>
<ref_no>336820-182</ref_no>
<oem>Ford</oem>
</main_component>
<main_component>
<name>Gearbox</name>
<ref_no>378912-009</ref_no>
<oem>GM</oem>
</main_component>
<main_component>
<name>Fuel Tank</name>
<ref_no>378927</ref_no>
<oem>GM</oem>
<sub_component>
<name>Fuel Pump</name>
<ref_no>27182A</ref_no>
<oem>Lucus</oem>
</sub_component>
<name>Contents Unit</name>
<ref_no>1219290</ref_no>
<oem>Honeywell</oem>
</sub_component>
</main_component>
</components>
You need to use "XML Input Stream" and need to write small javascript code to get parent node information.您需要使用“XML 输入流”并且需要编写小 javascript 代码来获取父节点信息。 (Here I have set the variable if parent node is available and read those variable if child node is available as parent information of that child)
(如果父节点可用,我在这里设置变量,如果子节点可用作为该子节点的父信息,则读取这些变量)
//Script here var pName=null; var pRef=null; var pOem=null; if( xml_path_level2,= null){ pName = getVariable("VName";""), pRef = getVariable("VRef";""), pOem = getVariable("VOem";""), } else{ setVariable( "VName",Name;"s"), setVariable( "VRef",Ref_no;"s"), setVariable( "VOem",Oem;"s"); }
You can found sample from Here你可以从这里找到样本
Pleasae let me know if its ok with you.请让我知道您是否可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.