Hi,

I am able to index XML with same "name" element but in different XPATH by
using XPathEntityProcessor "forEach" (e.g. below)

Just wondering if there is better way to handle this xml format.

a) Is there any better way to handle this scenario as xml file will have
multiple sub-menu attributes (e.g. A, B, C, D...)
and I will have to specify each in "forEach" attribute.

b) How to differentiate xml result from two entities defined in
data-config.xml

Example xml
<menu>
<A>
<name>Waffles</name>
<price>$2.95</price>
</A>
<B>
<name>Strawberry</name>
<description>
Light waffles covered with strawberries
</description>
<price>$3.95</price>
</B>
</menu>

Example dataConfig
<dataConfig>
<dataSource type="FileDataSource" encoding="UTF-8" />
<document>
<entity name="actions"
processor="XPathEntityProcessor"
stream="true"
forEach="/menu/A | /menu/B"
url="C:/tmp/menu.xml"
transformer="RegexTransformer,DateFormatTransformer">

<field column="name" xpath="/menu/A/name" />
<field column="price" xpath="/menu/A/price" />

<field column="name" xpath="/menu/B/name" />
<field column="description" xpath="/menu/B/description" />
<field column="price" xpath="/menu/B/price" />
</entity>
</document>
</dataConfig>

Result :
"docs": [
      {
        "name": "Waffles",
        "value": "$2.95"
      },
      {
        "description": "Light waffles covered with strawberries",
        "name": "Strawberry",
        "value": "$3.95"
      }
    ]

Reply via email to