Socket
Socket
Sign inDemoInstall

xmlbuilder

Package Overview
Dependencies
0
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.0.7 to 10.0.0

4

CHANGELOG.md

@@ -5,2 +5,5 @@ # Change Log

## [9.0.7] - 2018-02-09
- simplified regex used for validating encoding.
## [9.0.4] - 2017-08-16

@@ -349,2 +352,3 @@ - `spacebeforeslash` writer option accepts `true` as well as space char(s).

[9.0.7]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.4...v9.0.7
[9.0.4]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.3...v9.0.4

@@ -351,0 +355,0 @@ [9.0.3]: https://github.com/oozcitak/xmlbuilder-js/compare/v9.0.2...v9.0.3

2

lib/index.js

@@ -18,3 +18,3 @@ // Generated by CoffeeScript 1.12.7

if (name == null) {
throw new Error("Root element needs a name");
throw new Error("Root element needs a name.");
}

@@ -21,0 +21,0 @@ options = assign({}, xmldec, doctype, options);

// Generated by CoffeeScript 1.12.7
(function() {
var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
slice = [].slice,

@@ -61,2 +61,10 @@ hasProp = {}.hasOwnProperty;

getValue = function(obj) {
if (isFunction(obj.valueOf)) {
return obj.valueOf();
} else {
return obj;
}
};
module.exports.assign = assign;

@@ -74,2 +82,4 @@

module.exports.getValue = getValue;
}).call(this);

@@ -9,7 +9,8 @@ // Generated by CoffeeScript 1.12.7

this.stringify = parent.stringify;
this.parent = parent;
if (name == null) {
throw new Error("Missing attribute name of element " + parent.name);
throw new Error("Missing attribute name. " + this.debugInfo(name));
}
if (value == null) {
throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
throw new Error("Missing attribute value. " + this.debugInfo(name));
}

@@ -28,2 +29,16 @@ this.name = this.stringify.attName(name);

XMLAttribute.prototype.debugInfo = function(name) {
var ref, ref1;
name = name || this.name;
if ((name == null) && !((ref = this.parent) != null ? ref.name : void 0)) {
return "";
} else if (name == null) {
return "parent: <" + this.parent.name + ">";
} else if (!((ref1 = this.parent) != null ? ref1.name : void 0)) {
return "attribute: {" + name + "}";
} else {
return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
}
};
return XMLAttribute;

@@ -30,0 +45,0 @@

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (text == null) {
throw new Error("Missing CDATA text");
throw new Error("Missing CDATA text. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ this.text = this.stringify.cdata(text);

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (text == null) {
throw new Error("Missing comment text");
throw new Error("Missing comment text. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ this.text = this.stringify.comment(text);

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

XMLDocType.__super__.constructor.call(this, parent);
this.name = "!DOCTYPE";
this.documentObject = parent;

@@ -27,0 +28,0 @@ if (isObject(pubID)) {

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

XMLDocument.__super__.constructor.call(this, null);
this.name = "?xml";
options || (options = {});

@@ -22,0 +23,0 @@ if (!options.writer) {

// Generated by CoffeeScript 1.12.7
(function() {
var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref,
hasProp = {}.hasOwnProperty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;

@@ -41,2 +41,3 @@ XMLElement = require('./XMLElement');

var writerOptions;
this.name = "?xml";
options || (options = {});

@@ -65,13 +66,13 @@ if (!options.writer) {

if (name == null) {
throw new Error("Missing node name");
throw new Error("Missing node name.");
}
if (this.root && this.currentLevel === -1) {
throw new Error("Document can only have one root node");
throw new Error("Document can only have one root node. " + this.debugInfo(name));
}
this.openCurrent();
name = name.valueOf();
name = getValue(name);
if (attributes == null) {
attributes = {};
}
attributes = attributes.valueOf();
attributes = getValue(attributes);
if (!isObject(attributes)) {

@@ -101,6 +102,6 @@ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];

if (!this.currentNode || this.currentNode.children) {
throw new Error("att() can only be used immediately after an ele() call in callback mode");
throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
}
if (name != null) {
name = name.valueOf();
name = getValue(name);
}

@@ -128,3 +129,3 @@ if (isObject(name)) {

node = new XMLText(this, value);
this.onData(this.writer.text(node, this.currentLevel + 1));
this.onData(this.writer.text(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -137,3 +138,3 @@ };

node = new XMLCData(this, value);
this.onData(this.writer.cdata(node, this.currentLevel + 1));
this.onData(this.writer.cdata(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -146,3 +147,3 @@ };

node = new XMLComment(this, value);
this.onData(this.writer.comment(node, this.currentLevel + 1));
this.onData(this.writer.comment(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -155,3 +156,3 @@ };

node = new XMLRaw(this, value);
this.onData(this.writer.raw(node, this.currentLevel + 1));
this.onData(this.writer.raw(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -164,6 +165,6 @@ };

if (target != null) {
target = target.valueOf();
target = getValue(target);
}
if (value != null) {
value = value.valueOf();
value = getValue(value);
}

@@ -186,3 +187,3 @@ if (Array.isArray(target)) {

node = new XMLProcessingInstruction(this, target, value);
this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
this.onData(this.writer.processingInstruction(node, this.currentLevel + 1), this.currentLevel + 1);
}

@@ -196,6 +197,6 @@ return this;

if (this.documentStarted) {
throw new Error("declaration() must be the first node");
throw new Error("declaration() must be the first node.");
}
node = new XMLDeclaration(this, version, encoding, standalone);
this.onData(this.writer.declaration(node, this.currentLevel + 1));
this.onData(this.writer.declaration(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -207,6 +208,6 @@ };

if (root == null) {
throw new Error("Missing root node name");
throw new Error("Missing root node name.");
}
if (this.root) {
throw new Error("dtd() must come before the root node");
throw new Error("dtd() must come before the root node.");
}

@@ -225,3 +226,3 @@ this.currentNode = new XMLDocType(this, pubID, sysID);

node = new XMLDTDElement(this, name, value);
this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
this.onData(this.writer.dtdElement(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -234,3 +235,3 @@ };

node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
this.onData(this.writer.dtdAttList(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -243,3 +244,3 @@ };

node = new XMLDTDEntity(this, false, name, value);
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -252,3 +253,3 @@ };

node = new XMLDTDEntity(this, true, name, value);
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
this.onData(this.writer.dtdEntity(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -261,3 +262,3 @@ };

node = new XMLDTDNotation(this, name, value);
this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
this.onData(this.writer.dtdNotation(node, this.currentLevel + 1), this.currentLevel + 1);
return this;

@@ -268,3 +269,3 @@ };

if (this.currentLevel < 0) {
throw new Error("The document node has no parent");
throw new Error("The document node has no parent.");
}

@@ -305,3 +306,3 @@ if (this.currentNode) {

}
this.onData(this.writer.openNode(node, this.currentLevel));
this.onData(this.writer.openNode(node, this.currentLevel), this.currentLevel);
return node.isOpen = true;

@@ -313,3 +314,3 @@ }

if (!node.isClosed) {
this.onData(this.writer.closeNode(node, this.currentLevel));
this.onData(this.writer.closeNode(node, this.currentLevel), this.currentLevel);
return node.isClosed = true;

@@ -319,5 +320,5 @@ }

XMLDocumentCB.prototype.onData = function(chunk) {
XMLDocumentCB.prototype.onData = function(chunk, level) {
this.documentStarted = true;
return this.onDataCallback(chunk);
return this.onDataCallback(chunk, level + 1);
};

@@ -330,2 +331,10 @@

XMLDocumentCB.prototype.debugInfo = function(name) {
if (name == null) {
return "";
} else {
return "node: <" + name + ">";
}
};
XMLDocumentCB.prototype.ele = function() {

@@ -332,0 +341,0 @@ return this.element.apply(this, arguments);

@@ -15,12 +15,12 @@ // Generated by CoffeeScript 1.12.7

if (elementName == null) {
throw new Error("Missing DTD element name");
throw new Error("Missing DTD element name. " + this.debugInfo());
}
if (attributeName == null) {
throw new Error("Missing DTD attribute name");
throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
}
if (!attributeType) {
throw new Error("Missing DTD attribute type");
throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
}
if (!defaultValueType) {
throw new Error("Missing DTD attribute default");
throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
}

@@ -31,6 +31,6 @@ if (defaultValueType.indexOf('#') !== 0) {

if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
}
if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
throw new Error("Default value only applies to #FIXED or #DEFAULT");
throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
}

@@ -37,0 +37,0 @@ this.elementName = this.stringify.eleName(elementName);

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (name == null) {
throw new Error("Missing DTD element name");
throw new Error("Missing DTD element name. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ if (!value) {

@@ -17,6 +17,6 @@ // Generated by CoffeeScript 1.12.7

if (name == null) {
throw new Error("Missing entity name");
throw new Error("Missing DTD entity name. " + this.debugInfo(name));
}
if (value == null) {
throw new Error("Missing entity value");
throw new Error("Missing DTD entity value. " + this.debugInfo(name));
}

@@ -29,6 +29,6 @@ this.pe = !!pe;

if (!value.pubID && !value.sysID) {
throw new Error("Public and/or system identifiers are required for an external entity");
throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
}
if (value.pubID && !value.sysID) {
throw new Error("System identifier is required for a public external entity");
throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
}

@@ -45,3 +45,3 @@ if (value.pubID != null) {

if (this.pe && this.nData) {
throw new Error("Notation declaration is not allowed in a parameter entity");
throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
}

@@ -48,0 +48,0 @@ }

@@ -15,6 +15,6 @@ // Generated by CoffeeScript 1.12.7

if (name == null) {
throw new Error("Missing notation name");
throw new Error("Missing DTD notation name. " + this.debugInfo(name));
}
if (!value.pubID && !value.sysID) {
throw new Error("Public or system identifiers are required for an external entity");
throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
}

@@ -21,0 +21,0 @@ this.name = this.stringify.eleName(name);

// Generated by CoffeeScript 1.12.7
(function() {
var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
var XMLAttribute, XMLElement, XMLNode, getValue, isFunction, isObject, ref,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;

@@ -19,3 +19,3 @@ XMLNode = require('./XMLNode');

if (name == null) {
throw new Error("Missing element name");
throw new Error("Missing element name. " + this.debugInfo());
}

@@ -60,3 +60,3 @@ this.name = this.stringify.eleName(name);

if (name != null) {
name = name.valueOf();
name = getValue(name);
}

@@ -83,5 +83,5 @@ if (isObject(name)) {

if (name == null) {
throw new Error("Missing attribute name");
throw new Error("Missing attribute name. " + this.debugInfo());
}
name = name.valueOf();
name = getValue(name);
if (Array.isArray(name)) {

@@ -88,0 +88,0 @@ for (i = 0, len = name.length; i < len; i++) {

// Generated by CoffeeScript 1.12.7
(function() {
var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref,
hasProp = {}.hasOwnProperty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty, getValue = ref.getValue;

@@ -50,3 +50,3 @@ XMLElement = null;

}
attributes = attributes.valueOf();
attributes = getValue(attributes);
if (!isObject(attributes)) {

@@ -56,3 +56,3 @@ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];

if (name != null) {
name = name.valueOf();
name = getValue(name);
}

@@ -108,3 +108,3 @@ if (Array.isArray(name)) {

if (lastChild == null) {
throw new Error("Could not create any elements with: " + name);
throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
}

@@ -117,3 +117,3 @@ return lastChild;

if (this.isRoot) {
throw new Error("Cannot insert elements at root level");
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
}

@@ -130,3 +130,3 @@ i = this.parent.children.indexOf(this);

if (this.isRoot) {
throw new Error("Cannot insert elements at root level");
throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
}

@@ -143,3 +143,3 @@ i = this.parent.children.indexOf(this);

if (this.isRoot) {
throw new Error("Cannot remove the root element");
throw new Error("Cannot remove the root element. " + this.debugInfo());
}

@@ -154,6 +154,6 @@ i = this.parent.children.indexOf(this);

if (name != null) {
name = name.valueOf();
name = getValue(name);
}
attributes || (attributes = {});
attributes = attributes.valueOf();
attributes = getValue(attributes);
if (!isObject(attributes)) {

@@ -219,6 +219,6 @@ ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];

if (target != null) {
target = target.valueOf();
target = getValue(target);
}
if (value != null) {
value = value.valueOf();
value = getValue(value);
}

@@ -341,3 +341,3 @@ if (Array.isArray(target)) {

if (i < 1) {
throw new Error("Already at the first node");
throw new Error("Already at the first node. " + this.debugInfo());
}

@@ -351,3 +351,3 @@ return this.parent.children[i - 1];

if (i === -1 || i === this.parent.children.length - 1) {
throw new Error("Already at the last node");
throw new Error("Already at the last node. " + this.debugInfo());
}

@@ -366,2 +366,16 @@ return this.parent.children[i + 1];

XMLNode.prototype.debugInfo = function(name) {
var ref1, ref2;
name = name || this.name;
if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) {
return "";
} else if (name == null) {
return "parent: <" + this.parent.name + ">";
} else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) {
return "node: <" + name + ">";
} else {
return "node: <" + name + ">, parent: <" + this.parent.name + ">";
}
};
XMLNode.prototype.ele = function(name, attributes, text) {

@@ -368,0 +382,0 @@ return this.element(name, attributes, text);

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (target == null) {
throw new Error("Missing instruction target");
throw new Error("Missing instruction target. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ this.target = this.stringify.insTarget(target);

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (text == null) {
throw new Error("Missing raw text");
throw new Error("Missing raw text. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ this.value = this.stringify.raw(text);

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.12.7

if (text == null) {
throw new Error("Missing element text");
throw new Error("Missing element text. " + this.debugInfo());
}

@@ -18,0 +18,0 @@ this.value = this.stringify.eleText(text);

{
"name": "xmlbuilder",
"version": "9.0.7",
"version": "10.0.0",
"keywords": [

@@ -33,3 +33,3 @@ "xml",

"scripts": {
"prepublish": "coffee -co lib src",
"prepublishOnly": "coffee -co lib src",
"postpublish": "rm -rf lib",

@@ -36,0 +36,0 @@ "test": "mocha \"test/**/*.coffee\" && istanbul report text lcov"

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc