I’ve been trying to create (since I can’t find a downloadable .grf) the graph that is given as the “Data Load” example on this page: http://www.cloveretl.com/examples/transformations, in which daily exchange rates for the Euro are obtained from a website and written to a CSV file. On the example page, there is a Reformat transformation named “Add timestamp”, which I assume grabs the current time and adds it to each output row.
Now the XML returned from the website is a little unusual, but it does include the date for the given exchange rates:
The problem is, I have not been able to find a way to extract the time value from the XML and have it included in every output row.
I’m probably overlooking something obvious, but if anyone could point me in the right direction, I’d appreciate it. Is it possible, and if it is, is it possible without sequences (which, for example, are not available in the Community Edition)?
Hello,
the graph presented on the web pages can be accessed from the Welcome Page of CloverETL Designer (see attached picture) or created as the new example project (see CloverETL Examples Project).
To obtain the time directly from the xml file, you need to add another port (for upper Cube tag) and change the mapping as follows:
parentKey=“date” informs port 1 to get value from “date” field of port 0
generatedKey=“date” informs, that field “date” of port 1 is fulfilled with some value from port 0
Thanks for the quick reply. I had looked at parentKey and generatedKey, but misunderstood how they worked (I thought you needed a join function afterwards).
I now have a working graph. However, I came across something that I didn’t think was intuitive. If this graph is to work, then both output ports from XMLExtract have to be connected to something. i.e. you can’t just connect port1 (currency, rate and date) and ignore port0 (date). If you have just one connector, it always defaults to port0. So I had to connect port0 to trash, and port1 to my output object. I tried renaming port1 to port0, and port1 to port0, and just connect port0, but then date is *not* extracted from port1 and added to port0. Also, once I connect the 2 output ports, it shows a 3rd output port in the graph, even though I haven’t defined one. IMHO, the graphical representation should always accurately reflect the graph.
ParentKey and generatedKey (applicable both or none of them) create kind of a binding between a parent element and its child element. Using this keys it is uniquely determined to which parent element a child element belongs to. Moreover, this information is stored in the generatedKey field of child metadata. That is why no join is neccessary here - the time value becomes a part of child metadata. If the original xml file parent element does not have such unique attribute, a Clover sequence needs to be applied.
Regarding the ports, each nested xml element level that is mapped (according to mapping definition) must be sent to its own port. In this case, the element is mapped to get the generatedKey value and as we do not need the value any more, it is sent to Trash. That is why two ports are defined.
As it comes to the 3rd empty port displayed, it refers to CloverETL standard behaviour - anytime you connect an edge to a port and additional one appears, it is because the component allows you to connect the newly displayed port to an edge. Only if the number of output/input ports is stable and not changeable (e.g. Trash can have only one input port), no additional port appears.