最近研究xsl解析xml生产html功能;实现过程中发现生成 特定格式的xml 文件比较麻烦。kettle本身提供xml生产组件;但是太弱了,捣腾了好久终于实现了;今天有空把它贴出来。
xml写入方式一)
作业设计如图:
生产xml数据如下:
<?xml version="1.0" encoding="UTF-8"?>
<Rows>
<Row><school_id>1</school_id> <teacher_name>tom</teacher_name> <student_name>juli</student_name> <location>shenzhen</location> </Row>
<Row><school_id>2</school_id> <teacher_name>jack</teacher_name> <student_name>lurry</student_name> <location>shanghai</location> </Row>
<Row><school_id>3</school_id> <teacher_name>rose</teacher_name> <student_name>aiven</student_name> <location>guangzhou</location> </Row>
</Rows>
xml写入方式二)
xml结果数据如下:
<?xml version="1.0" encoding="UTF-8"?> <root> <teacher> <Row> <teacher_id>1</teacher_id> <teacher_name>tom</teacher_name> </Row> <Row> <teacher_id>2</teacher_id> <teacher_name>jack</teacher_name> </Row> <Row> <teacher_id>3</teacher_id> <teacher_name>rose</teacher_name> </Row> </teacher> <student> <Row> <student_id>1</student_id> <student_name>juli</student_name> </Row> <Row> <student_id>2</student_id> <student_name>lurry</student_name> </Row> <Row> <student_id>3</student_id> <student_name>aiven</student_name> </Row> </student> <location> <Row> <location_id>1</location_id> <location>shenzhen</location> </Row> <Row> <location_id>2</location_id> <location>shanghai</location> </Row> <Row> <location_id>3</location_id> <location>guangzhou</location> </Row> </location> </root>