GLEIF Sample (XML)

GLEIF Sample (XML)


Version
Download 2
Total Views 29
Stock
File Size 3.46 MB
File Type xml
Create Date December 10, 2018
Last Updated December 11, 2018
Download

Example to convert this XML file into a JSON format file, using curl:

curl --data @leismall.xml -H "Content-Type: application/xml" -X POST http://localhost:8080/XMLtoJSON/GLEIF/GLEIF/LEIRecord

Note: You must have the GLEIF schema installed in the MARS server to use this

Input is in XML form like this:

<?xml version='1.0' encoding='UTF-8'?>
<lei:LEIData xmlns:gleif="http://www.gleif.org/concatenated-file/header-extension/2.0" xmlns:lei="http://www.gleif.org/data/schema/leidata/2016">
<lei:LEIHeader>
<lei:ContentDate>2017-12-05T09:00:01+00:00</lei:ContentDate>
<lei:FileContent>GLEIF_FULL_PUBLISHED</lei:FileContent>
<lei:RecordCount>824170</lei:RecordCount>
 </lei:LEIHeader>
<lei:LEIRecords>
<lei:LEIRecord>
<lei:LEI>029200137F2K8AH5C573</lei:LEI>
<lei:Entity>
<lei:LegalName xml:lang="en">CAPITAL ASSETS LIMITED</lei:LegalName>
<lei:OtherEntityNames>
<lei:OtherEntityName xml:lang="fr" type="ALTERNATIVE_LANGUAGE_LEGAL_NAME">CAPITAL ASSETS LIMITED</lei:OtherEntityName>
</lei:OtherEntityNames>
<lei:LegalAddress xml:lang="en">
<lei:FirstAddressLine>9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET</lei:FirstAddressLine>
<lei:AdditionalAddressLine>P.O. BOX 702 LAGOS</lei:AdditionalAddressLine>
<lei:City>LAGOS</lei:City>
<lei:Region>NG-LA</lei:Region>
<lei:Country>NG</lei:Country>
<lei:PostalCode>23401</lei:PostalCode>
</lei:LegalAddress>
<lei:HeadquartersAddress xml:lang="en">
<lei:FirstAddressLine>9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET</lei:FirstAddressLine>
<lei:AdditionalAddressLine>P.O. BOX 702 LAGOS</lei:AdditionalAddressLine>
<lei:City>LAGOS</lei:City>
<lei:Region>NG-LA</lei:Region>
<lei:Country>NG</lei:Country>
</lei:HeadquartersAddress>
<lei:OtherAddresses>
<lei:OtherAddress xml:lang="fr" type="ALTERNATIVE_LANGUAGE_HEADQUARTERS_ADDRESS">
<lei:FirstAddressLine>9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET</lei:FirstAddressLine>
<lei:AdditionalAddressLine>P.O. BOX 702 LAGOS</lei:AdditionalAddressLine>
<lei:City>LAGOS</lei:City>
<lei:Region>NG-LA</lei:Region>
<lei:Country>NG</lei:Country>
<lei:PostalCode>23401</lei:PostalCode>
</lei:OtherAddress>
</lei:OtherAddresses>
<lei:RegistrationAuthority>
<lei:RegistrationAuthorityID>RA000469</lei:RegistrationAuthorityID>
<lei:RegistrationAuthorityEntityID>RC286096</lei:RegistrationAuthorityEntityID>
</lei:RegistrationAuthority>
<lei:LegalJurisdiction>NG-LA</lei:LegalJurisdiction>
<lei:LegalForm>
<lei:EntityLegalFormCode>8888</lei:EntityLegalFormCode>
<lei:OtherLegalForm>LIMITED</lei:OtherLegalForm>
</lei:LegalForm>
<lei:EntityStatus>ACTIVE</lei:EntityStatus>
</lei:Entity>
<lei:Registration>
<lei:InitialRegistrationDate>2014-11-06T00:00:00Z</lei:InitialRegistrationDate>
<lei:LastUpdateDate>2017-11-07T09:40:44+08:00</lei:LastUpdateDate>
<lei:RegistrationStatus>LAPSED</lei:RegistrationStatus>
<lei:NextRenewalDate>2017-11-06T00:00:00Z</lei:NextRenewalDate>
<lei:ManagingLOU>029200067A7K6CH0H586</lei:ManagingLOU>
<lei:ValidationSources>FULLY_CORROBORATED</lei:ValidationSources>
<lei:ValidationAuthority>
<lei:ValidationAuthorityID>RA000469</lei:ValidationAuthorityID>
</lei:ValidationAuthority>
</lei:Registration>
</lei:LEIRecord>
</lei:LEIRecords>
</lei:LEIData>

Output will appear in JSON:

[{
"Entity": {
"LegalForm": {
"OtherLegalForm": "LIMITED",
"EntityLegalFormCode": "8888"
},
"RegistrationAuthority": {
"RegistrationAuthorityEntityID": "RC286096",
"RegistrationAuthorityID": "RA000469"
},
"OtherEntityNames": [],
"LegalAddress": {
"AdditionalAddressLine": "P.O. BOX 702 LAGOS",
"PostalCode": "23401",
"FirstAddressLine": "9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET",
"City": "LAGOS",
"Country": "NG",
"Region": "NG-LA"
},
"OtherAddresses": [
{
"OtherAddress": {
"Country": "NG",
"Region": "NG-LA",
"City": "LAGOS",
"AdditionalAddressLine": "P.O. BOX 702 LAGOS",
"PostalCode": "23401",
"FirstAddressLine": "9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET"
}
}
],
"HeadquartersAddress": {
"City": "LAGOS",
"Region": "NG-LA",
"FirstAddressLine": "9TH FLOOR BOOKSHOP HOUSE, 50/52 BROAD STREET",
"AdditionalAddressLine": "P.O. BOX 702 LAGOS",
"Country": "NG"
},
"LegalName": "CAPITAL ASSETS LIMITED",
"EntityStatus": "ACTIVE",
"LegalJurisdiction": "NG-LA"
},
"LEI": "029200137F2K8AH5C573",
"Registration": {
"ValidationAuthority": {
"ValidationAuthorityID": "RA000469"
},
"InitialRegistrationDate": "2014-11-06T00:00:00Z",
"ManagingLOU": "029200067A7K6CH0H586",
"LastUpdateDate": "2017-11-07T09:40:44+08:00",
"ValidationSources": "FULLY_CORROBORATED",
"NextRenewalDate": "2017-11-06T00:00:00Z",
"RegistrationStatus": "LAPSED"
}
}
]

If you capture the output of the above command, you can use the Json Objects in the other MARS methods like compare, index or standardise:

curl --data @leismall.xml -H "Content-Type: application/xml" -X POST http://localhost:8080/XMLtoJSON/GLEIF/GLEIF/LEIRecord | curl --data @- -H "Content-Type: application/json" -X POST http://localhost:8080/compare/GLEIF/GLEIF

Although I really don't recommend you do this!! It will compare all the records in the file with themselves - which could take some time. Alternatively the output of the XMLtoJSON should be passed to the index method and only the records that share the same keys produced from this should be compared:

curl --data @leismall.xml -H "Content-Type: application/xml" -X POST http://localhost:8080/XMLtoJSON/GLEIF/GLEIF/LEIRecord | curl --data @- -H "Content-Type: application/json" -X POST "http://localhost:8080/index/GLEIF/GLEIF?isMatch=true&isSearch=false" > index.json

A better way to process larger files would be using nodejs:

IE Use the output of the XMLtoJSON to index the objects.

var fs = require('fs');
var http = require('http');
var array = require("./objects.json");
var closed=0;
var arrayData=new Array();
for (var i=0; i<array.length; i++){
  const options = {
   hostname: 'localhost',
   port: 8080,
   path: '/index/GLEIF/GLEIF/?isMatch=true&isSearch=false',
   method: 'POST',
   headers: {
   'Content-Type': 'application/json',
   'Content-Length': Buffer.byteLength(JSON.stringify(array[i]))
  }
 };
 const req = http.request(options, (res) => {
 var stringData="";
 res.setEncoding('utf8');
 res.on('data', (chunk) => {
   if (!res.stringData)
    res.stringData=chunk
   else
    res.stringData+=chunk;
   });
  res.on('end', () => {
   req.end();
   closed++;
   var arrayItems=JSON.parse(res.stringData);
   for (var j=0; j<arrayItems.length; j++){
     arrayData.push(arrayItems[j]);
   }
   if (closed==array.length){
    var stream = fs.createWriteStream("index.json");
    for (var k=0; k<arrayData.length; k++){
    if (k!=0) 
     stream.write(",
");
     stream.write(JSON.stringify(arrayData[k]));
    }
    stream.close();
   }
  });
 });

 req.on('error', (e) => {
   console.error(`problem with request: ${e.message}`);
 });

 req.write(JSON.stringify(array[i]));
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *