How to check the existence of XML attributes and elements

It is possible to create graph, that read XML and check for existence of some attribute or element? Attribute may or may not have a value, it could be ssd=”” or ssd=”vvvv”.

Yes. You may use XPath functions in the mapping xpath attribute. Function “empty()” is useful in this scenario.

Example input xml:

<employees>

    <employee>
        <empID>1</empID>
        <name ssd="dd">
            <firstname>Mark</firstname>
            <surname>Fish</surname>
        </name>
        <ShieldedRecordNotification/>
    </employee>
      <employee>
        <empID>2</empID>
        <name ssd="">
            <firstname>Jane</firstname>
            <surname>Simson</surname>
        </name>
    </employee>
      <employee>
        <empID>3</empID>
        <name>
            <firstname>Brandon</firstname>
            <surname>Morrison</surname>
        </name>
        <ShieldedRecordNotification>abcde</ShieldedRecordNotification>
    </employee>

</employees>

Example mapping:

<Context xpath="/employees/employee" outPort="0">
        <Mapping xpath="empID" cloverField="empID"/>
        <Mapping xpath="name/firstname" cloverField="firstname"/>
        <Mapping xpath="name/surname" cloverField="surname"/>
        <Mapping xpath="not(empty(name/@ssd))" cloverField="ssdAttributeExists"/>
        <Mapping xpath="not(empty(ShieldedRecordNotification))" cloverField="ShieldedRecordNotificationElementExists"/>
</Context>

Example result:


1;Mark;Fish;true;true
2;Jane;Simson;true;false
3;Brandon;Morrison;false;true