The question title is repeated cause it fits my case but it is indeed different.
I have a simple but complicated case, I am trying to fix a reader after an engine upgrade, and this has taking me a couple of days of frustration that I finally got here. This is what I’m trying to get:
I have this sample input file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2005/Atom" xmlns:csm="http://www.blabla.org/feed/2.0">
<entry>
<id>urn:nid:24477</id>
<csm:review star_rating="3">
<csm:themes>
<csm:theme id="1234">A theme value</csm:theme>
</csm:themes>
</csm:review>
<summary><![CDATA[This is the summary of this review]]></summary>
</entry>
</feed>
I found that the current faulty mapping code is this:
<Mappings>
<Mapping element="entry" outPort="1" xmlFields="id" cloverFields="csm_id_uri">
<Mapping element="csm:theme" outPort="0" parentKey="csm_id_uri" generatedKey="csm_id_uri" xmlFields="id" cloverFields="tag_id"/>
</Mapping>
</Mappings>
This mapping just reads nothing, all the records the log says they go to port1, but when I dump it to a file, the records are empty, no data is passed.
I think (not sure yet, but…) the expected record should have:
|urn:nid:24477|||1234||
which is:
/feed/entry/id → csm_id_uri = urn:nid:24477
/feed/entry/csm:review/csm:themes/csm:theme/@id → tag_id = 1234
and the rest of the fields are left blank.
The point is that I can’t get to have a single record with those values in a single record, I have been able to get one or the other, or two records per value.
I also tried this:
<Mapping element="entry" >
<Mapping element="csm:review">
<Mapping element="csm:themes">
<Mapping element="csm:theme" outPort="1"
xmlFields="id;../../../id"
cloverFields="tag_id;csm_id_uri" />
</Mapping>
</Mapping>
</Mapping>
but no matter what combination I try, I can not refer to a child element using the dots, if the upper Id was an attribute instead of a child element, the problem would have been solved already. Is there a way to achieve this?
I’m looking for a general way to map N to 1 with this structure, for example, having the input
<feed>
<entry>
<id>5555<id>
<listOfThings>
<item id=33>item 1</item>
<item id=44>item 2</item>
</listOfThings>
<entry>
<entry>
<id>6666<id>
<listOfThings>
<item id=77>item 3</item>
<item id=88>item 4</item>
</listOfThings>
<entry>
<feed>
to get these records:
|5555|33|||
|5555|44|||
|6666|77|||
|6666|88|||
All the examples I have found are where the same name input fields are of the same nature, usually an attribute.
Can anyone please help?
Thank you in advance.