Applying business rules using xslt -
i have requirement choose value xml based on business rules. below source xml
<?xml version="1.0" encoding="utf-8" ?> <ns2:getplotownersbyplotidresponse xmlns="urn:tst:tst:aad:aaeett:data:profile:messages" xmlns:ns2="urn:tst:tst:aad:aaeett:data:profile" xmlns:ns3="http://schemas.microsoft.com/2003/10/serialization/arrays" xmlns:ns4="urn:tst:tst:aad:aaeett:data:profile:data" xmlns:ns5="urn:tst:tst:aad:aaeett:data:profile:fault" xmlns:ns6="http://schemas.microsoft.com/2003/10/serialization/"> <ns2:getplotownersbyplotidresult> <ownerslist> <ns4:ownerwithshares> <ns4:ownerinfo xsi:type="ns4:persondetails" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <ns4:ownertype>person</ns4:ownertype> <ns4:personinfo> <ns4:ownernamear>abc1</ns4:ownernamear> <ns4:ownernameen>abc1</ns4:ownernameen> </ns4:personinfo> </ns4:ownerinfo> <ns4:sharelist> <ns4:sharedetails> <ns4:acquisitiontype>ac1</ns4:acquisitiontype> <ns4:ownershippercentage>10</ns4:ownershippercentage> <ns4:rightholdtype>ownership</ns4:rightholdtype> </ns4:sharedetails> </ns4:sharelist> </ns4:ownerwithshares> <ns4:ownerwithshares> <ns4:ownerinfo xsi:type="ns4:persondetails" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <ns4:ownertype>person</ns4:ownertype> <ns4:personinfo> <ns4:ownernamear>abc3</ns4:ownernamear> <ns4:ownernameen>abc3</ns4:ownernameen> </ns4:personinfo> </ns4:ownerinfo> <ns4:sharelist> <ns4:sharedetails> <ns4:acquisitiontype>ac3</ns4:acquisitiontype> <ns4:ownershippercentage>35</ns4:ownershippercentage> <ns4:rightholdtype>partnership</ns4:rightholdtype> </ns4:sharedetails> </ns4:sharelist> </ns4:ownerwithshares> <ns4:ownerwithshares> <ns4:ownerinfo xsi:type="ns4:persondetails" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <ns4:ownertype>person</ns4:ownertype> <ns4:personinfo> <ns4:ownernamear>abc2</ns4:ownernamear> <ns4:ownernameen>abc2</ns4:ownernameen> </ns4:personinfo> </ns4:ownerinfo> <ns4:sharelist> <ns4:sharedetails> <ns4:acquisitiontype>ac2</ns4:acquisitiontype> <ns4:ownershippercentage>25</ns4:ownershippercentage> <ns4:rightholdtype>partnership</ns4:rightholdtype> </ns4:sharedetails> </ns4:sharelist> </ns4:ownerwithshares> <ns4:ownerwithshares> <ns4:ownerinfo xsi:type="ns4:persondetails" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <ns4:ownertype>person</ns4:ownertype> <ns4:personinfo> <ns4:ownernamear>abc4</ns4:ownernamear> <ns4:ownernameen>abc4</ns4:ownernameen> </ns4:personinfo> </ns4:ownerinfo> <ns4:sharelist> <ns4:sharedetails> <ns4:acquisitiontype>ac4</ns4:acquisitiontype> <ns4:ownershippercentage>30</ns4:ownershippercentage> <ns4:rightholdtype>ownership</ns4:rightholdtype> </ns4:sharedetails> </ns4:sharelist> </ns4:ownerwithshares> </ownerslist> </ns2:getplotownersbyplotidresult> </ns2:getplotownersbyplotidresponse>
below target xml.
<ns4:ownerinfo xsi:type="ns4:persondetails" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <ns4:ownertype>person</ns4:ownertype> <ns4:personinfo> <ns4:ownernamear>abc4</ns4:ownernamear> <ns4:ownernameen>abc4</ns4:ownernameen> </ns4:personinfo> </ns4:ownerinfo>
and below business rules
owner name should showed based on below conditions.
rule 1 : if rightholdtype = ownership show owner name, if multiple values found follow rule 2.
rule 2 : output of rule one, select owner highest value in ownership percentage. if multiple values found follow rule 3
rule 3 : sort owner_name output rule 2 in alphabetical order , select first owner.
Comments
Post a Comment