xmlbuilder
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -25,5 +25,3 @@ // Generated by CoffeeScript 1.9.1 | ||
} | ||
if (version != null) { | ||
this.version = this.stringify.xmlVersion(version); | ||
} | ||
this.version = this.stringify.xmlVersion(version); | ||
if (encoding != null) { | ||
@@ -37,6 +35,2 @@ this.encoding = this.stringify.xmlEncoding(encoding); | ||
XMLDeclaration.prototype.clone = function() { | ||
return create(XMLDeclaration.prototype, this); | ||
}; | ||
XMLDeclaration.prototype.toString = function(options, level) { | ||
@@ -55,5 +49,3 @@ var indent, newline, offset, pretty, r, ref, ref1, ref2, space; | ||
r += '<?xml'; | ||
if (this.version != null) { | ||
r += ' version="' + this.version + '"'; | ||
} | ||
r += ' version="' + this.version + '"'; | ||
if (this.encoding != null) { | ||
@@ -60,0 +52,0 @@ r += ' encoding="' + this.encoding + '"'; |
@@ -43,6 +43,2 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLDocType.prototype.clone = function() { | ||
return create(XMLDocType.prototype, this); | ||
}; | ||
XMLDocType.prototype.element = function(name, value) { | ||
@@ -49,0 +45,0 @@ var child; |
@@ -38,6 +38,2 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLDTDAttList.prototype.clone = function() { | ||
return create(XMLDTDAttList.prototype, this); | ||
}; | ||
XMLDTDAttList.prototype.toString = function(options, level) { | ||
@@ -44,0 +40,0 @@ var indent, newline, offset, pretty, r, ref, ref1, ref2, space; |
@@ -23,6 +23,2 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLDTDElement.prototype.clone = function() { | ||
return create(XMLDTDElement.prototype, this); | ||
}; | ||
XMLDTDElement.prototype.toString = function(options, level) { | ||
@@ -29,0 +25,0 @@ var indent, newline, offset, pretty, r, ref, ref1, ref2, space; |
@@ -44,6 +44,2 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLDTDEntity.prototype.clone = function() { | ||
return create(XMLDTDEntity.prototype, this); | ||
}; | ||
XMLDTDEntity.prototype.toString = function(options, level) { | ||
@@ -50,0 +46,0 @@ var indent, newline, offset, pretty, r, ref, ref1, ref2, space; |
@@ -25,6 +25,2 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLDTDNotation.prototype.clone = function() { | ||
return create(XMLDTDNotation.prototype, this); | ||
}; | ||
XMLDTDNotation.prototype.toString = function(options, level) { | ||
@@ -31,0 +27,0 @@ var indent, newline, offset, pretty, r, ref, ref1, ref2, space; |
@@ -42,8 +42,4 @@ // Generated by CoffeeScript 1.9.1 | ||
XMLNode.prototype.clone = function() { | ||
throw new Error("Cannot clone generic XMLNode"); | ||
}; | ||
XMLNode.prototype.element = function(name, attributes, text) { | ||
var item, j, key, lastChild, len, ref, val; | ||
var childNode, item, j, k, key, lastChild, len, len1, ref, val; | ||
lastChild = null; | ||
@@ -77,6 +73,2 @@ if (attributes == null) { | ||
} | ||
if (!val && !this.options.ignoreDecorators && this.stringify.convertListKey && key.indexOf(this.stringify.convertListKey) === 0) { | ||
lastChild = this; | ||
continue; | ||
} | ||
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { | ||
@@ -86,9 +78,12 @@ lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); | ||
lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val); | ||
} else if (Array.isArray(val)) { | ||
for (k = 0, len1 = val.length; k < len1; k++) { | ||
item = val[k]; | ||
childNode = {}; | ||
childNode[key] = item; | ||
lastChild = this.element(childNode); | ||
} | ||
} else if (isObject(val)) { | ||
if (!this.options.ignoreDecorators && this.stringify.convertListKey && key.indexOf(this.stringify.convertListKey) === 0 && Array.isArray(val)) { | ||
lastChild = this.element(val); | ||
} else { | ||
lastChild = this.element(key); | ||
lastChild.element(val); | ||
} | ||
lastChild = this.element(key); | ||
lastChild.element(val); | ||
} else { | ||
@@ -95,0 +90,0 @@ lastChild = this.element(key, val); |
@@ -81,3 +81,3 @@ // Generated by CoffeeScript 1.9.1 | ||
val = '' + val || ''; | ||
if (!val.match(/[A-Za-z](?:[A-Za-z0-9._-]|-)*/)) { | ||
if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-]|-)*$/)) { | ||
throw new Error("Invalid encoding: " + val); | ||
@@ -140,4 +140,2 @@ } | ||
XMLStringifier.prototype.convertListKey = '#list'; | ||
XMLStringifier.prototype.assertLegalChar = function(str) { | ||
@@ -144,0 +142,0 @@ var chars, chr; |
{ | ||
"name": "xmlbuilder", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"keywords": [ | ||
@@ -29,3 +29,6 @@ "xml", | ||
"coffee-script": "*", | ||
"mocha": "*" | ||
"mocha": "*", | ||
"coffee-coverage": "*", | ||
"istanbul": "*", | ||
"coveralls": "*" | ||
}, | ||
@@ -35,4 +38,4 @@ "scripts": { | ||
"postpublish": "rm -rf lib", | ||
"test": "mocha --ui tdd --reporter dot --compilers coffee:coffee-script/register --require test/common/common" | ||
"test": "mocha && istanbul report text lcov" | ||
} | ||
} |
# xmlbuilder-js | ||
An XML builder for [io.js](https://iojs.org/) similar to | ||
An XML builder for [node.js](https://nodejs.org/) similar to | ||
[java-xmlbuilder](https://github.com/jmurty/java-xmlbuilder). | ||
[![License](http://img.shields.io/npm/l/xmlbuilder.svg?style=flat-square)](http://opensource.org/licenses/MIT) | ||
[![NPM Version](http://img.shields.io/npm/v/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder) | ||
[![License](http://img.shields.io/npm/l/xmlbuilder.svg?style=flat-square)](http://opensource.org/licenses/MIT) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/xmlbuilder.svg?style=flat-square)](https://npmjs.com/package/xmlbuilder) | ||
[![Build Status](http://img.shields.io/travis/oozcitak/xmlbuilder-js.svg?style=flat-square)](http://travis-ci.org/oozcitak/xmlbuilder-js) | ||
[![Dependency Status](http://img.shields.io/david/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://david-dm.org/oozcitak/xmlbuilder-js) | ||
[![Dev Dependency Status](http://img.shields.io/david/dev/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://david-dm.org/oozcitak/xmlbuilder-js) | ||
[![Code Coverage](https://img.shields.io/coveralls/oozcitak/xmlbuilder-js.svg?style=flat-square)](https://coveralls.io/github/oozcitak/xmlbuilder-js) | ||
@@ -23,3 +26,3 @@ ### Installation: | ||
var xml = builder.create('root') | ||
.ele('xmlbuilder', {'for': 'node-js'}) | ||
.ele('xmlbuilder') | ||
.ele('repo', {'type': 'git'}, 'git://github.com/oozcitak/xmlbuilder-js.git') | ||
@@ -36,3 +39,3 @@ .end({ pretty: true}); | ||
<root> | ||
<xmlbuilder for="node-js"> | ||
<xmlbuilder> | ||
<repo type="git">git://github.com/oozcitak/xmlbuilder-js.git</repo> | ||
@@ -49,5 +52,4 @@ </xmlbuilder> | ||
xmlbuilder: { | ||
'@for': 'node-js', // attributes start with @ | ||
repo: { | ||
'@type': 'git', | ||
'@type': 'git', // attributes start with @ | ||
'#text': 'git://github.com/oozcitak/xmlbuilder-js.git' // text node | ||
@@ -54,0 +56,0 @@ } |
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
87
53125
5
1344