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 6.0.0 to 7.0.0

16

CHANGELOG.md

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

## [7.0.0] - 2016-03-21
- Processing instructions are now created as regular nodes. This is a major breaking change if you are using processing instructions. Previously processing instructions were inserted before their parent node. After this change processing instructions are appended to the children of the parent node. Note that it is not currently possible to insert a processing instructions before the root element.
```js
root.ele('node').ins('pi');
// pre-v7
<?pi?><node/>
// v7
<node><?pi?></node>
```
## [6.0.0] - 2016-03-20
- Added custom XML writers. The default string conversion functions are now collected under the `XMLStringWriter` class which can be accessed by the `stringWriter(options)` function exported by the module. An `XMLStreamWriter` is also added which outputs the XML document to a writable stream. A stream writer can be created by calling the `streamWriter(stream, options)` function exported by the module. Both classes are heavily customizable and the details are added to the wiki. It is also possible to write an XML writer from scratch and use it when calling `end()` on the XML document.
## [5.0.1] - 2016-03-08

@@ -273,3 +286,4 @@ - Moved require statements for text case conversion to the top of files to reduce lazy requires.

[7.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v6.0.0...v7.0.0
[6.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.1...v6.0.0
[5.0.1]: https://github.com/oozcitak/xmlbuilder-js/compare/v5.0.0...v5.0.1

@@ -276,0 +290,0 @@ [5.0.0]: https://github.com/oozcitak/xmlbuilder-js/compare/v4.2.1...v5.0.0

50

lib/XMLElement.js
// Generated by CoffeeScript 1.10.0
(function() {
var XMLAttribute, XMLElement, XMLNode, XMLProcessingInstruction, create, isFunction, isObject,
var XMLAttribute, XMLElement, XMLNode, create, isFunction, isObject,
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; },

@@ -17,4 +17,2 @@ hasProp = {}.hasOwnProperty;

XMLProcessingInstruction = require('./XMLProcessingInstruction');
module.exports = XMLElement = (function(superClass) {

@@ -30,3 +28,2 @@ extend(XMLElement, superClass);

this.children = [];
this.instructions = [];
this.attributes = {};

@@ -39,3 +36,3 @@ if (attributes != null) {

XMLElement.prototype.clone = function() {
var att, attName, clonedSelf, i, len, pi, ref, ref1;
var att, attName, clonedSelf, ref;
clonedSelf = create(XMLElement.prototype, this);

@@ -52,8 +49,2 @@ if (clonedSelf.isRoot) {

}
clonedSelf.instructions = [];
ref1 = this.instructions;
for (i = 0, len = ref1.length; i < len; i++) {
pi = ref1[i];
clonedSelf.instructions.push(pi.clone());
}
clonedSelf.children = [];

@@ -108,31 +99,2 @@ this.children.forEach(function(child) {

XMLElement.prototype.instruction = function(target, value) {
var i, insTarget, insValue, instruction, len;
if (target != null) {
target = target.valueOf();
}
if (value != null) {
value = value.valueOf();
}
if (Array.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;
};
XMLElement.prototype.toString = function(options) {

@@ -146,6 +108,2 @@ return this.options.writer.set(options).element(this);

XMLElement.prototype.ins = function(target, value) {
return this.instruction(target, value);
};
XMLElement.prototype.a = function(name, value) {

@@ -155,6 +113,2 @@ return this.attribute(name, value);

XMLElement.prototype.i = function(target, value) {
return this.instruction(target, value);
};
return XMLElement;

@@ -161,0 +115,0 @@

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

@@ -26,2 +26,4 @@

XMLProcessingInstruction = null;
module.exports = XMLNode = (function() {

@@ -40,2 +42,3 @@ function XMLNode(parent) {

XMLText = require('./XMLText');
XMLProcessingInstruction = require('./XMLProcessingInstruction');
}

@@ -76,4 +79,2 @@ }

lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
} 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 (!this.options.separateArrayItems && Array.isArray(val)) {

@@ -102,2 +103,4 @@ for (k = 0, len1 = val.length; k < len1; k++) {

lastChild = this.raw(text);
} else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
} else {

@@ -195,2 +198,31 @@ lastChild = this.node(name, attributes, text);

XMLNode.prototype.instruction = function(target, value) {
var insTarget, insValue, instruction, j, len;
if (target != null) {
target = target.valueOf();
}
if (value != null) {
value = value.valueOf();
}
if (Array.isArray(target)) {
for (j = 0, len = target.length; j < len; j++) {
insTarget = target[j];
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.children.push(instruction);
}
return this;
};
XMLNode.prototype.declaration = function(version, encoding, standalone) {

@@ -292,2 +324,6 @@ var doc, xmldec;

XMLNode.prototype.ins = function(target, value) {
return this.instruction(target, value);
};
XMLNode.prototype.doc = function() {

@@ -329,2 +365,6 @@ return this.document();

XMLNode.prototype.i = function(target, value) {
return this.instruction(target, value);
};
XMLNode.prototype.u = function() {

@@ -331,0 +371,0 @@ return this.up();

// Generated by CoffeeScript 1.10.0
(function() {
var XMLProcessingInstruction, create;
var XMLNode, XMLProcessingInstruction, create,
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;
create = require('lodash/create');
module.exports = XMLProcessingInstruction = (function() {
XMLNode = require('./XMLNode');
module.exports = XMLProcessingInstruction = (function(superClass) {
extend(XMLProcessingInstruction, superClass);
function XMLProcessingInstruction(parent, target, value) {
this.options = parent.options;
this.stringify = parent.stringify;
XMLProcessingInstruction.__super__.constructor.call(this, parent);
if (target == null) {

@@ -30,4 +35,4 @@ throw new Error("Missing instruction target");

})();
})(XMLNode);
}).call(this);

@@ -121,15 +121,10 @@ // Generated by CoffeeScript 1.10.0

XMLStreamWriter.prototype.element = function(node, level) {
var att, child, i, ins, j, len, len1, name, ref, ref1, ref2, space;
var att, child, i, len, name, ref, ref1, space;
level || (level = 0);
space = this.space(level);
ref = node.instructions;
for (i = 0, len = ref.length; i < len; i++) {
ins = ref[i];
this.processingInstruction(ins, level);
}
this.stream.write(space + '<' + node.name);
ref1 = node.attributes;
for (name in ref1) {
if (!hasProp.call(ref1, name)) continue;
att = ref1[name];
ref = node.attributes;
for (name in ref) {
if (!hasProp.call(ref, name)) continue;
att = ref[name];
this.attribute(att);

@@ -151,5 +146,5 @@ }

this.stream.write('>' + this.newline);
ref2 = node.children;
for (j = 0, len1 = ref2.length; j < len1; j++) {
child = ref2[j];
ref1 = node.children;
for (i = 0, len = ref1.length; i < len; i++) {
child = ref1[i];
switch (false) {

@@ -171,2 +166,5 @@ case !(child instanceof XMLCData):

break;
case !(child instanceof XMLProcessingInstruction):
this.processingInstruction(child, level + 1);
break;
default:

@@ -173,0 +171,0 @@ throw new Error("Unknown XML node type: " + child.constructor.name);

@@ -124,16 +124,11 @@ // Generated by CoffeeScript 1.10.0

XMLStringWriter.prototype.element = function(node, level) {
var att, child, i, ins, j, len, len1, name, r, ref, ref1, ref2, space;
var att, child, i, len, name, r, ref, ref1, space;
level || (level = 0);
space = this.space(level);
r = '';
ref = node.instructions;
for (i = 0, len = ref.length; i < len; i++) {
ins = ref[i];
r += this.processingInstruction(ins, level);
}
r += space + '<' + node.name;
ref1 = node.attributes;
for (name in ref1) {
if (!hasProp.call(ref1, name)) continue;
att = ref1[name];
ref = node.attributes;
for (name in ref) {
if (!hasProp.call(ref, name)) continue;
att = ref[name];
r += this.attribute(att);

@@ -155,5 +150,5 @@ }

r += '>' + this.newline;
ref2 = node.children;
for (j = 0, len1 = ref2.length; j < len1; j++) {
child = ref2[j];
ref1 = node.children;
for (i = 0, len = ref1.length; i < len; i++) {
child = ref1[i];
r += (function() {

@@ -171,2 +166,4 @@ switch (false) {

return this.text(child, level + 1);
case !(child instanceof XMLProcessingInstruction):
return this.processingInstruction(child, level + 1);
default:

@@ -173,0 +170,0 @@ throw new Error("Unknown XML node type: " + child.constructor.name);

{
"name": "xmlbuilder",
"version": "6.0.0",
"version": "7.0.0",
"keywords": [

@@ -5,0 +5,0 @@ "xml",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc