How to use tXMLMAP

At first create a job named :txmlmaptest,enter the job‘s name and click finish。

Drag tJava component into the job,Then write this code。

The in1.xml code fragment

<root>

<students>
	<student>
		<name>zhaoxin</name>
		<age>29</age>
	</student>
	<student>
		<name>kobe</name>
		<age>30</age>
	</student>
</students>

</root>

Drag tFixFlowInput component into the job

add three column like this:

Give this three columns initialization values.

Right click tJava componet and open the Trigger menu ,click On Subjob Ok button。

Drag tXMLMap component into the job

Right click tFixFlowInput componet and open the Row menu, click Main。

Drag tLogRow component into the job

Right click tXMLMap and open Main menu, click new output button.

Double click tXMLMap component and config

step 1: add output column like this

step 2: import XML attributes

Right click inDoc and select import xml button.

Choose tjava component specified XML files:in1.xml.

After import xml.

Set loop element of the root node: right click Student element ,and select AS loop element button.

XML output element configuration

Right click root element and select Create Sub_Element button . enter the new element name :students

In the same way create :student

Drag the xml input element :name to xml output rootnode element student.

After Drag :

Set XML output loop element of the root node: right click Student element ,and select AS loop element button.

Drag input element :newcolumn 、newcolumn1 to output element.

Drag tJavaFlex component into the job

Double click tJavaFlex , In endcode input box enter this code

String outputDir1 = "C:/out1.xml";
java.io.FileOutputStream stream_tAFOX_1 = new java.io.FileOutputStream(outputDir1);
org.dom4j.io.XMLWriter output_tAFOX_1 = new org.dom4j.io.XMLWriter(stream_tAFOX_1);
output_tAFOX_1.write(row2.outDoc.getDocument());
output_tAFOX_1.close();

note :row2 is output attribute。

Run job

Generated XML files

Generated xml code fragments

<?xml version="1.0" encoding="UTF-8"?>
   <root>
 <students>
  <student>
	   <name>zhaoxin</name>
  </student>
  <student>
	  <name>kobe</name>
  </student>
           </students>
   </root>

The job source code

 
doc/component_txmlmap.txt · Last modified: 2011/12/17 03:52 (external edit)
 
 
Recent changes RSS feed Driven by DokuWiki