Skip to Content

How to remove the record(XML) based on some condition.

Hi All,

I want to Remove record from XML based on input field values.

Is this Possible through XSLT mapping?.

Regards,

Aditya

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 17, 2017 at 07:03 AM

    Hi Aditya!

    You can apply template to source document which copies only elements that fit your condition. Thus, unwanted records will be skipped.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 17, 2017 at 09:51 AM

    Hello Aditya,

    Agree with evegniy.From SAP HCI perspective you can use Content Filter which might fit into your requirement instead of writing XSLT to perform the same.

    Below example might help you.

    Goal is to pull Active employees from India who are permanent.

    Condition in Content Filter:

    Input XML:

    <?xml version="1.0" encoding="UTF-8"?>
    <EmployeeData>
        <Record>
            <PersonID>1000</PersonID>
            <UserID>31</UserID>
            <EmployementID>E221</EmployementID>
            <Status>A</Status>
            <Country>IND</Country>
            <Contractor>No</Contractor>
        </Record>
        <Record>
            <PersonID>1001</PersonID>
            <UserID>32</UserID>
            <EmployementID>E222</EmployementID>
            <Status>T</Status>
            <Country>SGP</Country>
        </Record>
        <Record>
            <PersonID>1002</PersonID>
            <UserID>33</UserID>
            <EmployementID>E223</EmployementID>
            <Status>A</Status>
            <Country>CAN</Country>
        </Record>
        <Record>
            <PersonID>C1003</PersonID>
            <UserID>C34</UserID>
            <EmployementID>C224</EmployementID>
            <Status>A</Status>
            <Country>IND</Country>
            <Contractor>Yes</Contractor>
        </Record>
    </EmployeeData>

    Output XML:

    <Record>
            <PersonID>1000</PersonID>
            <UserID>31</UserID>
            <EmployementID>E221</EmployementID>
            <Status>A</Status>
            <Country>IND</Country>
            <Contractor>No</Contractor>
     </Record>

    You can have Content Modifier after Content Filter and rebuild the XML with root node [ Having EmployeeData as root node ]

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded