Comparing version 0.9.5 to 0.9.6
@@ -1,3 +0,1 @@ | ||
/*jslint node:true */ | ||
var common = require('./common'); | ||
@@ -70,3 +68,3 @@ | ||
} | ||
xml += (options.spaces && element[options.elementsKey] && element[options.elementsKey].length && (element[options.elementsKey].length > 1 || element[options.elementsKey][0].type !== 'text') ? '\n' : '') + Array(depth + 1).join(options.spaces); | ||
xml += (options.spaces && element[options.elementsKey] && element[options.elementsKey].length && (element[options.elementsKey].length > 1 || element[options.elementsKey][0].type !== 'text') ? '\n' + Array(depth + 1).join(options.spaces) : ''); | ||
xml += '</' + element.name + '>'; | ||
@@ -73,0 +71,0 @@ } else { |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
var js2xml = require('./js2xml.js'); | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
var sax = require('sax'); | ||
@@ -3,0 +2,0 @@ var expat /*= require('node-expat');*/ = {on: function () {}, parse: function () {}}; |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
var common = require('./common'); | ||
@@ -3,0 +2,0 @@ var xml2js = require('./xml2js'); |
{ | ||
"name": "xml-js", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"description": "A convertor between XML text and Javascript object / JSON text.", | ||
@@ -47,15 +47,15 @@ "main": "index.js", | ||
"biased-opener": "^0.2.8", | ||
"browser-sync": "^2.14.3", | ||
"browser-sync": "^2.17.5", | ||
"cash-cat": "^0.2.0", | ||
"codacy-coverage": "^2.0.0", | ||
"codeclimate-test-reporter": "^0.3.3", | ||
"coveralls": "^2.11.12", | ||
"cross-env": "^2.0.1", | ||
"codeclimate-test-reporter": "^0.4.0", | ||
"coveralls": "^2.11.14", | ||
"cross-env": "^3.1.3", | ||
"globify": "^1.2.2", | ||
"istanbul": "^0.4.5", | ||
"jasmine": "^2.4.1", | ||
"jasmine": "^2.5.2", | ||
"node-inspector": "^0.12.8", | ||
"nodemon": "^1.10.2", | ||
"npm-run-all": "^3.1.0", | ||
"watch": "^0.19.2" | ||
"nodemon": "^1.11.0", | ||
"npm-run-all": "^3.1.1", | ||
"watch": "^1.0.1" | ||
}, | ||
@@ -82,3 +82,3 @@ "scripts": { | ||
"git:push": "git push origin master", | ||
"deploy": "npm-run-all --serial istanbul:coveralls git:commit", | ||
"deploy": "npm-run-all --serial coverage git:commit", | ||
"coverage": "npm-run-all coverage:*", | ||
@@ -88,7 +88,7 @@ "coverage:a-step": "npm run istanbul", | ||
"coverage:codacy": "cross-env CODACY_PROJECT_TOKEN=0207815122ea49a68241d1aa435f21f1 cat ./test/browse-coverage/lcov.info | codacy-coverage", | ||
"coverage:codeclimate": "cross-env CODECLIMATE_REPO_TOKEN=60848a077f9070acf358b0c7145f0a2698a460ddeca7d8250815e75aa4333f7d codeclimate-test-reporter < coverage\\lcov.info", | ||
"coverage:codeclimate": "cross-env CODECLIMATE_REPO_TOKEN=60848a077f9070acf358b0c7145f0a2698a460ddeca7d8250815e75aa4333f7d codeclimate-test-reporter < test\\browse-coverage\\lcov.info", | ||
"update-packages": "npm-check-updates --upgrade --loglevel verbose", | ||
"xprepublish": "npm run test", | ||
"prepublish": "npm run test", | ||
"test": "npm run jasmine" | ||
} | ||
} |
@@ -33,3 +33,3 @@ ![XML ⇔ JS/JSON](http://nashwaan.github.io/xml-js/images/logo.svg) | ||
* **Fully XML Compliant**: | ||
Can parse: Comments, Processing Instructions, XML Declarations, Entity declarations, and CDATA Sections. | ||
Can parse: elements, attributes, texts, comments, CData, and XML declarations. | ||
@@ -76,3 +76,3 @@ * **Reversible**: | ||
```shell | ||
npm install xml-js | ||
npm install --save xml-js | ||
``` | ||
@@ -83,3 +83,3 @@ | ||
```shell | ||
npm install -g xml-js | ||
npm install --global xml-js | ||
``` | ||
@@ -141,3 +141,3 @@ | ||
| `compact` | `false` | Whether the *input* object is in compact form or not. | | ||
| `fullTagEmptyElement` | `false` | Whether to produce element without sub-elements as full tag pairs `<a></a>` rather than self closing tag `</a>`. | | ||
| `fullTagEmptyElement` | `false` | Whether to produce element without sub-elements as full tag pairs `<a></a>` rather than self closing tag `<a/>`. | | ||
| `ignoreDeclaration` | `false` | Whether to ignore writing declaration directives of xml. For example, `<?xml?>` will be ignored. | | ||
@@ -211,5 +211,7 @@ | `ignoreAttributes` | `false` | Whether to ignore writing attributes of the elements. For example, `x="1"` in `<a x="1"></a>` will be ignored | | ||
```shell | ||
npm install -g xml-js // install this library globally | ||
xml-js test.json // test.json will be converted to test.xml | ||
xml-js test.xml // test.xml will be converted to test.json | ||
npm install -g xml-js // install this library globally | ||
xml-js test.json --space 4 // xml result will be printed on screen | ||
xml-js test.json --space 4 --out test.xml // xml result will be saved to test.xml | ||
xml-js test.xml --space 4 // json result will be printed on screen | ||
xml-js test.xml --space 4 --out test.json // json result will be saved to test.json | ||
``` | ||
@@ -232,3 +234,3 @@ | ||
"scripts": { | ||
"convert": "xml-js test.json" | ||
"convert": "xml-js test.json --spaces 4" | ||
} | ||
@@ -301,3 +303,3 @@ ``` | ||
Use [this link](https://github.com/nashwaan/xml-js/issues) to report an issue or bug. Please include a sample code or Jasmine test spec where the code is failing. | ||
Use [this link](https://github.com/nashwaan/xml-js/issues) to report an issue or bug. Please include a sample code where the code is failing. | ||
@@ -304,0 +306,0 @@ # License |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true*/ | ||
/*global describe,it,expect,beforeEach,afterEach*/ | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true*/ | ||
/*global describe,it,expect,beforeEach,afterEach*/ | ||
@@ -3,0 +2,0 @@ |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
var fs = require('fs'); | ||
@@ -7,8 +6,8 @@ var convertor = require('..'); | ||
return fs.readdirSync('fixtures/') | ||
.filter(function (file) { | ||
return file.slice(-4) === type;}) | ||
.map(function (file) { | ||
return 'fixtures/' + file;}) | ||
.filter(function (file) { | ||
return fs.statSync(file).isFile();}); | ||
.filter(function (file) { | ||
return file.slice(-4) === type;}) | ||
.map(function (file) { | ||
return 'fixtures/' + file;}) | ||
.filter(function (file) { | ||
return fs.statSync(file).isFile();}); | ||
} | ||
@@ -15,0 +14,0 @@ |
@@ -1,3 +0,1 @@ | ||
/*jslint node:true */ | ||
var path = require('path'); | ||
@@ -4,0 +2,0 @@ var jasmine = new (require('jasmine'))(); |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
/*global describe,it,expect,beforeEach*/ | ||
@@ -294,3 +293,3 @@ | ||
'</snippet>'; | ||
it('should output cdata and text unformatted', function () { | ||
@@ -306,2 +305,39 @@ expect(convert.js2xml(js, {compact: true})).toEqual(xml.replace(/\v|\n/g, '')); | ||
describe('case by Denis Carriere ', function () { | ||
// see https://github.com/nashwaan/xml-js/issues/5 | ||
var js1 = { | ||
a: { | ||
b: { | ||
_text: 'foo bar', | ||
} | ||
} | ||
}; | ||
var js2 = { | ||
elements: [{ | ||
type: 'element', | ||
name: 'a', | ||
elements: [{ | ||
type: 'element', | ||
name: 'b', | ||
elements: [{ | ||
type: 'text', | ||
text: 'foo bar' | ||
}], | ||
}] | ||
}] | ||
}; | ||
var xml = '<a>\n' + | ||
'\v<b>foo bar</b>\n' + | ||
'</a>'; | ||
it('should output xml of compact js input', function () { | ||
expect(convert.js2xml(js1, {compact: true, spaces: 4})).toEqual(xml.replace(/\v/g, ' ')); | ||
}); | ||
it('should output xml of non-compact js input', function () { | ||
expect(convert.js2xml(js2, {compact: false, spaces: 4})).toEqual(xml.replace(/\v/g, ' ')); | ||
}); | ||
}); | ||
}); | ||
@@ -308,0 +344,0 @@ |
@@ -1,3 +0,1 @@ | ||
/*jslint node:true */ | ||
var cases = [ | ||
@@ -4,0 +2,0 @@ { |
@@ -1,2 +0,1 @@ | ||
/*jslint node:true */ | ||
/*global describe,it,expect,beforeEach,afterEach*/ | ||
@@ -246,2 +245,64 @@ | ||
describe('User reported issues:', function () { | ||
describe('case by Mark Pareja', function () { | ||
var xml = '<?xml version="1.0" encoding="utf-8"?>' + '\n' + | ||
'<dp:ListServicesReply ReturnCode="0" xmlns:dp="http://www.cisco.com/vtg/diagnosticportal">' + '\n' + | ||
' <dp:Schema Version="1.0" />' + '\n' + | ||
' <dp:ServiceList>' + '\n' + | ||
' <dp:Service Name="Cisco ICM usgd1 LoggerA" Description="Provides Call Logging services for Instance usgd1" Status="Running" StartupType="Auto" LogOnAs="****" />' + '\n' + | ||
' <dp:Service Name="Cisco ICM Diagnostic Framework" Description="Provides a web-based diagnostic service for Cisco Unified ICM, Contact Center Enterprise application." Status="Running" StartupType="Auto" LogOnAs="LocalSystem" />' + '\n' + | ||
' </dp:ServiceList>' + '\n' + | ||
'</dp:ListServicesReply>'; | ||
var json = { | ||
"_declaration": { | ||
"_attributes": { | ||
"version": "1.0", | ||
"encoding": "utf-8" | ||
} | ||
}, | ||
"dp:ListServicesReply": { | ||
"_attributes": { | ||
"ReturnCode": "0", | ||
"xmlns:dp": "http://www.cisco.com/vtg/diagnosticportal" | ||
}, | ||
"dp:Schema": { | ||
"_attributes": { | ||
"Version": "1.0" | ||
} | ||
}, | ||
"dp:ServiceList": { | ||
"dp:Service": [ | ||
{ | ||
"_attributes": { | ||
"Name": "Cisco ICM usgd1 LoggerA", | ||
"Description": "Provides Call Logging services for Instance usgd1", | ||
"Status": "Running", | ||
"StartupType": "Auto", | ||
"LogOnAs": "****" | ||
} | ||
}, | ||
{ | ||
"_attributes": { | ||
"Name": "Cisco ICM Diagnostic Framework", | ||
"Description": "Provides a web-based diagnostic service for Cisco Unified ICM, Contact Center Enterprise application.", | ||
"Status": "Running", | ||
"StartupType": "Auto", | ||
"LogOnAs": "LocalSystem" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
it('should output ', function () { | ||
expect(convert.xml2json(xml, {compact: true})).toEqual(JSON.stringify(json)); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
722537
43
12181
301
2
10