Commit de025e60 authored by Nauman Rupani's avatar Nauman Rupani

Initial commit

parents
Pipeline #35 canceled with stages
node_modules/
nominees.xml
nominees.html
const convert = require("xml-js");
const fs = require("fs");
const xmlData = fs.readFileSync("./nominees.xml", "utf-8");
const compactJson = JSON.parse(convert.xml2json(xmlData, { compact: true }));
const nominees = compactJson.root.nominee;
const generateNameValueHTML = (name_classes, name, value_classes, value) => {
return `
<div class="${name_classes}">${name}</div>
<div class="${value_classes}">${value}</div>
<br/>
`
}
const wrapHTMLInContainer = (container_classes, title_classes, title, html) => {
return `
<div class="${container_classes}">
<div class="${title_classes}">${title}</div>
<br/>
${html}
<hr/>
</div>
`
}
let outputHTML = "";
for (const nominee of nominees) {
const attributes = nominee._attributes;
const {
fname: firstName,
mname: middleName,
lname: lastName,
prevlname: previousLastName,
gender,
ismaili,
maritalstatus: maritalStatus,
famcountryoforigin: familyCountryOfOrigin,
countryofbirth: countryOfBirth,
yearmigrated: yearMigrated,
linkedin: linkedinURL
} = attributes;
let personalDetailsHTML = ""
personalDetailsHTML += generateNameValueHTML("caption", "First Name", "value", firstName);
personalDetailsHTML += generateNameValueHTML("caption", "Middle Name", "value", middleName);
personalDetailsHTML += generateNameValueHTML("caption", "Last Name", "value", lastName);
personalDetailsHTML += generateNameValueHTML("caption", "Last Name", "value", previousLastName);
personalDetailsHTML += generateNameValueHTML("caption", "Gender", "value", gender);
personalDetailsHTML += generateNameValueHTML("caption", "Ismaili", "value", ismaili);
personalDetailsHTML += generateNameValueHTML("caption", "Marital Status", "value", maritalStatus);
personalDetailsHTML += generateNameValueHTML("caption", "Family Country of Origin", "value", familyCountryOfOrigin);
personalDetailsHTML += generateNameValueHTML("caption", "Country of Birth", "value", countryOfBirth);
outputHTML += wrapHTMLInContainer("nominee-container", "nominee-container-title", `Personal Details for ${firstName}`, personalDetailsHTML);
migrationHTML = generateNameValueHTML("caption", "Year Migrated", "value", yearMigrated);
outputHTML += wrapHTMLInContainer("nominee-container", "nominee-container-title", "Migration", migrationHTML);
let professionalSummary = nominee.professionalsummary ? nominee.professionalsummary._text : "";
let professions = nominee.professions;
if (professions && professions.profession) {
// Assuming the index-0 is latest profession
let professionalProfileHTML = ""
const profession = Array.isArray(professions.profession) ? professions.profession[0] : professions.profession;
const {
category,
industry,
country
} = profession._attributes;
professionalProfileHTML += generateNameValueHTML("caption", "Employment Type", "value", category);
professionalProfileHTML += generateNameValueHTML("caption", "Industry", "value", industry);
professionalProfileHTML += generateNameValueHTML("caption", "Country", "value", country);
professionalProfileHTML += generateNameValueHTML("caption", "LinkedIn Profile", "value", linkedinURL);
professionalProfileHTML += generateNameValueHTML("caption", "Professional Summary", "value", professionalSummary);
outputHTML += wrapHTMLInContainer("nominee-container", "nominee-container-title", "Professional Profile", professionalProfileHTML)
}
outputHTML += "<hr/>";
}
outputHTML = `
<html>
<head>
<style>
</style>
</head>
<body>
${outputHTML}
</body>
</html>
`
fs.writeFileSync("nominees.html", outputHTML);
\ No newline at end of file
{
"name": "nomex-beautify",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "nomex-beautify",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"xml-js": "^1.6.11"
}
},
"node_modules/sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"node_modules/xml-js": {
"version": "1.6.11",
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
"dependencies": {
"sax": "^1.2.4"
},
"bin": {
"xml-js": "bin/cli.js"
}
}
},
"dependencies": {
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"xml-js": {
"version": "1.6.11",
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
"requires": {
"sax": "^1.2.4"
}
}
}
}
{
"name": "nomex-beautify",
"version": "1.0.0",
"description": "Convert NOMEX XML data to HTML",
"main": "index.js",
"scripts": {
"convert": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"xml-js": "^1.6.11"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment