简体   繁体   中英

How to transform XML to match XSD or DTD?

I have a Pentaho Kettle (PDI) transformation that starts with a Table Output step executing basic SQL. This step hops to an XML Output step that creates an XML file.

The xml format looks like this:

<series>
 <values><Date>2011&#47;03&#47;15 00:00:00.000</Date> <Media Cost>$136.08</Media Cost> <Clicks> 50.0</Clicks> </values>
 <values><Date>2011&#47;03&#47;16 00:00:00.000</Date> <Media Cost>$240.47</Media Cost> <Clicks> 71.0</Clicks> </values>

However, I need this XML to be a specific format. I do have an XML schema and DTD to define this format, just not sure the best way to get into that format.

Here is an example of how it needs to be formatted.

<series name="Media Cost">
<value>340</value>
<value>154</value>
<value>516</value>
<value>103</value>
<value>315</value>
</series>

<series name="Clicks">
<value>476</value>
<value>504</value>
<value>239</value>
<value>111</value>
<value>224</value>
</series>

Any advice is appreciated.

The only way I came up with to do this was to use the Add XML or the Append Stream transform steps and build the final output. I used Execute SQL statements to create the individual components and then joined them together to create the output that was required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM