first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

1
build/node_modules/jsontoxml/.npmignore generated vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

5
build/node_modules/jsontoxml/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.4
- 0.6
- 0.8

21
build/node_modules/jsontoxml/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2010 Ryan Day
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

97
build/node_modules/jsontoxml/README.md generated vendored Normal file
View File

@@ -0,0 +1,97 @@
[![Build Status](https://secure.travis-ci.org/soldair/node-jsontoxml.png)](http://travis-ci.org/soldair/node-jsontoxml)
[![browser support](http://ci.testling.com/soldair/node-jsontoxml.png)](http://ci.testling.com/soldair/node-jsontoxml)
# jsontoxml
This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures.
For that and perhaps as a compliment to this you can use jsdom or xml2js for editing existing markup.
this will do a good job rendering json as xml but apis that require xml expect odd things mostly related to elements with attributes and implicit array like keys that make formatting your json a little tricky.
## example
```js
var jsonxml = require('jsontoxml');
var xml = jsonxml({
node:'text content',
parent:[
{name:'taco',text:'beef taco',children:{salsa:'hot!'}},
{name:'taco',text:'fish taco',attrs:{mood:'sad'},children:[
{name:'salsa',text:'mild'},
'hi',
{name:'salsa',text:'weak',attrs:{type:2}}
]},
{name:'taco',attrs:'mood="party!"'}
],
parent2:{
hi:'is a nice thing to say',
node:'i am another not special child node'
date:function(){
return (new Date())+'';
}
}
})
console.log(xml);
```
outputs:
```xml
<node>text content</node>
<parent>
<taco>
beef taco
<salsa>hot!</salsa>
</taco>
<taco mood='sad'>
fish taco
<salsa>mild</salsa>
hi
<salsa type="2">weak</salsa>
</taco>
<taco mood='party!'/>
</parent>
<parent2>
<hi>is a nice thing to say</hi>
<node>i am another not special child node</node>
<date>Sun Sep 26 2010 17:27:29 GMT-0700 (PDT)</date>
</parent2>
```
## API
`jsontoxml (obj,options)`
* a valid json structure to interpret or a json string
* returns an xml string
* `options` is optional. it can be true (add generic xml header) or an object. If an object, valid options are:
- `escape`
* calls escape on all values
* attribute values if attribute values are specified as an object
- `xmlHeader` can either be boolan (add generic `<?xml …?>` header) or an object. If an object valid options are:
- `standalone` if true, the `<?xml …?>` gets an additional attribute `standalone="true"`.
- `docType` if defined gets added as the `<!DOCTYPE …>` contents (unescaped).
- `prettyPrint` if truthy the output gets a rudimentary pretty print (good for debugging, don't expect too much)
- `indent` specify what unit you would like to indent by (spaces, tabstop, nothing - pass an empty string)
- `removeIllegalNameCharacters` replace illegal XML element Name characters with '_'
`jsontoxml.escape (string)`
* returns string with xml entities escaped
* escapes `"" & < >`
`jsontoxml.cdata (string)`
* wraps string with `<![CDATA[ ]]>`
* removes all occurences of close cdata (`]]>`) in input text
## more description
I made this because i wanted to abstract away the fact that antiquated external systems require post data as xml and i wanted to expose a standard js calling api like my other interfaces.
I did not want to instantiate an entire dom to perform simple updates to tags in lower level functions (like injecting api keys) when top level api call specific functions start building the xml string.

3
build/node_modules/jsontoxml/a.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
var j = require('./jsontoxml');
console.log(j([{attrs:{a:"b"},name:"b"}]))

8605
build/node_modules/jsontoxml/bundle.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

190
build/node_modules/jsontoxml/jsontoxml.js generated vendored Normal file
View File

@@ -0,0 +1,190 @@
//copyright Ryan Day 2010 <http://ryanday.org>, Joscha Feth 2013 <http://www.feth.com> [MIT Licensed]
var element_start_char =
"a-zA-Z_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FFF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
var element_non_start_char = "\-.0-9\u00B7\u0300-\u036F\u203F\u2040";
var element_replace = new RegExp("^([^" + element_start_char + "])|^((x|X)(m|M)(l|L))|([^" + element_start_char + element_non_start_char + "])", "g");
var process_to_xml = function(node_data,options){
var makeNode = function(name, content, attributes, level, hasSubNodes) {
var indent_value = options.indent !== undefined ? options.indent : "\t";
var indent = options.prettyPrint ? '\n' + new Array(level).join(indent_value) : '';
if(options.removeIllegalNameCharacters) {
name = name.replace(element_replace, '_');
}
var node = [indent, '<',name, (attributes || '')];
if(content && content.length > 0) {
node.push('>')
node.push(content);
hasSubNodes && node.push(indent);
node.push('</');
node.push(name);
node.push('>');
} else {
node.push('/>');
}
return node.join('');
};
return (function fn(node_data,node_descriptor, level){
var type = typeof node_data;
if((Array.isArray) ? Array.isArray(node_data) : node_data instanceof Array) {
type = 'array';
} else if(node_data instanceof Date) {
type = 'date';
}
switch(type) {
//if value is an array create child nodes from values
case 'array':
var ret = [];
node_data.map(function(v){
ret.push(fn(v,1, level+1));
//entries that are values of an array are the only ones that can be special node descriptors
});
options.prettyPrint && ret.push('\n');
return ret.join('');
break;
case 'date':
// cast dates to ISO 8601 date (soap likes it)
return node_data.toJSON?node_data.toJSON():node_data+'';
break;
case 'object':
if(node_descriptor == 1 && node_data.name){
var content = []
, attributes = []
;
if(node_data.attrs) {
if(typeof node_data.attrs != 'object') {
// attrs is a string, etc. - just use it as an attribute
attributes.push(' ');
attributes.push(node_data.attrs);
} else {
for(var key in node_data.attrs){
var value = node_data.attrs[key];
attributes.push(' ');
attributes.push(key);
attributes.push('="')
attributes.push(options.escape ? esc(value) : value);
attributes.push('"');
}
}
}
//later attributes can be added here
if(typeof node_data.value != 'undefined') {
var c = ''+node_data.value;
content.push(options.escape ? esc(c) : c);
} else if(typeof node_data.text != 'undefined') {
var c = ''+node_data.text;
content.push(options.escape ? esc(c) : c);
}
if(node_data.children){
content.push(fn(node_data.children,0,level+1));
}
return makeNode(node_data.name, content.join(''), attributes.join(''),level,!!node_data.children);
} else {
var nodes = [];
for(var name in node_data){
nodes.push(makeNode(name, fn(node_data[name],0,level+1),null,level+1));
}
options.prettyPrint && nodes.length > 0 && nodes.push('\n');
return nodes.join('');
}
break;
case 'function':
return node_data();
break;
default:
return options.escape ? esc(node_data) : ''+node_data;
}
}(node_data, 0, 0))
};
var xml_header = function(standalone) {
var ret = ['<?xml version="1.0" encoding="utf-8"'];
if(standalone) {
ret.push(' standalone="yes"');
}
ret.push('?>');
return ret.join('');
};
module.exports = function(obj,options){
var Buffer = this.Buffer || function Buffer () {};
if(typeof obj == 'string' || obj instanceof Buffer) {
try{
obj = JSON.parse(obj.toString());
} catch(e){
return false;
}
}
var xmlheader = '';
var docType = '';
if(options) {
if(typeof options == 'object') {
// our config is an object
if(options.xmlHeader) {
// the user wants an xml header
xmlheader = xml_header(!!options.xmlHeader.standalone);
}
if(typeof options.docType != 'undefined') {
docType = '<!DOCTYPE '+options.docType+'>'
}
} else {
// our config is a boolean value, so just add xml header
xmlheader = xml_header();
}
}
options = options || {}
var ret = [
xmlheader,
(options.prettyPrint && docType ? '\n' : ''),
docType,
process_to_xml(obj,options)
];
return ret.join('');
}
module.exports.json_to_xml=
module.exports.obj_to_xml = module.exports;
module.exports.escape = esc;
function esc(str){
return (''+str).replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&apos;')
.replace(/"/g, '&quot;');
}
module.exports.cdata = cdata;
function cdata(str){
if(str) return "<![CDATA["+str.replace(/]]>/g,'')+']]>';
return "<![CDATA[]]>";
};

77
build/node_modules/jsontoxml/package.json generated vendored Normal file
View File

@@ -0,0 +1,77 @@
{
"_from": "jsontoxml@0.0.11",
"_id": "jsontoxml@0.0.11",
"_inBundle": false,
"_integrity": "sha1-Nzq1sgcL43N6X7PjL9G3uBhwyqQ=",
"_location": "/jsontoxml",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "jsontoxml@0.0.11",
"name": "jsontoxml",
"escapedName": "jsontoxml",
"rawSpec": "0.0.11",
"saveSpec": null,
"fetchSpec": "0.0.11"
},
"_requiredBy": [
"/favicons"
],
"_resolved": "https://registry.npmjs.org/jsontoxml/-/jsontoxml-0.0.11.tgz",
"_shasum": "373ab5b2070be3737a5fb3e32fd1b7b81870caa4",
"_spec": "jsontoxml@0.0.11",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/favicons",
"bugs": {
"url": "https://github.com/soldair/node-jsontoxml/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures.",
"devDependencies": {
"tape": "~0.2.2"
},
"engines": {
"node": ">=0.2.0"
},
"homepage": "http://github.com/ken-franken/node-jsontoxml",
"license": "MIT",
"main": "./jsontoxml.js",
"name": "jsontoxml",
"people": {
"author": {
"name": "Ryan Day",
"email": "soldair@gmail.com",
"url": "http://ryanday.org"
}
},
"repository": {
"type": "git",
"url": "git://github.com/soldair/node-jsontoxml.git"
},
"scripts": {
"test": "node ./test.js"
},
"testling": {
"files": "./test.js",
"browsers": {
"ie": [
8,
9
],
"firefox": [
13
],
"chrome": [
20
],
"safari": [
5.1
],
"opera": [
12
]
}
},
"version": "0.0.11"
}

94
build/node_modules/jsontoxml/test.js generated vendored Normal file
View File

@@ -0,0 +1,94 @@
//copyright Ryan Day 2010 <http://ryanday.org> [MIT Licensed]
var test = require('tape')
, jsonxml = require("./jsontoxml.js")
;
var date = (new Date());
var input = {
node:'text content',
parent:[
{name:'taco',text:'beef taco',children:{salsa:'hot!'}},
{name:'xml',text:'tag'},
{name:'taco',text:'fish taco',attrs:{mood:'sad'},children:[
{name:'salsa',text:'mild'},
'hi',
{name:'salsa',text:'weak',attrs:{type:2}}
]},
{name:'taco',attrs:{mood:"party!"}}
],
parent2:{
hi:'this & this is a nice thing to say',
node:'i am another not special child node',
date:date+'',
date2:date
}
};
var expected_no_element_substitution =
'<node>text content</node>'
+'<parent>'
+'<taco>'
+'beef taco'
+'<salsa>hot!</salsa>'
+'</taco>'
+'<xml>tag</xml>'
+'<taco mood="sad">'
+'fish taco'
+'<salsa>mild</salsa>'
+'hi'
+'<salsa type="2">weak</salsa>'
+'</taco>'
+"<taco mood=\"party!\"/>"
+'</parent>'
+'<parent2>'
+'<hi>this &amp; this is a nice thing to say</hi>'
+'<node>i am another not special child node</node>'
+'<date>'+date+'</date>'
+'<date2>'+date.toJSON()+'</date2>'
+'</parent2>';
var expected_with_element_substitution =
'<node>text content</node>'
+'<parent>'
+'<taco>'
+'beef taco'
+'<salsa>hot!</salsa>'
+'</taco>'
+'<_>tag</_>'
+'<taco mood="sad">'
+'fish taco'
+'<salsa>mild</salsa>'
+'hi'
+'<salsa type="2">weak</salsa>'
+'</taco>'
+"<taco mood=\"party!\"/>"
+'</parent>'
+'<parent2>'
+'<hi>this &amp; this is a nice thing to say</hi>'
+'<node>i am another not special child node</node>'
+'<date>'+date+'</date>'
+'<date2>'+date.toJSON()+'</date2>'
+'</parent2>';
var expected = expected_no_element_substitution;
var buffer = new Buffer(JSON.stringify(input));
test("creates correct object from buffer",function(t){
var result = jsonxml(buffer,{escape:true});
t.equals(result,expected,' should have generated correct xml');
t.end()
});
test("creates correct object from string",function(t){
var result = jsonxml(input,{escape:true});
t.equals(result,expected,' test should have generated correct xml');
t.end()
});
test("creates correct object with element fixup",function(t){
var result = jsonxml(input,{escape:true, removeIllegalNameCharacters:true});
t.equals(result,expected_with_element_substitution,' test should have generated correct xml');
t.end()
});