Created
          February 28, 2020 14:01 
        
      - 
      
- 
        Save hbt/df6427efe8d6a0433c08b639611c5a5d to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| } | |
| { | |
| // // | |
| // let filenames = 'comp2.leo comp.leo oval2.xml etodos.leo fh.leo goals.leo housing.leo ia.leo outline.leo oval2.xml' | |
| // let files = filenames.split(' ') | |
| // files = files.filter((v) => { | |
| // return v.length > 0 | |
| // }) | |
| // let dir = '/tmp/tmp-1580816712' | |
| // files = files.map(v => { | |
| // return dir + '/' + v | |
| // }) | |
| // | |
| // for(let file of files) { | |
| // console.log(file) | |
| // let xml = fs.readFileSync(file).toString() | |
| // // | |
| // var convert = require('xml-js'); | |
| // var result1 = convert.xml2json(xml, {compact: false}); | |
| // let json = JSON.parse(result1) | |
| // console.dir(json) | |
| // // | |
| // let xml2 = convert.json2xml(result1, {compact: false}) | |
| // fs.writeFileSync('/tmp/gg.xml', xml2) | |
| // let ret = Utils.shell('xmllint /tmp/gg.xml', {cwd: '/tmp'}) | |
| // console.log(ret) | |
| // } | |
| } | |
| { | |
| // | |
| // let xml = fs.readFileSync('/tmp/oval3.xml').toString() | |
| // | |
| // var convert = require('xml-js'); | |
| // // var result1 = convert.xml2json(xml, {compact: true}); | |
| // var result1 = convert.xml2json(xml, {compact: false}); | |
| // let json = JSON.parse(result1) | |
| // console.dir(json) | |
| // // console.dir(json['elements']) | |
| // | |
| // // let xml2 = convert.json2xml(result1, {compact: true}) | |
| // let xml2 = convert.json2xml(result1, {compact: false}) | |
| // fs.writeFileSync('/tmp/oval2.xml', xml2) | |
| // console.dir(xml2) | |
| // | |
| } | |
| { | |
| // | |
| // let xml = fs.readFileSync('/home/hassen/workspace/acc-dev/transhumanjourney/comp.leo').toString() | |
| // | |
| // var convert = require('xml-js'); | |
| // var result1 = convert.xml2json(xml, {compact: false, spaces: 4}); | |
| // let json = JSON.parse(result1) | |
| // console.dir(json['elements']) | |
| // | |
| // // let xml2 = convert.json2xml(result1, {compact: false}) | |
| // // fs.writeFileSync('/tmp/gg.leo', xml2) | |
| // // console.dir(xml2) | |
| } | |
| { | |
| // | |
| // let xml = fs.readFileSync('/home/hassen/workspace/acc-dev/transhumanjourney/comp.leo').toString() | |
| // | |
| // var parser = require('xml2json'); | |
| // var json = JSON.parse(parser.toJson(xml, { | |
| // object: false, | |
| // reversible: true, | |
| // coerce: false, | |
| // sanitize: false, | |
| // trim: false, | |
| // arrayNotation: false, | |
| // alternateTextNode: false | |
| // })); | |
| // console.log(json) | |
| // | |
| // let str = JSON.stringify(json) | |
| // let xml2 = parser.toXml(str) | |
| // | |
| // sassert(xml === xml2) | |
| // fs.writeFileSync('/tmp/gg.leo', xml2) | |
| // | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment