Socket
Socket
Sign inDemoInstall

xmlbuilder

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

4

lib/XMLAttribute.js

@@ -14,4 +14,4 @@ // Generated by CoffeeScript 1.6.1

}
if (_.isFunction(value)) {
value = value.apply();
if (value == null) {
throw new Error("Missing attribute value");
}

@@ -18,0 +18,0 @@ this.name = this.stringify.attName(name);

@@ -25,2 +25,3 @@ // Generated by CoffeeScript 1.6.1

}
this.options = options;
this.stringify = new XMLStringifier(options);

@@ -35,3 +36,3 @@ temp = new XMLElement(this, 'doc');

if ((options.pubID != null) || (options.sysID != null)) {
root.doctype(options.pubID, options.sysID);
root.doctype(options);
}

@@ -38,0 +39,0 @@ }

@@ -20,3 +20,2 @@ // Generated by CoffeeScript 1.6.1

function XMLElement(parent, name, attributes) {
var attName, attValue;
XMLElement.__super__.constructor.call(this, parent);

@@ -30,8 +29,4 @@ if (name == null) {

this.attributes = {};
for (attName in attributes) {
if (!__hasProp.call(attributes, attName)) continue;
attValue = attributes[attName];
if ((attName != null) && (attValue != null)) {
this.attributes[attName] = new XMLAttribute(this, attName, attValue);
}
if (attributes != null) {
this.attribute(attributes);
}

@@ -69,13 +64,17 @@ }

XMLElement.prototype.attribute = function(name, value) {
var _ref;
if (name == null) {
throw new Error("Missing attribute name");
var attName, attValue;
if (_.isObject(name)) {
for (attName in name) {
if (!__hasProp.call(name, attName)) continue;
attValue = name[attName];
this.attribute(attName, attValue);
}
} else {
if (_.isFunction(value)) {
value = value.apply();
}
if (!this.options.skipNullAttributes || (value != null)) {
this.attributes[name] = new XMLAttribute(this, name, value);
}
}
if (value == null) {
throw new Error("Missing attribute value");
}
if ((_ref = this.attributes) == null) {
this.attributes = {};
}
this.attributes[name] = new XMLAttribute(this, name, value);
return this;

@@ -85,6 +84,14 @@ };

XMLElement.prototype.removeAttribute = function(name) {
var attName, _i, _len;
if (name == null) {
throw new Error("Missing attribute name");
}
delete this.attributes[name];
if (_.isArray(name)) {
for (_i = 0, _len = name.length; _i < _len; _i++) {
attName = name[_i];
delete this.attributes[attName];
}
} else {
delete this.attributes[name];
}
return this;

@@ -94,5 +101,21 @@ };

XMLElement.prototype.instruction = function(target, value) {
var instruction;
instruction = new XMLProcessingInstruction(this, target, value);
this.instructions.push(instruction);
var insTarget, insValue, instruction, _i, _len;
if (_.isArray(target)) {
for (_i = 0, _len = target.length; _i < _len; _i++) {
insTarget = target[_i];
this.instruction(insTarget);
}
} else if (_.isObject(target)) {
for (insTarget in target) {
if (!__hasProp.call(target, insTarget)) continue;
insValue = target[insTarget];
this.instruction(insTarget, insValue);
}
} else {
if (_.isFunction(value)) {
value = value.apply();
}
instruction = new XMLProcessingInstruction(this, target, value);
this.instructions.push(instruction);
}
return this;

@@ -99,0 +122,0 @@ };

@@ -12,2 +12,3 @@ // Generated by CoffeeScript 1.6.1

this.parent = parent;
this.options = this.parent.options;
this.stringify = this.parent.stringify;

@@ -42,8 +43,8 @@ }

}
if (this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
} else if (this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) {
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && key.indexOf(this.stringify.convertPIKey) === 0) {
lastChild = this.instruction(key.substr(this.stringify.convertPIKey.length), val);
} else if (_.isObject(val)) {
if (this.stringify.convertListKey && key.indexOf(this.stringify.convertListKey) === 0 && _.isArray(val)) {
if (!this.options.ignoreDecorators && this.stringify.convertListKey && key.indexOf(this.stringify.convertListKey) === 0 && _.isArray(val)) {
lastChild = this.element(val);

@@ -59,10 +60,9 @@ } else {

} else {
name = '' + name;
if (this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
lastChild = this.text(text);
} else if (this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
} else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
lastChild = this.cdata(text);
} else if (this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
} else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
lastChild = this.comment(text);
} else if (this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
} else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
lastChild = this.raw(text);

@@ -114,3 +114,9 @@ } else {

XMLNode.prototype.node = function(name, attributes, text) {
var XMLElement, child;
var XMLElement, child, _ref;
if (attributes == null) {
attributes = {};
}
if (!_.isObject(attributes)) {
_ref = [attributes, text], text = _ref[0], attributes = _ref[1];
}
XMLElement = require('./XMLElement');

@@ -117,0 +123,0 @@ child = new XMLElement(this, name, attributes);

@@ -14,5 +14,2 @@ // Generated by CoffeeScript 1.6.1

}
if (_.isFunction(value)) {
value = value.apply();
}
this.target = this.stringify.insTarget(target);

@@ -19,0 +16,0 @@ if (value) {

{
"name": "xmlbuilder",
"version": "2.0.1",
"version": "2.1.0",
"keywords": [ "xml", "xmlbuilder" ],

@@ -5,0 +5,0 @@ "homepage": "http://github.com/oozcitak/xmlbuilder-js",

# xmlbuilder-js
An XMLBuilder for [node.js](http://nodejs.org/) similar to
An XML builder for [node.js](http://nodejs.org/) similar to
[java-xmlbuilder](http://code.google.com/p/java-xmlbuilder/).

@@ -5,0 +5,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc