123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832 |
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
- (function (Buffer){
- /**
- * Module dependencies.
- */
-
- var base64 = require('base64-js');
- var xmlbuilder = require('xmlbuilder');
-
- /**
- * Module exports.
- */
-
- exports.build = build;
-
- /**
- * Accepts a `Date` instance and returns an ISO date string.
- *
- * @param {Date} d - Date instance to serialize
- * @returns {String} ISO date string representation of `d`
- * @api private
- */
-
- function ISODateString(d){
- function pad(n){
- return n < 10 ? '0' + n : n;
- }
- return d.getUTCFullYear()+'-'
- + pad(d.getUTCMonth()+1)+'-'
- + pad(d.getUTCDate())+'T'
- + pad(d.getUTCHours())+':'
- + pad(d.getUTCMinutes())+':'
- + pad(d.getUTCSeconds())+'Z';
- }
-
- /**
- * Returns the internal "type" of `obj` via the
- * `Object.prototype.toString()` trick.
- *
- * @param {Mixed} obj - any value
- * @returns {String} the internal "type" name
- * @api private
- */
-
- var toString = Object.prototype.toString;
- function type (obj) {
- var m = toString.call(obj).match(/\[object (.*)\]/);
- return m ? m[1] : m;
- }
-
- /**
- * Generate an XML plist string from the input object `obj`.
- *
- * @param {Object} obj - the object to convert
- * @param {Object} [opts] - optional options object
- * @returns {String} converted plist XML string
- * @api public
- */
-
- function build (obj, opts) {
- var XMLHDR = {
- version: '1.0',
- encoding: 'UTF-8'
- };
-
- var XMLDTD = {
- pubid: '-//Apple//DTD PLIST 1.0//EN',
- sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
- };
-
- var doc = xmlbuilder.create('plist');
-
- doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
- doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
- doc.att('version', '1.0');
-
- walk_obj(obj, doc);
-
- if (!opts) opts = {};
- // default `pretty` to `true`
- opts.pretty = opts.pretty !== false;
- return doc.end(opts);
- }
-
- /**
- * depth first, recursive traversal of a javascript object. when complete,
- * next_child contains a reference to the build XML object.
- *
- * @api private
- */
-
- function walk_obj(next, next_child) {
- var tag_type, i, prop;
- var name = type(next);
-
- if ('Undefined' == name) {
- return;
- } else if (Array.isArray(next)) {
- next_child = next_child.ele('array');
- for (i = 0; i < next.length; i++) {
- walk_obj(next[i], next_child);
- }
-
- } else if (Buffer.isBuffer(next)) {
- next_child.ele('data').raw(next.toString('base64'));
-
- } else if ('Object' == name) {
- next_child = next_child.ele('dict');
- for (prop in next) {
- if (next.hasOwnProperty(prop)) {
- next_child.ele('key').txt(prop);
- walk_obj(next[prop], next_child);
- }
- }
-
- } else if ('Number' == name) {
- // detect if this is an integer or real
- // TODO: add an ability to force one way or another via a "cast"
- tag_type = (next % 1 === 0) ? 'integer' : 'real';
- next_child.ele(tag_type).txt(next.toString());
-
- } else if ('Date' == name) {
- next_child.ele('date').txt(ISODateString(new Date(next)));
-
- } else if ('Boolean' == name) {
- next_child.ele(next ? 'true' : 'false');
-
- } else if ('String' == name) {
- next_child.ele('string').txt(next);
-
- } else if ('ArrayBuffer' == name) {
- next_child.ele('data').raw(base64.fromByteArray(next));
-
- } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
- // a typed array
- next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
-
- }
- }
-
- }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
- },{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":25}],2:[function(require,module,exports){
- 'use strict'
-
- exports.byteLength = byteLength
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
-
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
-
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
-
- // Support decoding URL-safe base64 strings, as Node.js does.
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
-
- function placeHoldersCount (b64) {
- var len = b64.length
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
-
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
- }
-
- function byteLength (b64) {
- // base64 is 4/3 + up to two characters of the original data
- return (b64.length * 3 / 4) - placeHoldersCount(b64)
- }
-
- function toByteArray (b64) {
- var i, l, tmp, placeHolders, arr
- var len = b64.length
- placeHolders = placeHoldersCount(b64)
-
- arr = new Arr((len * 3 / 4) - placeHolders)
-
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? len - 4 : len
-
- var L = 0
-
- for (i = 0; i < l; i += 4) {
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
- arr[L++] = (tmp >> 16) & 0xFF
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- if (placeHolders === 2) {
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[L++] = tmp & 0xFF
- } else if (placeHolders === 1) {
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- return arr
- }
-
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
- }
-
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
-
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var output = ''
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
-
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
-
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- output += lookup[tmp >> 2]
- output += lookup[(tmp << 4) & 0x3F]
- output += '=='
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
- output += lookup[tmp >> 10]
- output += lookup[(tmp >> 4) & 0x3F]
- output += lookup[(tmp << 2) & 0x3F]
- output += '='
- }
-
- parts.push(output)
-
- return parts.join('')
- }
-
- },{}],3:[function(require,module,exports){
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */
-
- // The _isBuffer check is for Safari 5-7 support, because it's missing
- // Object.prototype.constructor. Remove this eventually
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
-
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
-
- // For Node v0.10 support. Remove this eventually.
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
-
- },{}],4:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
- slice = [].slice,
- hasProp = {}.hasOwnProperty;
-
- assign = function() {
- var i, key, len, source, sources, target;
- target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- if (isFunction(Object.assign)) {
- Object.assign.apply(null, arguments);
- } else {
- for (i = 0, len = sources.length; i < len; i++) {
- source = sources[i];
- if (source != null) {
- for (key in source) {
- if (!hasProp.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- }
- }
- return target;
- };
-
- isFunction = function(val) {
- return !!val && Object.prototype.toString.call(val) === '[object Function]';
- };
-
- isObject = function(val) {
- var ref;
- return !!val && ((ref = typeof val) === 'function' || ref === 'object');
- };
-
- isArray = function(val) {
- if (isFunction(Array.isArray)) {
- return Array.isArray(val);
- } else {
- return Object.prototype.toString.call(val) === '[object Array]';
- }
- };
-
- isEmpty = function(val) {
- var key;
- if (isArray(val)) {
- return !val.length;
- } else {
- for (key in val) {
- if (!hasProp.call(val, key)) continue;
- return false;
- }
- return true;
- }
- };
-
- isPlainObject = function(val) {
- var ctor, proto;
- return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
- };
-
- module.exports.assign = assign;
-
- module.exports.isFunction = isFunction;
-
- module.exports.isObject = isObject;
-
- module.exports.isArray = isArray;
-
- module.exports.isEmpty = isEmpty;
-
- module.exports.isPlainObject = isPlainObject;
-
- }).call(this);
-
- },{}],5:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLAttribute;
-
- module.exports = XMLAttribute = (function() {
- function XMLAttribute(parent, name, value) {
- this.options = parent.options;
- this.stringify = parent.stringify;
- if (name == null) {
- throw new Error("Missing attribute name of element " + parent.name);
- }
- if (value == null) {
- throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
- }
- this.name = this.stringify.attName(name);
- this.value = this.stringify.attValue(value);
- }
-
- XMLAttribute.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLAttribute.prototype.toString = function(options) {
- return this.options.writer.set(options).attribute(this);
- };
-
- return XMLAttribute;
-
- })();
-
- }).call(this);
-
- },{}],6:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLNode,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLCData = (function(superClass) {
- extend(XMLCData, superClass);
-
- function XMLCData(parent, text) {
- XMLCData.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing CDATA text");
- }
- this.text = this.stringify.cdata(text);
- }
-
- XMLCData.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLCData.prototype.toString = function(options) {
- return this.options.writer.set(options).cdata(this);
- };
-
- return XMLCData;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],7:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLComment, XMLNode,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLComment = (function(superClass) {
- extend(XMLComment, superClass);
-
- function XMLComment(parent, text) {
- XMLComment.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing comment text");
- }
- this.text = this.stringify.comment(text);
- }
-
- XMLComment.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLComment.prototype.toString = function(options) {
- return this.options.writer.set(options).comment(this);
- };
-
- return XMLComment;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],8:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDAttList, XMLNode,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDAttList = (function(superClass) {
- extend(XMLDTDAttList, superClass);
-
- function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- XMLDTDAttList.__super__.constructor.call(this, parent);
- if (elementName == null) {
- throw new Error("Missing DTD element name");
- }
- if (attributeName == null) {
- throw new Error("Missing DTD attribute name");
- }
- if (!attributeType) {
- throw new Error("Missing DTD attribute type");
- }
- if (!defaultValueType) {
- throw new Error("Missing DTD attribute default");
- }
- if (defaultValueType.indexOf('#') !== 0) {
- defaultValueType = '#' + defaultValueType;
- }
- if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
- throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
- }
- if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
- throw new Error("Default value only applies to #FIXED or #DEFAULT");
- }
- this.elementName = this.stringify.eleName(elementName);
- this.attributeName = this.stringify.attName(attributeName);
- this.attributeType = this.stringify.dtdAttType(attributeType);
- this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
- this.defaultValueType = defaultValueType;
- }
-
- XMLDTDAttList.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdAttList(this);
- };
-
- return XMLDTDAttList;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],9:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDElement, XMLNode,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDElement = (function(superClass) {
- extend(XMLDTDElement, superClass);
-
- function XMLDTDElement(parent, name, value) {
- XMLDTDElement.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing DTD element name");
- }
- if (!value) {
- value = '(#PCDATA)';
- }
- if (Array.isArray(value)) {
- value = '(' + value.join(',') + ')';
- }
- this.name = this.stringify.eleName(name);
- this.value = this.stringify.dtdElementValue(value);
- }
-
- XMLDTDElement.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdElement(this);
- };
-
- return XMLDTDElement;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],10:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDEntity, XMLNode, 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDEntity = (function(superClass) {
- extend(XMLDTDEntity, superClass);
-
- function XMLDTDEntity(parent, pe, name, value) {
- XMLDTDEntity.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing entity name");
- }
- if (value == null) {
- throw new Error("Missing entity value");
- }
- this.pe = !!pe;
- this.name = this.stringify.eleName(name);
- if (!isObject(value)) {
- this.value = this.stringify.dtdEntityValue(value);
- } else {
- if (!value.pubID && !value.sysID) {
- throw new Error("Public and/or system identifiers are required for an external entity");
- }
- if (value.pubID && !value.sysID) {
- throw new Error("System identifier is required for a public external entity");
- }
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- if (value.nData != null) {
- this.nData = this.stringify.dtdNData(value.nData);
- }
- if (this.pe && this.nData) {
- throw new Error("Notation declaration is not allowed in a parameter entity");
- }
- }
- }
-
- XMLDTDEntity.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdEntity(this);
- };
-
- return XMLDTDEntity;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":4,"./XMLNode":17}],11:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDNotation, XMLNode,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDNotation = (function(superClass) {
- extend(XMLDTDNotation, superClass);
-
- function XMLDTDNotation(parent, name, value) {
- XMLDTDNotation.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing notation name");
- }
- if (!value.pubID && !value.sysID) {
- throw new Error("Public or system identifiers are required for an external entity");
- }
- this.name = this.stringify.eleName(name);
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- }
-
- XMLDTDNotation.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdNotation(this);
- };
-
- return XMLDTDNotation;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],12:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDeclaration, XMLNode, 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDeclaration = (function(superClass) {
- extend(XMLDeclaration, superClass);
-
- function XMLDeclaration(parent, version, encoding, standalone) {
- var ref;
- XMLDeclaration.__super__.constructor.call(this, parent);
- if (isObject(version)) {
- ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
- }
- if (!version) {
- version = '1.0';
- }
- this.version = this.stringify.xmlVersion(version);
- if (encoding != null) {
- this.encoding = this.stringify.xmlEncoding(encoding);
- }
- if (standalone != null) {
- this.standalone = this.stringify.xmlStandalone(standalone);
- }
- }
-
- XMLDeclaration.prototype.toString = function(options) {
- return this.options.writer.set(options).declaration(this);
- };
-
- return XMLDeclaration;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":4,"./XMLNode":17}],13:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- module.exports = XMLDocType = (function(superClass) {
- extend(XMLDocType, superClass);
-
- function XMLDocType(parent, pubID, sysID) {
- var ref, ref1;
- XMLDocType.__super__.constructor.call(this, parent);
- this.documentObject = parent;
- if (isObject(pubID)) {
- ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
- }
- if (sysID == null) {
- ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
- }
- if (pubID != null) {
- this.pubID = this.stringify.dtdPubID(pubID);
- }
- if (sysID != null) {
- this.sysID = this.stringify.dtdSysID(sysID);
- }
- }
-
- XMLDocType.prototype.element = function(name, value) {
- var child;
- child = new XMLDTDElement(this, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var child;
- child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.entity = function(name, value) {
- var child;
- child = new XMLDTDEntity(this, false, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.pEntity = function(name, value) {
- var child;
- child = new XMLDTDEntity(this, true, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.notation = function(name, value) {
- var child;
- child = new XMLDTDNotation(this, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.toString = function(options) {
- return this.options.writer.set(options).docType(this);
- };
-
- XMLDocType.prototype.ele = function(name, value) {
- return this.element(name, value);
- };
-
- XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
- };
-
- XMLDocType.prototype.ent = function(name, value) {
- return this.entity(name, value);
- };
-
- XMLDocType.prototype.pent = function(name, value) {
- return this.pEntity(name, value);
- };
-
- XMLDocType.prototype.not = function(name, value) {
- return this.notation(name, value);
- };
-
- XMLDocType.prototype.up = function() {
- return this.root() || this.documentObject;
- };
-
- return XMLDocType;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":4,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLNode":17}],14:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
- 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;
-
- isPlainObject = require('./Utility').isPlainObject;
-
- XMLNode = require('./XMLNode');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- module.exports = XMLDocument = (function(superClass) {
- extend(XMLDocument, superClass);
-
- function XMLDocument(options) {
- XMLDocument.__super__.constructor.call(this, null);
- options || (options = {});
- if (!options.writer) {
- options.writer = new XMLStringWriter();
- }
- this.options = options;
- this.stringify = new XMLStringifier(options);
- this.isDocument = true;
- }
-
- XMLDocument.prototype.end = function(writer) {
- var writerOptions;
- if (!writer) {
- writer = this.options.writer;
- } else if (isPlainObject(writer)) {
- writerOptions = writer;
- writer = this.options.writer.set(writerOptions);
- }
- return writer.document(this);
- };
-
- XMLDocument.prototype.toString = function(options) {
- return this.options.writer.set(options).document(this);
- };
-
- return XMLDocument;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":4,"./XMLNode":17,"./XMLStringWriter":21,"./XMLStringifier":22}],15:[function(require,module,exports){
- // 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,
- hasProp = {}.hasOwnProperty;
-
- ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
-
- XMLElement = require('./XMLElement');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLAttribute = require('./XMLAttribute');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- module.exports = XMLDocumentCB = (function() {
- function XMLDocumentCB(options, onData, onEnd) {
- var writerOptions;
- options || (options = {});
- if (!options.writer) {
- options.writer = new XMLStringWriter(options);
- } else if (isPlainObject(options.writer)) {
- writerOptions = options.writer;
- options.writer = new XMLStringWriter(writerOptions);
- }
- this.options = options;
- this.writer = options.writer;
- this.stringify = new XMLStringifier(options);
- this.onDataCallback = onData || function() {};
- this.onEndCallback = onEnd || function() {};
- this.currentNode = null;
- this.currentLevel = -1;
- this.openTags = {};
- this.documentStarted = false;
- this.documentCompleted = false;
- this.root = null;
- }
-
- XMLDocumentCB.prototype.node = function(name, attributes, text) {
- var ref1;
- if (name == null) {
- throw new Error("Missing node name");
- }
- if (this.root && this.currentLevel === -1) {
- throw new Error("Document can only have one root node");
- }
- this.openCurrent();
- name = name.valueOf();
- if (attributes == null) {
- attributes = {};
- }
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- this.currentNode = new XMLElement(this, name, attributes);
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- if (text != null) {
- this.text(text);
- }
- return this;
- };
-
- XMLDocumentCB.prototype.element = function(name, attributes, text) {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.dtdElement.apply(this, arguments);
- } else {
- return this.node(name, attributes, text);
- }
- };
-
- XMLDocumentCB.prototype.attribute = function(name, value) {
- var attName, attValue;
- if (!this.currentNode || this.currentNode.children) {
- throw new Error("att() can only be used immediately after an ele() call in callback mode");
- }
- if (name != null) {
- name = name.valueOf();
- }
- 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.currentNode.attributes[name] = new XMLAttribute(this, name, value);
- }
- }
- return this;
- };
-
- XMLDocumentCB.prototype.text = function(value) {
- var node;
- this.openCurrent();
- node = new XMLText(this, value);
- this.onData(this.writer.text(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.cdata = function(value) {
- var node;
- this.openCurrent();
- node = new XMLCData(this, value);
- this.onData(this.writer.cdata(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.comment = function(value) {
- var node;
- this.openCurrent();
- node = new XMLComment(this, value);
- this.onData(this.writer.comment(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.raw = function(value) {
- var node;
- this.openCurrent();
- node = new XMLRaw(this, value);
- this.onData(this.writer.raw(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.instruction = function(target, value) {
- var i, insTarget, insValue, len, node;
- this.openCurrent();
- 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();
- }
- node = new XMLProcessingInstruction(this, target, value);
- this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
- }
- return this;
- };
-
- XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
- var node;
- this.openCurrent();
- if (this.documentStarted) {
- 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));
- return this;
- };
-
- XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
- this.openCurrent();
- if (root == null) {
- throw new Error("Missing root node name");
- }
- if (this.root) {
- throw new Error("dtd() must come before the root node");
- }
- this.currentNode = new XMLDocType(this, pubID, sysID);
- this.currentNode.rootNodeName = root;
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- return this;
- };
-
- XMLDocumentCB.prototype.dtdElement = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDElement(this, name, value);
- this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var node;
- this.openCurrent();
- node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.entity = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, false, name, value);
- this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.pEntity = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, true, name, value);
- this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.notation = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDNotation(this, name, value);
- this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.up = function() {
- if (this.currentLevel < 0) {
- throw new Error("The document node has no parent");
- }
- if (this.currentNode) {
- if (this.currentNode.children) {
- this.closeNode(this.currentNode);
- } else {
- this.openNode(this.currentNode);
- }
- this.currentNode = null;
- } else {
- this.closeNode(this.openTags[this.currentLevel]);
- }
- delete this.openTags[this.currentLevel];
- this.currentLevel--;
- return this;
- };
-
- XMLDocumentCB.prototype.end = function() {
- while (this.currentLevel >= 0) {
- this.up();
- }
- return this.onEnd();
- };
-
- XMLDocumentCB.prototype.openCurrent = function() {
- if (this.currentNode) {
- this.currentNode.children = true;
- return this.openNode(this.currentNode);
- }
- };
-
- XMLDocumentCB.prototype.openNode = function(node) {
- if (!node.isOpen) {
- if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
- this.root = node;
- }
- this.onData(this.writer.openNode(node, this.currentLevel));
- return node.isOpen = true;
- }
- };
-
- XMLDocumentCB.prototype.closeNode = function(node) {
- if (!node.isClosed) {
- this.onData(this.writer.closeNode(node, this.currentLevel));
- return node.isClosed = true;
- }
- };
-
- XMLDocumentCB.prototype.onData = function(chunk) {
- this.documentStarted = true;
- return this.onDataCallback(chunk);
- };
-
- XMLDocumentCB.prototype.onEnd = function() {
- this.documentCompleted = true;
- return this.onEndCallback();
- };
-
- XMLDocumentCB.prototype.ele = function() {
- return this.element.apply(this, arguments);
- };
-
- XMLDocumentCB.prototype.nod = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.txt = function(value) {
- return this.text(value);
- };
-
- XMLDocumentCB.prototype.dat = function(value) {
- return this.cdata(value);
- };
-
- XMLDocumentCB.prototype.com = function(value) {
- return this.comment(value);
- };
-
- XMLDocumentCB.prototype.ins = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- };
-
- XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
- return this.doctype(root, pubID, sysID);
- };
-
- XMLDocumentCB.prototype.e = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.n = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.t = function(value) {
- return this.text(value);
- };
-
- XMLDocumentCB.prototype.d = function(value) {
- return this.cdata(value);
- };
-
- XMLDocumentCB.prototype.c = function(value) {
- return this.comment(value);
- };
-
- XMLDocumentCB.prototype.r = function(value) {
- return this.raw(value);
- };
-
- XMLDocumentCB.prototype.i = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLDocumentCB.prototype.att = function() {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.attList.apply(this, arguments);
- } else {
- return this.attribute.apply(this, arguments);
- }
- };
-
- XMLDocumentCB.prototype.a = function() {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.attList.apply(this, arguments);
- } else {
- return this.attribute.apply(this, arguments);
- }
- };
-
- XMLDocumentCB.prototype.ent = function(name, value) {
- return this.entity(name, value);
- };
-
- XMLDocumentCB.prototype.pent = function(name, value) {
- return this.pEntity(name, value);
- };
-
- XMLDocumentCB.prototype.not = function(name, value) {
- return this.notation(name, value);
- };
-
- return XMLDocumentCB;
-
- })();
-
- }).call(this);
-
- },{"./Utility":4,"./XMLAttribute":5,"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLStringWriter":21,"./XMLStringifier":22,"./XMLText":23}],16:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLAttribute, XMLElement, XMLNode, 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;
-
- XMLNode = require('./XMLNode');
-
- XMLAttribute = require('./XMLAttribute');
-
- module.exports = XMLElement = (function(superClass) {
- extend(XMLElement, superClass);
-
- function XMLElement(parent, name, attributes) {
- XMLElement.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing element name");
- }
- this.name = this.stringify.eleName(name);
- this.attributes = {};
- if (attributes != null) {
- this.attribute(attributes);
- }
- if (parent.isDocument) {
- this.isRoot = true;
- this.documentObject = parent;
- parent.rootObject = this;
- }
- }
-
- XMLElement.prototype.clone = function() {
- var att, attName, clonedSelf, ref1;
- clonedSelf = Object.create(this);
- if (clonedSelf.isRoot) {
- clonedSelf.documentObject = null;
- }
- clonedSelf.attributes = {};
- ref1 = this.attributes;
- for (attName in ref1) {
- if (!hasProp.call(ref1, attName)) continue;
- att = ref1[attName];
- clonedSelf.attributes[attName] = att.clone();
- }
- clonedSelf.children = [];
- this.children.forEach(function(child) {
- var clonedChild;
- clonedChild = child.clone();
- clonedChild.parent = clonedSelf;
- return clonedSelf.children.push(clonedChild);
- });
- return clonedSelf;
- };
-
- XMLElement.prototype.attribute = function(name, value) {
- var attName, attValue;
- if (name != null) {
- name = name.valueOf();
- }
- 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);
- }
- }
- return this;
- };
-
- XMLElement.prototype.removeAttribute = function(name) {
- var attName, i, len;
- if (name == null) {
- throw new Error("Missing attribute name");
- }
- name = name.valueOf();
- if (Array.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;
- };
-
- XMLElement.prototype.toString = function(options) {
- return this.options.writer.set(options).element(this);
- };
-
- XMLElement.prototype.att = function(name, value) {
- return this.attribute(name, value);
- };
-
- XMLElement.prototype.a = function(name, value) {
- return this.attribute(name, value);
- };
-
- return XMLElement;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":4,"./XMLAttribute":5,"./XMLNode":17}],17:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
- hasProp = {}.hasOwnProperty;
-
- ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
-
- XMLElement = null;
-
- XMLCData = null;
-
- XMLComment = null;
-
- XMLDeclaration = null;
-
- XMLDocType = null;
-
- XMLRaw = null;
-
- XMLText = null;
-
- XMLProcessingInstruction = null;
-
- module.exports = XMLNode = (function() {
- function XMLNode(parent) {
- this.parent = parent;
- if (this.parent) {
- this.options = this.parent.options;
- this.stringify = this.parent.stringify;
- }
- this.children = [];
- if (!XMLElement) {
- XMLElement = require('./XMLElement');
- XMLCData = require('./XMLCData');
- XMLComment = require('./XMLComment');
- XMLDeclaration = require('./XMLDeclaration');
- XMLDocType = require('./XMLDocType');
- XMLRaw = require('./XMLRaw');
- XMLText = require('./XMLText');
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
- }
- }
-
- XMLNode.prototype.element = function(name, attributes, text) {
- var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
- lastChild = null;
- if (attributes == null) {
- attributes = {};
- }
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- if (name != null) {
- name = name.valueOf();
- }
- if (Array.isArray(name)) {
- for (j = 0, len = name.length; j < len; j++) {
- item = name[j];
- lastChild = this.element(item);
- }
- } else if (isFunction(name)) {
- lastChild = this.element(name.apply());
- } else if (isObject(name)) {
- for (key in name) {
- if (!hasProp.call(name, key)) continue;
- val = name[key];
- if (isFunction(val)) {
- val = val.apply();
- }
- if ((isObject(val)) && (isEmpty(val))) {
- val = null;
- }
- 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.options.separateArrayItems && 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)) {
- lastChild = this.element(key);
- lastChild.element(val);
- } else {
- lastChild = this.element(key, val);
- }
- }
- } else {
- if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
- lastChild = this.text(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
- lastChild = this.cdata(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
- lastChild = this.comment(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
- 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 {
- lastChild = this.node(name, attributes, text);
- }
- }
- if (lastChild == null) {
- throw new Error("Could not create any elements with: " + name);
- }
- return lastChild;
- };
-
- XMLNode.prototype.insertBefore = function(name, attributes, text) {
- var child, i, removed;
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level");
- }
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.element(name, attributes, text);
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- };
-
- XMLNode.prototype.insertAfter = function(name, attributes, text) {
- var child, i, removed;
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level");
- }
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.element(name, attributes, text);
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- };
-
- XMLNode.prototype.remove = function() {
- var i, ref1;
- if (this.isRoot) {
- throw new Error("Cannot remove the root element");
- }
- i = this.parent.children.indexOf(this);
- [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
- return this.parent;
- };
-
- XMLNode.prototype.node = function(name, attributes, text) {
- var child, ref1;
- if (name != null) {
- name = name.valueOf();
- }
- attributes || (attributes = {});
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- child = new XMLElement(this, name, attributes);
- if (text != null) {
- child.text(text);
- }
- this.children.push(child);
- return child;
- };
-
- XMLNode.prototype.text = function(value) {
- var child;
- child = new XMLText(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.cdata = function(value) {
- var child;
- child = new XMLCData(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.comment = function(value) {
- var child;
- child = new XMLComment(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.commentBefore = function(value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.comment(value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.commentAfter = function(value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.comment(value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.raw = function(value) {
- var child;
- child = new XMLRaw(this, value);
- this.children.push(child);
- return this;
- };
-
- 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.instructionBefore = function(target, value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.instruction(target, value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.instructionAfter = function(target, value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.instruction(target, value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.declaration = function(version, encoding, standalone) {
- var doc, xmldec;
- doc = this.document();
- xmldec = new XMLDeclaration(doc, version, encoding, standalone);
- if (doc.children[0] instanceof XMLDeclaration) {
- doc.children[0] = xmldec;
- } else {
- doc.children.unshift(xmldec);
- }
- return doc.root() || doc;
- };
-
- XMLNode.prototype.doctype = function(pubID, sysID) {
- var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
- doc = this.document();
- doctype = new XMLDocType(doc, pubID, sysID);
- ref1 = doc.children;
- for (i = j = 0, len = ref1.length; j < len; i = ++j) {
- child = ref1[i];
- if (child instanceof XMLDocType) {
- doc.children[i] = doctype;
- return doctype;
- }
- }
- ref2 = doc.children;
- for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
- child = ref2[i];
- if (child.isRoot) {
- doc.children.splice(i, 0, doctype);
- return doctype;
- }
- }
- doc.children.push(doctype);
- return doctype;
- };
-
- XMLNode.prototype.up = function() {
- if (this.isRoot) {
- throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
- }
- return this.parent;
- };
-
- XMLNode.prototype.root = function() {
- var node;
- node = this;
- while (node) {
- if (node.isDocument) {
- return node.rootObject;
- } else if (node.isRoot) {
- return node;
- } else {
- node = node.parent;
- }
- }
- };
-
- XMLNode.prototype.document = function() {
- var node;
- node = this;
- while (node) {
- if (node.isDocument) {
- return node;
- } else {
- node = node.parent;
- }
- }
- };
-
- XMLNode.prototype.end = function(options) {
- return this.document().end(options);
- };
-
- XMLNode.prototype.prev = function() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i < 1) {
- throw new Error("Already at the first node");
- }
- return this.parent.children[i - 1];
- };
-
- XMLNode.prototype.next = function() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i === -1 || i === this.parent.children.length - 1) {
- throw new Error("Already at the last node");
- }
- return this.parent.children[i + 1];
- };
-
- XMLNode.prototype.importDocument = function(doc) {
- var clonedRoot;
- clonedRoot = doc.root().clone();
- clonedRoot.parent = this;
- clonedRoot.isRoot = false;
- this.children.push(clonedRoot);
- return this;
- };
-
- XMLNode.prototype.ele = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLNode.prototype.nod = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLNode.prototype.txt = function(value) {
- return this.text(value);
- };
-
- XMLNode.prototype.dat = function(value) {
- return this.cdata(value);
- };
-
- XMLNode.prototype.com = function(value) {
- return this.comment(value);
- };
-
- XMLNode.prototype.ins = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLNode.prototype.doc = function() {
- return this.document();
- };
-
- XMLNode.prototype.dec = function(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- };
-
- XMLNode.prototype.dtd = function(pubID, sysID) {
- return this.doctype(pubID, sysID);
- };
-
- XMLNode.prototype.e = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLNode.prototype.n = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLNode.prototype.t = function(value) {
- return this.text(value);
- };
-
- XMLNode.prototype.d = function(value) {
- return this.cdata(value);
- };
-
- XMLNode.prototype.c = function(value) {
- return this.comment(value);
- };
-
- XMLNode.prototype.r = function(value) {
- return this.raw(value);
- };
-
- XMLNode.prototype.i = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLNode.prototype.u = function() {
- return this.up();
- };
-
- XMLNode.prototype.importXMLBuilder = function(doc) {
- return this.importDocument(doc);
- };
-
- return XMLNode;
-
- })();
-
- }).call(this);
-
- },{"./Utility":4,"./XMLCData":6,"./XMLComment":7,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23}],18:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLProcessingInstruction,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLProcessingInstruction = (function(superClass) {
- extend(XMLProcessingInstruction, superClass);
-
- function XMLProcessingInstruction(parent, target, value) {
- XMLProcessingInstruction.__super__.constructor.call(this, parent);
- if (target == null) {
- throw new Error("Missing instruction target");
- }
- this.target = this.stringify.insTarget(target);
- if (value) {
- this.value = this.stringify.insValue(value);
- }
- }
-
- XMLProcessingInstruction.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLProcessingInstruction.prototype.toString = function(options) {
- return this.options.writer.set(options).processingInstruction(this);
- };
-
- return XMLProcessingInstruction;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],19:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLRaw,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLRaw = (function(superClass) {
- extend(XMLRaw, superClass);
-
- function XMLRaw(parent, text) {
- XMLRaw.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing raw text");
- }
- this.value = this.stringify.raw(text);
- }
-
- XMLRaw.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLRaw.prototype.toString = function(options) {
- return this.options.writer.set(options).raw(this);
- };
-
- return XMLRaw;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],20:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
- 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;
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLElement = require('./XMLElement');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLWriterBase = require('./XMLWriterBase');
-
- module.exports = XMLStreamWriter = (function(superClass) {
- extend(XMLStreamWriter, superClass);
-
- function XMLStreamWriter(stream, options) {
- XMLStreamWriter.__super__.constructor.call(this, options);
- this.stream = stream;
- }
-
- XMLStreamWriter.prototype.document = function(doc) {
- var child, i, j, len, len1, ref, ref1, results;
- ref = doc.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- child.isLastRootNode = false;
- }
- doc.children[doc.children.length - 1].isLastRootNode = true;
- ref1 = doc.children;
- results = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- child = ref1[j];
- switch (false) {
- case !(child instanceof XMLDeclaration):
- results.push(this.declaration(child));
- break;
- case !(child instanceof XMLDocType):
- results.push(this.docType(child));
- break;
- case !(child instanceof XMLComment):
- results.push(this.comment(child));
- break;
- case !(child instanceof XMLProcessingInstruction):
- results.push(this.processingInstruction(child));
- break;
- default:
- results.push(this.element(child));
- }
- }
- return results;
- };
-
- XMLStreamWriter.prototype.attribute = function(att) {
- return this.stream.write(' ' + att.name + '="' + att.value + '"');
- };
-
- XMLStreamWriter.prototype.cdata = function(node, level) {
- return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.comment = function(node, level) {
- return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.declaration = function(node, level) {
- this.stream.write(this.space(level));
- this.stream.write('<?xml version="' + node.version + '"');
- if (node.encoding != null) {
- this.stream.write(' encoding="' + node.encoding + '"');
- }
- if (node.standalone != null) {
- this.stream.write(' standalone="' + node.standalone + '"');
- }
- this.stream.write(this.spacebeforeslash + '?>');
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.docType = function(node, level) {
- var child, i, len, ref;
- level || (level = 0);
- this.stream.write(this.space(level));
- this.stream.write('<!DOCTYPE ' + node.root().name);
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- if (node.children.length > 0) {
- this.stream.write(' [');
- this.stream.write(this.endline(node));
- ref = node.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- switch (false) {
- case !(child instanceof XMLDTDAttList):
- this.dtdAttList(child, level + 1);
- break;
- case !(child instanceof XMLDTDElement):
- this.dtdElement(child, level + 1);
- break;
- case !(child instanceof XMLDTDEntity):
- this.dtdEntity(child, level + 1);
- break;
- case !(child instanceof XMLDTDNotation):
- this.dtdNotation(child, level + 1);
- break;
- case !(child instanceof XMLCData):
- this.cdata(child, level + 1);
- break;
- case !(child instanceof XMLComment):
- this.comment(child, level + 1);
- break;
- case !(child instanceof XMLProcessingInstruction):
- this.processingInstruction(child, level + 1);
- break;
- default:
- throw new Error("Unknown DTD node type: " + child.constructor.name);
- }
- }
- this.stream.write(']');
- }
- this.stream.write(this.spacebeforeslash + '>');
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.element = function(node, level) {
- var att, child, i, len, name, ref, ref1, space;
- level || (level = 0);
- space = this.space(level);
- this.stream.write(space + '<' + node.name);
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- this.attribute(att);
- }
- if (node.children.length === 0 || node.children.every(function(e) {
- return e.value === '';
- })) {
- if (this.allowEmpty) {
- this.stream.write('></' + node.name + '>');
- } else {
- this.stream.write(this.spacebeforeslash + '/>');
- }
- } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
- this.stream.write('>');
- this.stream.write(node.children[0].value);
- this.stream.write('</' + node.name + '>');
- } else {
- this.stream.write('>' + this.newline);
- ref1 = node.children;
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- switch (false) {
- case !(child instanceof XMLCData):
- this.cdata(child, level + 1);
- break;
- case !(child instanceof XMLComment):
- this.comment(child, level + 1);
- break;
- case !(child instanceof XMLElement):
- this.element(child, level + 1);
- break;
- case !(child instanceof XMLRaw):
- this.raw(child, level + 1);
- break;
- case !(child instanceof XMLText):
- this.text(child, level + 1);
- break;
- case !(child instanceof XMLProcessingInstruction):
- this.processingInstruction(child, level + 1);
- break;
- default:
- throw new Error("Unknown XML node type: " + child.constructor.name);
- }
- }
- this.stream.write(space + '</' + node.name + '>');
- }
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.processingInstruction = function(node, level) {
- this.stream.write(this.space(level) + '<?' + node.target);
- if (node.value) {
- this.stream.write(' ' + node.value);
- }
- return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.raw = function(node, level) {
- return this.stream.write(this.space(level) + node.value + this.endline(node));
- };
-
- XMLStreamWriter.prototype.text = function(node, level) {
- return this.stream.write(this.space(level) + node.value + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdAttList = function(node, level) {
- this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
- if (node.defaultValueType !== '#DEFAULT') {
- this.stream.write(' ' + node.defaultValueType);
- }
- if (node.defaultValue) {
- this.stream.write(' "' + node.defaultValue + '"');
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdElement = function(node, level) {
- this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdEntity = function(node, level) {
- this.stream.write(this.space(level) + '<!ENTITY');
- if (node.pe) {
- this.stream.write(' %');
- }
- this.stream.write(' ' + node.name);
- if (node.value) {
- this.stream.write(' "' + node.value + '"');
- } else {
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- if (node.nData) {
- this.stream.write(' NDATA ' + node.nData);
- }
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdNotation = function(node, level) {
- this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.pubID) {
- this.stream.write(' PUBLIC "' + node.pubID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.endline = function(node) {
- if (!node.isLastRootNode) {
- return this.newline;
- } else {
- return '';
- }
- };
-
- return XMLStreamWriter;
-
- })(XMLWriterBase);
-
- }).call(this);
-
- },{"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23,"./XMLWriterBase":24}],21:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
- 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;
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLElement = require('./XMLElement');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLWriterBase = require('./XMLWriterBase');
-
- module.exports = XMLStringWriter = (function(superClass) {
- extend(XMLStringWriter, superClass);
-
- function XMLStringWriter(options) {
- XMLStringWriter.__super__.constructor.call(this, options);
- }
-
- XMLStringWriter.prototype.document = function(doc) {
- var child, i, len, r, ref;
- this.textispresent = false;
- r = '';
- ref = doc.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLDeclaration):
- return this.declaration(child);
- case !(child instanceof XMLDocType):
- return this.docType(child);
- case !(child instanceof XMLComment):
- return this.comment(child);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child);
- default:
- return this.element(child, 0);
- }
- }).call(this);
- }
- if (this.pretty && r.slice(-this.newline.length) === this.newline) {
- r = r.slice(0, -this.newline.length);
- }
- return r;
- };
-
- XMLStringWriter.prototype.attribute = function(att) {
- return ' ' + att.name + '="' + att.value + '"';
- };
-
- XMLStringWriter.prototype.cdata = function(node, level) {
- return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
- };
-
- XMLStringWriter.prototype.comment = function(node, level) {
- return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
- };
-
- XMLStringWriter.prototype.declaration = function(node, level) {
- var r;
- r = this.space(level);
- r += '<?xml version="' + node.version + '"';
- if (node.encoding != null) {
- r += ' encoding="' + node.encoding + '"';
- }
- if (node.standalone != null) {
- r += ' standalone="' + node.standalone + '"';
- }
- r += this.spacebeforeslash + '?>';
- r += this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.docType = function(node, level) {
- var child, i, len, r, ref;
- level || (level = 0);
- r = this.space(level);
- r += '<!DOCTYPE ' + node.root().name;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- if (node.children.length > 0) {
- r += ' [';
- r += this.newline;
- ref = node.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLDTDAttList):
- return this.dtdAttList(child, level + 1);
- case !(child instanceof XMLDTDElement):
- return this.dtdElement(child, level + 1);
- case !(child instanceof XMLDTDEntity):
- return this.dtdEntity(child, level + 1);
- case !(child instanceof XMLDTDNotation):
- return this.dtdNotation(child, level + 1);
- case !(child instanceof XMLCData):
- return this.cdata(child, level + 1);
- case !(child instanceof XMLComment):
- return this.comment(child, level + 1);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child, level + 1);
- default:
- throw new Error("Unknown DTD node type: " + child.constructor.name);
- }
- }).call(this);
- }
- r += ']';
- }
- r += this.spacebeforeslash + '>';
- r += this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.element = function(node, level) {
- var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
- level || (level = 0);
- textispresentwasset = false;
- if (this.textispresent) {
- this.newline = '';
- this.pretty = false;
- } else {
- this.newline = this.newlinedefault;
- this.pretty = this.prettydefault;
- }
- space = this.space(level);
- r = '';
- r += space + '<' + node.name;
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- r += this.attribute(att);
- }
- if (node.children.length === 0 || node.children.every(function(e) {
- return e.value === '';
- })) {
- if (this.allowEmpty) {
- r += '></' + node.name + '>' + this.newline;
- } else {
- r += this.spacebeforeslash + '/>' + this.newline;
- }
- } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
- r += '>';
- r += node.children[0].value;
- r += '</' + node.name + '>' + this.newline;
- } else {
- if (this.dontprettytextnodes) {
- ref1 = node.children;
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- if (child.value != null) {
- this.textispresent++;
- textispresentwasset = true;
- break;
- }
- }
- }
- if (this.textispresent) {
- this.newline = '';
- this.pretty = false;
- space = this.space(level);
- }
- r += '>' + this.newline;
- ref2 = node.children;
- for (j = 0, len1 = ref2.length; j < len1; j++) {
- child = ref2[j];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLCData):
- return this.cdata(child, level + 1);
- case !(child instanceof XMLComment):
- return this.comment(child, level + 1);
- case !(child instanceof XMLElement):
- return this.element(child, level + 1);
- case !(child instanceof XMLRaw):
- return this.raw(child, level + 1);
- case !(child instanceof XMLText):
- return this.text(child, level + 1);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child, level + 1);
- default:
- throw new Error("Unknown XML node type: " + child.constructor.name);
- }
- }).call(this);
- }
- if (textispresentwasset) {
- this.textispresent--;
- }
- if (!this.textispresent) {
- this.newline = this.newlinedefault;
- this.pretty = this.prettydefault;
- }
- r += space + '</' + node.name + '>' + this.newline;
- }
- return r;
- };
-
- XMLStringWriter.prototype.processingInstruction = function(node, level) {
- var r;
- r = this.space(level) + '<?' + node.target;
- if (node.value) {
- r += ' ' + node.value;
- }
- r += this.spacebeforeslash + '?>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.raw = function(node, level) {
- return this.space(level) + node.value + this.newline;
- };
-
- XMLStringWriter.prototype.text = function(node, level) {
- return this.space(level) + node.value + this.newline;
- };
-
- XMLStringWriter.prototype.dtdAttList = function(node, level) {
- var r;
- r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
- if (node.defaultValueType !== '#DEFAULT') {
- r += ' ' + node.defaultValueType;
- }
- if (node.defaultValue) {
- r += ' "' + node.defaultValue + '"';
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.dtdElement = function(node, level) {
- return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
- };
-
- XMLStringWriter.prototype.dtdEntity = function(node, level) {
- var r;
- r = this.space(level) + '<!ENTITY';
- if (node.pe) {
- r += ' %';
- }
- r += ' ' + node.name;
- if (node.value) {
- r += ' "' + node.value + '"';
- } else {
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- if (node.nData) {
- r += ' NDATA ' + node.nData;
- }
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.dtdNotation = function(node, level) {
- var r;
- r = this.space(level) + '<!NOTATION ' + node.name;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.pubID) {
- r += ' PUBLIC "' + node.pubID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.openNode = function(node, level) {
- var att, name, r, ref;
- level || (level = 0);
- if (node instanceof XMLElement) {
- r = this.space(level) + '<' + node.name;
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- r += this.attribute(att);
- }
- r += (node.children ? '>' : '/>') + this.newline;
- return r;
- } else {
- r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- r += (node.children ? ' [' : '>') + this.newline;
- return r;
- }
- };
-
- XMLStringWriter.prototype.closeNode = function(node, level) {
- level || (level = 0);
- switch (false) {
- case !(node instanceof XMLElement):
- return this.space(level) + '</' + node.name + '>' + this.newline;
- case !(node instanceof XMLDocType):
- return this.space(level) + ']>' + this.newline;
- }
- };
-
- return XMLStringWriter;
-
- })(XMLWriterBase);
-
- }).call(this);
-
- },{"./XMLCData":6,"./XMLComment":7,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23,"./XMLWriterBase":24}],22:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLStringifier,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- hasProp = {}.hasOwnProperty;
-
- module.exports = XMLStringifier = (function() {
- function XMLStringifier(options) {
- this.assertLegalChar = bind(this.assertLegalChar, this);
- var key, ref, value;
- options || (options = {});
- this.noDoubleEncoding = options.noDoubleEncoding;
- ref = options.stringify || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this[key] = value;
- }
- }
-
- XMLStringifier.prototype.eleName = function(val) {
- val = '' + val || '';
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.eleText = function(val) {
- val = '' + val || '';
- return this.assertLegalChar(this.elEscape(val));
- };
-
- XMLStringifier.prototype.cdata = function(val) {
- val = '' + val || '';
- val = val.replace(']]>', ']]]]><![CDATA[>');
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.comment = function(val) {
- val = '' + val || '';
- if (val.match(/--/)) {
- throw new Error("Comment text cannot contain double-hypen: " + val);
- }
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.raw = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.attName = function(val) {
- return val = '' + val || '';
- };
-
- XMLStringifier.prototype.attValue = function(val) {
- val = '' + val || '';
- return this.attEscape(val);
- };
-
- XMLStringifier.prototype.insTarget = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.insValue = function(val) {
- val = '' + val || '';
- if (val.match(/\?>/)) {
- throw new Error("Invalid processing instruction value: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlVersion = function(val) {
- val = '' + val || '';
- if (!val.match(/1\.[0-9]+/)) {
- throw new Error("Invalid version number: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlEncoding = function(val) {
- val = '' + val || '';
- if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
- throw new Error("Invalid encoding: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlStandalone = function(val) {
- if (val) {
- return "yes";
- } else {
- return "no";
- }
- };
-
- XMLStringifier.prototype.dtdPubID = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdSysID = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdElementValue = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdAttType = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdAttDefault = function(val) {
- if (val != null) {
- return '' + val || '';
- } else {
- return val;
- }
- };
-
- XMLStringifier.prototype.dtdEntityValue = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdNData = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.convertAttKey = '@';
-
- XMLStringifier.prototype.convertPIKey = '?';
-
- XMLStringifier.prototype.convertTextKey = '#text';
-
- XMLStringifier.prototype.convertCDataKey = '#cdata';
-
- XMLStringifier.prototype.convertCommentKey = '#comment';
-
- XMLStringifier.prototype.convertRawKey = '#raw';
-
- XMLStringifier.prototype.assertLegalChar = function(str) {
- var res;
- res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
- if (res) {
- throw new Error("Invalid character in string: " + str + " at index " + res.index);
- }
- return str;
- };
-
- XMLStringifier.prototype.elEscape = function(str) {
- var ampregex;
- ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r/g, '
');
- };
-
- XMLStringifier.prototype.attEscape = function(str) {
- var ampregex;
- ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
');
- };
-
- return XMLStringifier;
-
- })();
-
- }).call(this);
-
- },{}],23:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLText,
- 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;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLText = (function(superClass) {
- extend(XMLText, superClass);
-
- function XMLText(parent, text) {
- XMLText.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing element text");
- }
- this.value = this.stringify.eleText(text);
- }
-
- XMLText.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLText.prototype.toString = function(options) {
- return this.options.writer.set(options).text(this);
- };
-
- return XMLText;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":17}],24:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLWriterBase,
- hasProp = {}.hasOwnProperty;
-
- module.exports = XMLWriterBase = (function() {
- function XMLWriterBase(options) {
- var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
- options || (options = {});
- this.pretty = options.pretty || false;
- this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
- if (this.pretty) {
- this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
- this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
- this.offset = (ref3 = options.offset) != null ? ref3 : 0;
- this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
- } else {
- this.indent = '';
- this.newline = '';
- this.offset = 0;
- this.dontprettytextnodes = 0;
- }
- this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
- if (this.spacebeforeslash === true) {
- this.spacebeforeslash = ' ';
- }
- this.newlinedefault = this.newline;
- this.prettydefault = this.pretty;
- ref6 = options.writer || {};
- for (key in ref6) {
- if (!hasProp.call(ref6, key)) continue;
- value = ref6[key];
- this[key] = value;
- }
- }
-
- XMLWriterBase.prototype.set = function(options) {
- var key, ref, value;
- options || (options = {});
- if ("pretty" in options) {
- this.pretty = options.pretty;
- }
- if ("allowEmpty" in options) {
- this.allowEmpty = options.allowEmpty;
- }
- if (this.pretty) {
- this.indent = "indent" in options ? options.indent : ' ';
- this.newline = "newline" in options ? options.newline : '\n';
- this.offset = "offset" in options ? options.offset : 0;
- this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
- } else {
- this.indent = '';
- this.newline = '';
- this.offset = 0;
- this.dontprettytextnodes = 0;
- }
- this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
- if (this.spacebeforeslash === true) {
- this.spacebeforeslash = ' ';
- }
- this.newlinedefault = this.newline;
- this.prettydefault = this.pretty;
- ref = options.writer || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this[key] = value;
- }
- return this;
- };
-
- XMLWriterBase.prototype.space = function(level) {
- var indent;
- if (this.pretty) {
- indent = (level || 0) + this.offset + 1;
- if (indent > 0) {
- return new Array(indent).join(this.indent);
- } else {
- return '';
- }
- } else {
- return '';
- }
- };
-
- return XMLWriterBase;
-
- })();
-
- }).call(this);
-
- },{}],25:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
-
- ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
-
- XMLDocument = require('./XMLDocument');
-
- XMLDocumentCB = require('./XMLDocumentCB');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- XMLStreamWriter = require('./XMLStreamWriter');
-
- module.exports.create = function(name, xmldec, doctype, options) {
- var doc, root;
- if (name == null) {
- throw new Error("Root element needs a name");
- }
- options = assign({}, xmldec, doctype, options);
- doc = new XMLDocument(options);
- root = doc.element(name);
- if (!options.headless) {
- doc.declaration(options);
- if ((options.pubID != null) || (options.sysID != null)) {
- doc.doctype(options);
- }
- }
- return root;
- };
-
- module.exports.begin = function(options, onData, onEnd) {
- var ref1;
- if (isFunction(options)) {
- ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
- options = {};
- }
- if (onData) {
- return new XMLDocumentCB(options, onData, onEnd);
- } else {
- return new XMLDocument(options);
- }
- };
-
- module.exports.stringWriter = function(options) {
- return new XMLStringWriter(options);
- };
-
- module.exports.streamWriter = function(stream, options) {
- return new XMLStreamWriter(stream, options);
- };
-
- }).call(this);
-
- },{"./Utility":4,"./XMLDocument":14,"./XMLDocumentCB":15,"./XMLStreamWriter":20,"./XMLStringWriter":21}]},{},[1])(1)
- });
|