Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

plist-build.js 90KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832
  1. (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){
  2. (function (Buffer){
  3. /**
  4. * Module dependencies.
  5. */
  6. var base64 = require('base64-js');
  7. var xmlbuilder = require('xmlbuilder');
  8. /**
  9. * Module exports.
  10. */
  11. exports.build = build;
  12. /**
  13. * Accepts a `Date` instance and returns an ISO date string.
  14. *
  15. * @param {Date} d - Date instance to serialize
  16. * @returns {String} ISO date string representation of `d`
  17. * @api private
  18. */
  19. function ISODateString(d){
  20. function pad(n){
  21. return n < 10 ? '0' + n : n;
  22. }
  23. return d.getUTCFullYear()+'-'
  24. + pad(d.getUTCMonth()+1)+'-'
  25. + pad(d.getUTCDate())+'T'
  26. + pad(d.getUTCHours())+':'
  27. + pad(d.getUTCMinutes())+':'
  28. + pad(d.getUTCSeconds())+'Z';
  29. }
  30. /**
  31. * Returns the internal "type" of `obj` via the
  32. * `Object.prototype.toString()` trick.
  33. *
  34. * @param {Mixed} obj - any value
  35. * @returns {String} the internal "type" name
  36. * @api private
  37. */
  38. var toString = Object.prototype.toString;
  39. function type (obj) {
  40. var m = toString.call(obj).match(/\[object (.*)\]/);
  41. return m ? m[1] : m;
  42. }
  43. /**
  44. * Generate an XML plist string from the input object `obj`.
  45. *
  46. * @param {Object} obj - the object to convert
  47. * @param {Object} [opts] - optional options object
  48. * @returns {String} converted plist XML string
  49. * @api public
  50. */
  51. function build (obj, opts) {
  52. var XMLHDR = {
  53. version: '1.0',
  54. encoding: 'UTF-8'
  55. };
  56. var XMLDTD = {
  57. pubid: '-//Apple//DTD PLIST 1.0//EN',
  58. sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
  59. };
  60. var doc = xmlbuilder.create('plist');
  61. doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
  62. doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
  63. doc.att('version', '1.0');
  64. walk_obj(obj, doc);
  65. if (!opts) opts = {};
  66. // default `pretty` to `true`
  67. opts.pretty = opts.pretty !== false;
  68. return doc.end(opts);
  69. }
  70. /**
  71. * depth first, recursive traversal of a javascript object. when complete,
  72. * next_child contains a reference to the build XML object.
  73. *
  74. * @api private
  75. */
  76. function walk_obj(next, next_child) {
  77. var tag_type, i, prop;
  78. var name = type(next);
  79. if ('Undefined' == name) {
  80. return;
  81. } else if (Array.isArray(next)) {
  82. next_child = next_child.ele('array');
  83. for (i = 0; i < next.length; i++) {
  84. walk_obj(next[i], next_child);
  85. }
  86. } else if (Buffer.isBuffer(next)) {
  87. next_child.ele('data').raw(next.toString('base64'));
  88. } else if ('Object' == name) {
  89. next_child = next_child.ele('dict');
  90. for (prop in next) {
  91. if (next.hasOwnProperty(prop)) {
  92. next_child.ele('key').txt(prop);
  93. walk_obj(next[prop], next_child);
  94. }
  95. }
  96. } else if ('Number' == name) {
  97. // detect if this is an integer or real
  98. // TODO: add an ability to force one way or another via a "cast"
  99. tag_type = (next % 1 === 0) ? 'integer' : 'real';
  100. next_child.ele(tag_type).txt(next.toString());
  101. } else if ('Date' == name) {
  102. next_child.ele('date').txt(ISODateString(new Date(next)));
  103. } else if ('Boolean' == name) {
  104. next_child.ele(next ? 'true' : 'false');
  105. } else if ('String' == name) {
  106. next_child.ele('string').txt(next);
  107. } else if ('ArrayBuffer' == name) {
  108. next_child.ele('data').raw(base64.fromByteArray(next));
  109. } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
  110. // a typed array
  111. next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
  112. }
  113. }
  114. }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
  115. },{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":25}],2:[function(require,module,exports){
  116. 'use strict'
  117. exports.byteLength = byteLength
  118. exports.toByteArray = toByteArray
  119. exports.fromByteArray = fromByteArray
  120. var lookup = []
  121. var revLookup = []
  122. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  123. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  124. for (var i = 0, len = code.length; i < len; ++i) {
  125. lookup[i] = code[i]
  126. revLookup[code.charCodeAt(i)] = i
  127. }
  128. // Support decoding URL-safe base64 strings, as Node.js does.
  129. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  130. revLookup['-'.charCodeAt(0)] = 62
  131. revLookup['_'.charCodeAt(0)] = 63
  132. function placeHoldersCount (b64) {
  133. var len = b64.length
  134. if (len % 4 > 0) {
  135. throw new Error('Invalid string. Length must be a multiple of 4')
  136. }
  137. // the number of equal signs (place holders)
  138. // if there are two placeholders, than the two characters before it
  139. // represent one byte
  140. // if there is only one, then the three characters before it represent 2 bytes
  141. // this is just a cheap hack to not do indexOf twice
  142. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  143. }
  144. function byteLength (b64) {
  145. // base64 is 4/3 + up to two characters of the original data
  146. return (b64.length * 3 / 4) - placeHoldersCount(b64)
  147. }
  148. function toByteArray (b64) {
  149. var i, l, tmp, placeHolders, arr
  150. var len = b64.length
  151. placeHolders = placeHoldersCount(b64)
  152. arr = new Arr((len * 3 / 4) - placeHolders)
  153. // if there are placeholders, only get up to the last complete 4 chars
  154. l = placeHolders > 0 ? len - 4 : len
  155. var L = 0
  156. for (i = 0; i < l; i += 4) {
  157. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  158. arr[L++] = (tmp >> 16) & 0xFF
  159. arr[L++] = (tmp >> 8) & 0xFF
  160. arr[L++] = tmp & 0xFF
  161. }
  162. if (placeHolders === 2) {
  163. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  164. arr[L++] = tmp & 0xFF
  165. } else if (placeHolders === 1) {
  166. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  167. arr[L++] = (tmp >> 8) & 0xFF
  168. arr[L++] = tmp & 0xFF
  169. }
  170. return arr
  171. }
  172. function tripletToBase64 (num) {
  173. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  174. }
  175. function encodeChunk (uint8, start, end) {
  176. var tmp
  177. var output = []
  178. for (var i = start; i < end; i += 3) {
  179. tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
  180. output.push(tripletToBase64(tmp))
  181. }
  182. return output.join('')
  183. }
  184. function fromByteArray (uint8) {
  185. var tmp
  186. var len = uint8.length
  187. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  188. var output = ''
  189. var parts = []
  190. var maxChunkLength = 16383 // must be multiple of 3
  191. // go through the array every three bytes, we'll deal with trailing stuff later
  192. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  193. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  194. }
  195. // pad the end with zeros, but make sure to not forget the extra bytes
  196. if (extraBytes === 1) {
  197. tmp = uint8[len - 1]
  198. output += lookup[tmp >> 2]
  199. output += lookup[(tmp << 4) & 0x3F]
  200. output += '=='
  201. } else if (extraBytes === 2) {
  202. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  203. output += lookup[tmp >> 10]
  204. output += lookup[(tmp >> 4) & 0x3F]
  205. output += lookup[(tmp << 2) & 0x3F]
  206. output += '='
  207. }
  208. parts.push(output)
  209. return parts.join('')
  210. }
  211. },{}],3:[function(require,module,exports){
  212. /*!
  213. * Determine if an object is a Buffer
  214. *
  215. * @author Feross Aboukhadijeh <https://feross.org>
  216. * @license MIT
  217. */
  218. // The _isBuffer check is for Safari 5-7 support, because it's missing
  219. // Object.prototype.constructor. Remove this eventually
  220. module.exports = function (obj) {
  221. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  222. }
  223. function isBuffer (obj) {
  224. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  225. }
  226. // For Node v0.10 support. Remove this eventually.
  227. function isSlowBuffer (obj) {
  228. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  229. }
  230. },{}],4:[function(require,module,exports){
  231. // Generated by CoffeeScript 1.12.7
  232. (function() {
  233. var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
  234. slice = [].slice,
  235. hasProp = {}.hasOwnProperty;
  236. assign = function() {
  237. var i, key, len, source, sources, target;
  238. target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  239. if (isFunction(Object.assign)) {
  240. Object.assign.apply(null, arguments);
  241. } else {
  242. for (i = 0, len = sources.length; i < len; i++) {
  243. source = sources[i];
  244. if (source != null) {
  245. for (key in source) {
  246. if (!hasProp.call(source, key)) continue;
  247. target[key] = source[key];
  248. }
  249. }
  250. }
  251. }
  252. return target;
  253. };
  254. isFunction = function(val) {
  255. return !!val && Object.prototype.toString.call(val) === '[object Function]';
  256. };
  257. isObject = function(val) {
  258. var ref;
  259. return !!val && ((ref = typeof val) === 'function' || ref === 'object');
  260. };
  261. isArray = function(val) {
  262. if (isFunction(Array.isArray)) {
  263. return Array.isArray(val);
  264. } else {
  265. return Object.prototype.toString.call(val) === '[object Array]';
  266. }
  267. };
  268. isEmpty = function(val) {
  269. var key;
  270. if (isArray(val)) {
  271. return !val.length;
  272. } else {
  273. for (key in val) {
  274. if (!hasProp.call(val, key)) continue;
  275. return false;
  276. }
  277. return true;
  278. }
  279. };
  280. isPlainObject = function(val) {
  281. var ctor, proto;
  282. 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));
  283. };
  284. module.exports.assign = assign;
  285. module.exports.isFunction = isFunction;
  286. module.exports.isObject = isObject;
  287. module.exports.isArray = isArray;
  288. module.exports.isEmpty = isEmpty;
  289. module.exports.isPlainObject = isPlainObject;
  290. }).call(this);
  291. },{}],5:[function(require,module,exports){
  292. // Generated by CoffeeScript 1.12.7
  293. (function() {
  294. var XMLAttribute;
  295. module.exports = XMLAttribute = (function() {
  296. function XMLAttribute(parent, name, value) {
  297. this.options = parent.options;
  298. this.stringify = parent.stringify;
  299. if (name == null) {
  300. throw new Error("Missing attribute name of element " + parent.name);
  301. }
  302. if (value == null) {
  303. throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
  304. }
  305. this.name = this.stringify.attName(name);
  306. this.value = this.stringify.attValue(value);
  307. }
  308. XMLAttribute.prototype.clone = function() {
  309. return Object.create(this);
  310. };
  311. XMLAttribute.prototype.toString = function(options) {
  312. return this.options.writer.set(options).attribute(this);
  313. };
  314. return XMLAttribute;
  315. })();
  316. }).call(this);
  317. },{}],6:[function(require,module,exports){
  318. // Generated by CoffeeScript 1.12.7
  319. (function() {
  320. var XMLCData, XMLNode,
  321. 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; },
  322. hasProp = {}.hasOwnProperty;
  323. XMLNode = require('./XMLNode');
  324. module.exports = XMLCData = (function(superClass) {
  325. extend(XMLCData, superClass);
  326. function XMLCData(parent, text) {
  327. XMLCData.__super__.constructor.call(this, parent);
  328. if (text == null) {
  329. throw new Error("Missing CDATA text");
  330. }
  331. this.text = this.stringify.cdata(text);
  332. }
  333. XMLCData.prototype.clone = function() {
  334. return Object.create(this);
  335. };
  336. XMLCData.prototype.toString = function(options) {
  337. return this.options.writer.set(options).cdata(this);
  338. };
  339. return XMLCData;
  340. })(XMLNode);
  341. }).call(this);
  342. },{"./XMLNode":17}],7:[function(require,module,exports){
  343. // Generated by CoffeeScript 1.12.7
  344. (function() {
  345. var XMLComment, XMLNode,
  346. 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; },
  347. hasProp = {}.hasOwnProperty;
  348. XMLNode = require('./XMLNode');
  349. module.exports = XMLComment = (function(superClass) {
  350. extend(XMLComment, superClass);
  351. function XMLComment(parent, text) {
  352. XMLComment.__super__.constructor.call(this, parent);
  353. if (text == null) {
  354. throw new Error("Missing comment text");
  355. }
  356. this.text = this.stringify.comment(text);
  357. }
  358. XMLComment.prototype.clone = function() {
  359. return Object.create(this);
  360. };
  361. XMLComment.prototype.toString = function(options) {
  362. return this.options.writer.set(options).comment(this);
  363. };
  364. return XMLComment;
  365. })(XMLNode);
  366. }).call(this);
  367. },{"./XMLNode":17}],8:[function(require,module,exports){
  368. // Generated by CoffeeScript 1.12.7
  369. (function() {
  370. var XMLDTDAttList, XMLNode,
  371. 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; },
  372. hasProp = {}.hasOwnProperty;
  373. XMLNode = require('./XMLNode');
  374. module.exports = XMLDTDAttList = (function(superClass) {
  375. extend(XMLDTDAttList, superClass);
  376. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  377. XMLDTDAttList.__super__.constructor.call(this, parent);
  378. if (elementName == null) {
  379. throw new Error("Missing DTD element name");
  380. }
  381. if (attributeName == null) {
  382. throw new Error("Missing DTD attribute name");
  383. }
  384. if (!attributeType) {
  385. throw new Error("Missing DTD attribute type");
  386. }
  387. if (!defaultValueType) {
  388. throw new Error("Missing DTD attribute default");
  389. }
  390. if (defaultValueType.indexOf('#') !== 0) {
  391. defaultValueType = '#' + defaultValueType;
  392. }
  393. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  394. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
  395. }
  396. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  397. throw new Error("Default value only applies to #FIXED or #DEFAULT");
  398. }
  399. this.elementName = this.stringify.eleName(elementName);
  400. this.attributeName = this.stringify.attName(attributeName);
  401. this.attributeType = this.stringify.dtdAttType(attributeType);
  402. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  403. this.defaultValueType = defaultValueType;
  404. }
  405. XMLDTDAttList.prototype.toString = function(options) {
  406. return this.options.writer.set(options).dtdAttList(this);
  407. };
  408. return XMLDTDAttList;
  409. })(XMLNode);
  410. }).call(this);
  411. },{"./XMLNode":17}],9:[function(require,module,exports){
  412. // Generated by CoffeeScript 1.12.7
  413. (function() {
  414. var XMLDTDElement, XMLNode,
  415. 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; },
  416. hasProp = {}.hasOwnProperty;
  417. XMLNode = require('./XMLNode');
  418. module.exports = XMLDTDElement = (function(superClass) {
  419. extend(XMLDTDElement, superClass);
  420. function XMLDTDElement(parent, name, value) {
  421. XMLDTDElement.__super__.constructor.call(this, parent);
  422. if (name == null) {
  423. throw new Error("Missing DTD element name");
  424. }
  425. if (!value) {
  426. value = '(#PCDATA)';
  427. }
  428. if (Array.isArray(value)) {
  429. value = '(' + value.join(',') + ')';
  430. }
  431. this.name = this.stringify.eleName(name);
  432. this.value = this.stringify.dtdElementValue(value);
  433. }
  434. XMLDTDElement.prototype.toString = function(options) {
  435. return this.options.writer.set(options).dtdElement(this);
  436. };
  437. return XMLDTDElement;
  438. })(XMLNode);
  439. }).call(this);
  440. },{"./XMLNode":17}],10:[function(require,module,exports){
  441. // Generated by CoffeeScript 1.12.7
  442. (function() {
  443. var XMLDTDEntity, XMLNode, isObject,
  444. 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; },
  445. hasProp = {}.hasOwnProperty;
  446. isObject = require('./Utility').isObject;
  447. XMLNode = require('./XMLNode');
  448. module.exports = XMLDTDEntity = (function(superClass) {
  449. extend(XMLDTDEntity, superClass);
  450. function XMLDTDEntity(parent, pe, name, value) {
  451. XMLDTDEntity.__super__.constructor.call(this, parent);
  452. if (name == null) {
  453. throw new Error("Missing entity name");
  454. }
  455. if (value == null) {
  456. throw new Error("Missing entity value");
  457. }
  458. this.pe = !!pe;
  459. this.name = this.stringify.eleName(name);
  460. if (!isObject(value)) {
  461. this.value = this.stringify.dtdEntityValue(value);
  462. } else {
  463. if (!value.pubID && !value.sysID) {
  464. throw new Error("Public and/or system identifiers are required for an external entity");
  465. }
  466. if (value.pubID && !value.sysID) {
  467. throw new Error("System identifier is required for a public external entity");
  468. }
  469. if (value.pubID != null) {
  470. this.pubID = this.stringify.dtdPubID(value.pubID);
  471. }
  472. if (value.sysID != null) {
  473. this.sysID = this.stringify.dtdSysID(value.sysID);
  474. }
  475. if (value.nData != null) {
  476. this.nData = this.stringify.dtdNData(value.nData);
  477. }
  478. if (this.pe && this.nData) {
  479. throw new Error("Notation declaration is not allowed in a parameter entity");
  480. }
  481. }
  482. }
  483. XMLDTDEntity.prototype.toString = function(options) {
  484. return this.options.writer.set(options).dtdEntity(this);
  485. };
  486. return XMLDTDEntity;
  487. })(XMLNode);
  488. }).call(this);
  489. },{"./Utility":4,"./XMLNode":17}],11:[function(require,module,exports){
  490. // Generated by CoffeeScript 1.12.7
  491. (function() {
  492. var XMLDTDNotation, XMLNode,
  493. 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; },
  494. hasProp = {}.hasOwnProperty;
  495. XMLNode = require('./XMLNode');
  496. module.exports = XMLDTDNotation = (function(superClass) {
  497. extend(XMLDTDNotation, superClass);
  498. function XMLDTDNotation(parent, name, value) {
  499. XMLDTDNotation.__super__.constructor.call(this, parent);
  500. if (name == null) {
  501. throw new Error("Missing notation name");
  502. }
  503. if (!value.pubID && !value.sysID) {
  504. throw new Error("Public or system identifiers are required for an external entity");
  505. }
  506. this.name = this.stringify.eleName(name);
  507. if (value.pubID != null) {
  508. this.pubID = this.stringify.dtdPubID(value.pubID);
  509. }
  510. if (value.sysID != null) {
  511. this.sysID = this.stringify.dtdSysID(value.sysID);
  512. }
  513. }
  514. XMLDTDNotation.prototype.toString = function(options) {
  515. return this.options.writer.set(options).dtdNotation(this);
  516. };
  517. return XMLDTDNotation;
  518. })(XMLNode);
  519. }).call(this);
  520. },{"./XMLNode":17}],12:[function(require,module,exports){
  521. // Generated by CoffeeScript 1.12.7
  522. (function() {
  523. var XMLDeclaration, XMLNode, isObject,
  524. 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; },
  525. hasProp = {}.hasOwnProperty;
  526. isObject = require('./Utility').isObject;
  527. XMLNode = require('./XMLNode');
  528. module.exports = XMLDeclaration = (function(superClass) {
  529. extend(XMLDeclaration, superClass);
  530. function XMLDeclaration(parent, version, encoding, standalone) {
  531. var ref;
  532. XMLDeclaration.__super__.constructor.call(this, parent);
  533. if (isObject(version)) {
  534. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  535. }
  536. if (!version) {
  537. version = '1.0';
  538. }
  539. this.version = this.stringify.xmlVersion(version);
  540. if (encoding != null) {
  541. this.encoding = this.stringify.xmlEncoding(encoding);
  542. }
  543. if (standalone != null) {
  544. this.standalone = this.stringify.xmlStandalone(standalone);
  545. }
  546. }
  547. XMLDeclaration.prototype.toString = function(options) {
  548. return this.options.writer.set(options).declaration(this);
  549. };
  550. return XMLDeclaration;
  551. })(XMLNode);
  552. }).call(this);
  553. },{"./Utility":4,"./XMLNode":17}],13:[function(require,module,exports){
  554. // Generated by CoffeeScript 1.12.7
  555. (function() {
  556. var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject,
  557. 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; },
  558. hasProp = {}.hasOwnProperty;
  559. isObject = require('./Utility').isObject;
  560. XMLNode = require('./XMLNode');
  561. XMLDTDAttList = require('./XMLDTDAttList');
  562. XMLDTDEntity = require('./XMLDTDEntity');
  563. XMLDTDElement = require('./XMLDTDElement');
  564. XMLDTDNotation = require('./XMLDTDNotation');
  565. module.exports = XMLDocType = (function(superClass) {
  566. extend(XMLDocType, superClass);
  567. function XMLDocType(parent, pubID, sysID) {
  568. var ref, ref1;
  569. XMLDocType.__super__.constructor.call(this, parent);
  570. this.documentObject = parent;
  571. if (isObject(pubID)) {
  572. ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
  573. }
  574. if (sysID == null) {
  575. ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
  576. }
  577. if (pubID != null) {
  578. this.pubID = this.stringify.dtdPubID(pubID);
  579. }
  580. if (sysID != null) {
  581. this.sysID = this.stringify.dtdSysID(sysID);
  582. }
  583. }
  584. XMLDocType.prototype.element = function(name, value) {
  585. var child;
  586. child = new XMLDTDElement(this, name, value);
  587. this.children.push(child);
  588. return this;
  589. };
  590. XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  591. var child;
  592. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  593. this.children.push(child);
  594. return this;
  595. };
  596. XMLDocType.prototype.entity = function(name, value) {
  597. var child;
  598. child = new XMLDTDEntity(this, false, name, value);
  599. this.children.push(child);
  600. return this;
  601. };
  602. XMLDocType.prototype.pEntity = function(name, value) {
  603. var child;
  604. child = new XMLDTDEntity(this, true, name, value);
  605. this.children.push(child);
  606. return this;
  607. };
  608. XMLDocType.prototype.notation = function(name, value) {
  609. var child;
  610. child = new XMLDTDNotation(this, name, value);
  611. this.children.push(child);
  612. return this;
  613. };
  614. XMLDocType.prototype.toString = function(options) {
  615. return this.options.writer.set(options).docType(this);
  616. };
  617. XMLDocType.prototype.ele = function(name, value) {
  618. return this.element(name, value);
  619. };
  620. XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  621. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  622. };
  623. XMLDocType.prototype.ent = function(name, value) {
  624. return this.entity(name, value);
  625. };
  626. XMLDocType.prototype.pent = function(name, value) {
  627. return this.pEntity(name, value);
  628. };
  629. XMLDocType.prototype.not = function(name, value) {
  630. return this.notation(name, value);
  631. };
  632. XMLDocType.prototype.up = function() {
  633. return this.root() || this.documentObject;
  634. };
  635. return XMLDocType;
  636. })(XMLNode);
  637. }).call(this);
  638. },{"./Utility":4,"./XMLDTDAttList":8,"./XMLDTDElement":9,"./XMLDTDEntity":10,"./XMLDTDNotation":11,"./XMLNode":17}],14:[function(require,module,exports){
  639. // Generated by CoffeeScript 1.12.7
  640. (function() {
  641. var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
  642. 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; },
  643. hasProp = {}.hasOwnProperty;
  644. isPlainObject = require('./Utility').isPlainObject;
  645. XMLNode = require('./XMLNode');
  646. XMLStringifier = require('./XMLStringifier');
  647. XMLStringWriter = require('./XMLStringWriter');
  648. module.exports = XMLDocument = (function(superClass) {
  649. extend(XMLDocument, superClass);
  650. function XMLDocument(options) {
  651. XMLDocument.__super__.constructor.call(this, null);
  652. options || (options = {});
  653. if (!options.writer) {
  654. options.writer = new XMLStringWriter();
  655. }
  656. this.options = options;
  657. this.stringify = new XMLStringifier(options);
  658. this.isDocument = true;
  659. }
  660. XMLDocument.prototype.end = function(writer) {
  661. var writerOptions;
  662. if (!writer) {
  663. writer = this.options.writer;
  664. } else if (isPlainObject(writer)) {
  665. writerOptions = writer;
  666. writer = this.options.writer.set(writerOptions);
  667. }
  668. return writer.document(this);
  669. };
  670. XMLDocument.prototype.toString = function(options) {
  671. return this.options.writer.set(options).document(this);
  672. };
  673. return XMLDocument;
  674. })(XMLNode);
  675. }).call(this);
  676. },{"./Utility":4,"./XMLNode":17,"./XMLStringWriter":21,"./XMLStringifier":22}],15:[function(require,module,exports){
  677. // Generated by CoffeeScript 1.12.7
  678. (function() {
  679. var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
  680. hasProp = {}.hasOwnProperty;
  681. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
  682. XMLElement = require('./XMLElement');
  683. XMLCData = require('./XMLCData');
  684. XMLComment = require('./XMLComment');
  685. XMLRaw = require('./XMLRaw');
  686. XMLText = require('./XMLText');
  687. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  688. XMLDeclaration = require('./XMLDeclaration');
  689. XMLDocType = require('./XMLDocType');
  690. XMLDTDAttList = require('./XMLDTDAttList');
  691. XMLDTDEntity = require('./XMLDTDEntity');
  692. XMLDTDElement = require('./XMLDTDElement');
  693. XMLDTDNotation = require('./XMLDTDNotation');
  694. XMLAttribute = require('./XMLAttribute');
  695. XMLStringifier = require('./XMLStringifier');
  696. XMLStringWriter = require('./XMLStringWriter');
  697. module.exports = XMLDocumentCB = (function() {
  698. function XMLDocumentCB(options, onData, onEnd) {
  699. var writerOptions;
  700. options || (options = {});
  701. if (!options.writer) {
  702. options.writer = new XMLStringWriter(options);
  703. } else if (isPlainObject(options.writer)) {
  704. writerOptions = options.writer;
  705. options.writer = new XMLStringWriter(writerOptions);
  706. }
  707. this.options = options;
  708. this.writer = options.writer;
  709. this.stringify = new XMLStringifier(options);
  710. this.onDataCallback = onData || function() {};
  711. this.onEndCallback = onEnd || function() {};
  712. this.currentNode = null;
  713. this.currentLevel = -1;
  714. this.openTags = {};
  715. this.documentStarted = false;
  716. this.documentCompleted = false;
  717. this.root = null;
  718. }
  719. XMLDocumentCB.prototype.node = function(name, attributes, text) {
  720. var ref1;
  721. if (name == null) {
  722. throw new Error("Missing node name");
  723. }
  724. if (this.root && this.currentLevel === -1) {
  725. throw new Error("Document can only have one root node");
  726. }
  727. this.openCurrent();
  728. name = name.valueOf();
  729. if (attributes == null) {
  730. attributes = {};
  731. }
  732. attributes = attributes.valueOf();
  733. if (!isObject(attributes)) {
  734. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  735. }
  736. this.currentNode = new XMLElement(this, name, attributes);
  737. this.currentNode.children = false;
  738. this.currentLevel++;
  739. this.openTags[this.currentLevel] = this.currentNode;
  740. if (text != null) {
  741. this.text(text);
  742. }
  743. return this;
  744. };
  745. XMLDocumentCB.prototype.element = function(name, attributes, text) {
  746. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  747. return this.dtdElement.apply(this, arguments);
  748. } else {
  749. return this.node(name, attributes, text);
  750. }
  751. };
  752. XMLDocumentCB.prototype.attribute = function(name, value) {
  753. var attName, attValue;
  754. if (!this.currentNode || this.currentNode.children) {
  755. throw new Error("att() can only be used immediately after an ele() call in callback mode");
  756. }
  757. if (name != null) {
  758. name = name.valueOf();
  759. }
  760. if (isObject(name)) {
  761. for (attName in name) {
  762. if (!hasProp.call(name, attName)) continue;
  763. attValue = name[attName];
  764. this.attribute(attName, attValue);
  765. }
  766. } else {
  767. if (isFunction(value)) {
  768. value = value.apply();
  769. }
  770. if (!this.options.skipNullAttributes || (value != null)) {
  771. this.currentNode.attributes[name] = new XMLAttribute(this, name, value);
  772. }
  773. }
  774. return this;
  775. };
  776. XMLDocumentCB.prototype.text = function(value) {
  777. var node;
  778. this.openCurrent();
  779. node = new XMLText(this, value);
  780. this.onData(this.writer.text(node, this.currentLevel + 1));
  781. return this;
  782. };
  783. XMLDocumentCB.prototype.cdata = function(value) {
  784. var node;
  785. this.openCurrent();
  786. node = new XMLCData(this, value);
  787. this.onData(this.writer.cdata(node, this.currentLevel + 1));
  788. return this;
  789. };
  790. XMLDocumentCB.prototype.comment = function(value) {
  791. var node;
  792. this.openCurrent();
  793. node = new XMLComment(this, value);
  794. this.onData(this.writer.comment(node, this.currentLevel + 1));
  795. return this;
  796. };
  797. XMLDocumentCB.prototype.raw = function(value) {
  798. var node;
  799. this.openCurrent();
  800. node = new XMLRaw(this, value);
  801. this.onData(this.writer.raw(node, this.currentLevel + 1));
  802. return this;
  803. };
  804. XMLDocumentCB.prototype.instruction = function(target, value) {
  805. var i, insTarget, insValue, len, node;
  806. this.openCurrent();
  807. if (target != null) {
  808. target = target.valueOf();
  809. }
  810. if (value != null) {
  811. value = value.valueOf();
  812. }
  813. if (Array.isArray(target)) {
  814. for (i = 0, len = target.length; i < len; i++) {
  815. insTarget = target[i];
  816. this.instruction(insTarget);
  817. }
  818. } else if (isObject(target)) {
  819. for (insTarget in target) {
  820. if (!hasProp.call(target, insTarget)) continue;
  821. insValue = target[insTarget];
  822. this.instruction(insTarget, insValue);
  823. }
  824. } else {
  825. if (isFunction(value)) {
  826. value = value.apply();
  827. }
  828. node = new XMLProcessingInstruction(this, target, value);
  829. this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
  830. }
  831. return this;
  832. };
  833. XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
  834. var node;
  835. this.openCurrent();
  836. if (this.documentStarted) {
  837. throw new Error("declaration() must be the first node");
  838. }
  839. node = new XMLDeclaration(this, version, encoding, standalone);
  840. this.onData(this.writer.declaration(node, this.currentLevel + 1));
  841. return this;
  842. };
  843. XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
  844. this.openCurrent();
  845. if (root == null) {
  846. throw new Error("Missing root node name");
  847. }
  848. if (this.root) {
  849. throw new Error("dtd() must come before the root node");
  850. }
  851. this.currentNode = new XMLDocType(this, pubID, sysID);
  852. this.currentNode.rootNodeName = root;
  853. this.currentNode.children = false;
  854. this.currentLevel++;
  855. this.openTags[this.currentLevel] = this.currentNode;
  856. return this;
  857. };
  858. XMLDocumentCB.prototype.dtdElement = function(name, value) {
  859. var node;
  860. this.openCurrent();
  861. node = new XMLDTDElement(this, name, value);
  862. this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
  863. return this;
  864. };
  865. XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  866. var node;
  867. this.openCurrent();
  868. node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  869. this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
  870. return this;
  871. };
  872. XMLDocumentCB.prototype.entity = function(name, value) {
  873. var node;
  874. this.openCurrent();
  875. node = new XMLDTDEntity(this, false, name, value);
  876. this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
  877. return this;
  878. };
  879. XMLDocumentCB.prototype.pEntity = function(name, value) {
  880. var node;
  881. this.openCurrent();
  882. node = new XMLDTDEntity(this, true, name, value);
  883. this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
  884. return this;
  885. };
  886. XMLDocumentCB.prototype.notation = function(name, value) {
  887. var node;
  888. this.openCurrent();
  889. node = new XMLDTDNotation(this, name, value);
  890. this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
  891. return this;
  892. };
  893. XMLDocumentCB.prototype.up = function() {
  894. if (this.currentLevel < 0) {
  895. throw new Error("The document node has no parent");
  896. }
  897. if (this.currentNode) {
  898. if (this.currentNode.children) {
  899. this.closeNode(this.currentNode);
  900. } else {
  901. this.openNode(this.currentNode);
  902. }
  903. this.currentNode = null;
  904. } else {
  905. this.closeNode(this.openTags[this.currentLevel]);
  906. }
  907. delete this.openTags[this.currentLevel];
  908. this.currentLevel--;
  909. return this;
  910. };
  911. XMLDocumentCB.prototype.end = function() {
  912. while (this.currentLevel >= 0) {
  913. this.up();
  914. }
  915. return this.onEnd();
  916. };
  917. XMLDocumentCB.prototype.openCurrent = function() {
  918. if (this.currentNode) {
  919. this.currentNode.children = true;
  920. return this.openNode(this.currentNode);
  921. }
  922. };
  923. XMLDocumentCB.prototype.openNode = function(node) {
  924. if (!node.isOpen) {
  925. if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
  926. this.root = node;
  927. }
  928. this.onData(this.writer.openNode(node, this.currentLevel));
  929. return node.isOpen = true;
  930. }
  931. };
  932. XMLDocumentCB.prototype.closeNode = function(node) {
  933. if (!node.isClosed) {
  934. this.onData(this.writer.closeNode(node, this.currentLevel));
  935. return node.isClosed = true;
  936. }
  937. };
  938. XMLDocumentCB.prototype.onData = function(chunk) {
  939. this.documentStarted = true;
  940. return this.onDataCallback(chunk);
  941. };
  942. XMLDocumentCB.prototype.onEnd = function() {
  943. this.documentCompleted = true;
  944. return this.onEndCallback();
  945. };
  946. XMLDocumentCB.prototype.ele = function() {
  947. return this.element.apply(this, arguments);
  948. };
  949. XMLDocumentCB.prototype.nod = function(name, attributes, text) {
  950. return this.node(name, attributes, text);
  951. };
  952. XMLDocumentCB.prototype.txt = function(value) {
  953. return this.text(value);
  954. };
  955. XMLDocumentCB.prototype.dat = function(value) {
  956. return this.cdata(value);
  957. };
  958. XMLDocumentCB.prototype.com = function(value) {
  959. return this.comment(value);
  960. };
  961. XMLDocumentCB.prototype.ins = function(target, value) {
  962. return this.instruction(target, value);
  963. };
  964. XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
  965. return this.declaration(version, encoding, standalone);
  966. };
  967. XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
  968. return this.doctype(root, pubID, sysID);
  969. };
  970. XMLDocumentCB.prototype.e = function(name, attributes, text) {
  971. return this.element(name, attributes, text);
  972. };
  973. XMLDocumentCB.prototype.n = function(name, attributes, text) {
  974. return this.node(name, attributes, text);
  975. };
  976. XMLDocumentCB.prototype.t = function(value) {
  977. return this.text(value);
  978. };
  979. XMLDocumentCB.prototype.d = function(value) {
  980. return this.cdata(value);
  981. };
  982. XMLDocumentCB.prototype.c = function(value) {
  983. return this.comment(value);
  984. };
  985. XMLDocumentCB.prototype.r = function(value) {
  986. return this.raw(value);
  987. };
  988. XMLDocumentCB.prototype.i = function(target, value) {
  989. return this.instruction(target, value);
  990. };
  991. XMLDocumentCB.prototype.att = function() {
  992. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  993. return this.attList.apply(this, arguments);
  994. } else {
  995. return this.attribute.apply(this, arguments);
  996. }
  997. };
  998. XMLDocumentCB.prototype.a = function() {
  999. if (this.currentNode && this.currentNode instanceof XMLDocType) {
  1000. return this.attList.apply(this, arguments);
  1001. } else {
  1002. return this.attribute.apply(this, arguments);
  1003. }
  1004. };
  1005. XMLDocumentCB.prototype.ent = function(name, value) {
  1006. return this.entity(name, value);
  1007. };
  1008. XMLDocumentCB.prototype.pent = function(name, value) {
  1009. return this.pEntity(name, value);
  1010. };
  1011. XMLDocumentCB.prototype.not = function(name, value) {
  1012. return this.notation(name, value);
  1013. };
  1014. return XMLDocumentCB;
  1015. })();
  1016. }).call(this);
  1017. },{"./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){
  1018. // Generated by CoffeeScript 1.12.7
  1019. (function() {
  1020. var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
  1021. 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; },
  1022. hasProp = {}.hasOwnProperty;
  1023. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
  1024. XMLNode = require('./XMLNode');
  1025. XMLAttribute = require('./XMLAttribute');
  1026. module.exports = XMLElement = (function(superClass) {
  1027. extend(XMLElement, superClass);
  1028. function XMLElement(parent, name, attributes) {
  1029. XMLElement.__super__.constructor.call(this, parent);
  1030. if (name == null) {
  1031. throw new Error("Missing element name");
  1032. }
  1033. this.name = this.stringify.eleName(name);
  1034. this.attributes = {};
  1035. if (attributes != null) {
  1036. this.attribute(attributes);
  1037. }
  1038. if (parent.isDocument) {
  1039. this.isRoot = true;
  1040. this.documentObject = parent;
  1041. parent.rootObject = this;
  1042. }
  1043. }
  1044. XMLElement.prototype.clone = function() {
  1045. var att, attName, clonedSelf, ref1;
  1046. clonedSelf = Object.create(this);
  1047. if (clonedSelf.isRoot) {
  1048. clonedSelf.documentObject = null;
  1049. }
  1050. clonedSelf.attributes = {};
  1051. ref1 = this.attributes;
  1052. for (attName in ref1) {
  1053. if (!hasProp.call(ref1, attName)) continue;
  1054. att = ref1[attName];
  1055. clonedSelf.attributes[attName] = att.clone();
  1056. }
  1057. clonedSelf.children = [];
  1058. this.children.forEach(function(child) {
  1059. var clonedChild;
  1060. clonedChild = child.clone();
  1061. clonedChild.parent = clonedSelf;
  1062. return clonedSelf.children.push(clonedChild);
  1063. });
  1064. return clonedSelf;
  1065. };
  1066. XMLElement.prototype.attribute = function(name, value) {
  1067. var attName, attValue;
  1068. if (name != null) {
  1069. name = name.valueOf();
  1070. }
  1071. if (isObject(name)) {
  1072. for (attName in name) {
  1073. if (!hasProp.call(name, attName)) continue;
  1074. attValue = name[attName];
  1075. this.attribute(attName, attValue);
  1076. }
  1077. } else {
  1078. if (isFunction(value)) {
  1079. value = value.apply();
  1080. }
  1081. if (!this.options.skipNullAttributes || (value != null)) {
  1082. this.attributes[name] = new XMLAttribute(this, name, value);
  1083. }
  1084. }
  1085. return this;
  1086. };
  1087. XMLElement.prototype.removeAttribute = function(name) {
  1088. var attName, i, len;
  1089. if (name == null) {
  1090. throw new Error("Missing attribute name");
  1091. }
  1092. name = name.valueOf();
  1093. if (Array.isArray(name)) {
  1094. for (i = 0, len = name.length; i < len; i++) {
  1095. attName = name[i];
  1096. delete this.attributes[attName];
  1097. }
  1098. } else {
  1099. delete this.attributes[name];
  1100. }
  1101. return this;
  1102. };
  1103. XMLElement.prototype.toString = function(options) {
  1104. return this.options.writer.set(options).element(this);
  1105. };
  1106. XMLElement.prototype.att = function(name, value) {
  1107. return this.attribute(name, value);
  1108. };
  1109. XMLElement.prototype.a = function(name, value) {
  1110. return this.attribute(name, value);
  1111. };
  1112. return XMLElement;
  1113. })(XMLNode);
  1114. }).call(this);
  1115. },{"./Utility":4,"./XMLAttribute":5,"./XMLNode":17}],17:[function(require,module,exports){
  1116. // Generated by CoffeeScript 1.12.7
  1117. (function() {
  1118. var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
  1119. hasProp = {}.hasOwnProperty;
  1120. ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
  1121. XMLElement = null;
  1122. XMLCData = null;
  1123. XMLComment = null;
  1124. XMLDeclaration = null;
  1125. XMLDocType = null;
  1126. XMLRaw = null;
  1127. XMLText = null;
  1128. XMLProcessingInstruction = null;
  1129. module.exports = XMLNode = (function() {
  1130. function XMLNode(parent) {
  1131. this.parent = parent;
  1132. if (this.parent) {
  1133. this.options = this.parent.options;
  1134. this.stringify = this.parent.stringify;
  1135. }
  1136. this.children = [];
  1137. if (!XMLElement) {
  1138. XMLElement = require('./XMLElement');
  1139. XMLCData = require('./XMLCData');
  1140. XMLComment = require('./XMLComment');
  1141. XMLDeclaration = require('./XMLDeclaration');
  1142. XMLDocType = require('./XMLDocType');
  1143. XMLRaw = require('./XMLRaw');
  1144. XMLText = require('./XMLText');
  1145. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  1146. }
  1147. }
  1148. XMLNode.prototype.element = function(name, attributes, text) {
  1149. var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
  1150. lastChild = null;
  1151. if (attributes == null) {
  1152. attributes = {};
  1153. }
  1154. attributes = attributes.valueOf();
  1155. if (!isObject(attributes)) {
  1156. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  1157. }
  1158. if (name != null) {
  1159. name = name.valueOf();
  1160. }
  1161. if (Array.isArray(name)) {
  1162. for (j = 0, len = name.length; j < len; j++) {
  1163. item = name[j];
  1164. lastChild = this.element(item);
  1165. }
  1166. } else if (isFunction(name)) {
  1167. lastChild = this.element(name.apply());
  1168. } else if (isObject(name)) {
  1169. for (key in name) {
  1170. if (!hasProp.call(name, key)) continue;
  1171. val = name[key];
  1172. if (isFunction(val)) {
  1173. val = val.apply();
  1174. }
  1175. if ((isObject(val)) && (isEmpty(val))) {
  1176. val = null;
  1177. }
  1178. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  1179. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  1180. } else if (!this.options.separateArrayItems && Array.isArray(val)) {
  1181. for (k = 0, len1 = val.length; k < len1; k++) {
  1182. item = val[k];
  1183. childNode = {};
  1184. childNode[key] = item;
  1185. lastChild = this.element(childNode);
  1186. }
  1187. } else if (isObject(val)) {
  1188. lastChild = this.element(key);
  1189. lastChild.element(val);
  1190. } else {
  1191. lastChild = this.element(key, val);
  1192. }
  1193. }
  1194. } else {
  1195. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  1196. lastChild = this.text(text);
  1197. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  1198. lastChild = this.cdata(text);
  1199. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  1200. lastChild = this.comment(text);
  1201. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  1202. lastChild = this.raw(text);
  1203. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
  1204. lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
  1205. } else {
  1206. lastChild = this.node(name, attributes, text);
  1207. }
  1208. }
  1209. if (lastChild == null) {
  1210. throw new Error("Could not create any elements with: " + name);
  1211. }
  1212. return lastChild;
  1213. };
  1214. XMLNode.prototype.insertBefore = function(name, attributes, text) {
  1215. var child, i, removed;
  1216. if (this.isRoot) {
  1217. throw new Error("Cannot insert elements at root level");
  1218. }
  1219. i = this.parent.children.indexOf(this);
  1220. removed = this.parent.children.splice(i);
  1221. child = this.parent.element(name, attributes, text);
  1222. Array.prototype.push.apply(this.parent.children, removed);
  1223. return child;
  1224. };
  1225. XMLNode.prototype.insertAfter = function(name, attributes, text) {
  1226. var child, i, removed;
  1227. if (this.isRoot) {
  1228. throw new Error("Cannot insert elements at root level");
  1229. }
  1230. i = this.parent.children.indexOf(this);
  1231. removed = this.parent.children.splice(i + 1);
  1232. child = this.parent.element(name, attributes, text);
  1233. Array.prototype.push.apply(this.parent.children, removed);
  1234. return child;
  1235. };
  1236. XMLNode.prototype.remove = function() {
  1237. var i, ref1;
  1238. if (this.isRoot) {
  1239. throw new Error("Cannot remove the root element");
  1240. }
  1241. i = this.parent.children.indexOf(this);
  1242. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
  1243. return this.parent;
  1244. };
  1245. XMLNode.prototype.node = function(name, attributes, text) {
  1246. var child, ref1;
  1247. if (name != null) {
  1248. name = name.valueOf();
  1249. }
  1250. attributes || (attributes = {});
  1251. attributes = attributes.valueOf();
  1252. if (!isObject(attributes)) {
  1253. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  1254. }
  1255. child = new XMLElement(this, name, attributes);
  1256. if (text != null) {
  1257. child.text(text);
  1258. }
  1259. this.children.push(child);
  1260. return child;
  1261. };
  1262. XMLNode.prototype.text = function(value) {
  1263. var child;
  1264. child = new XMLText(this, value);
  1265. this.children.push(child);
  1266. return this;
  1267. };
  1268. XMLNode.prototype.cdata = function(value) {
  1269. var child;
  1270. child = new XMLCData(this, value);
  1271. this.children.push(child);
  1272. return this;
  1273. };
  1274. XMLNode.prototype.comment = function(value) {
  1275. var child;
  1276. child = new XMLComment(this, value);
  1277. this.children.push(child);
  1278. return this;
  1279. };
  1280. XMLNode.prototype.commentBefore = function(value) {
  1281. var child, i, removed;
  1282. i = this.parent.children.indexOf(this);
  1283. removed = this.parent.children.splice(i);
  1284. child = this.parent.comment(value);
  1285. Array.prototype.push.apply(this.parent.children, removed);
  1286. return this;
  1287. };
  1288. XMLNode.prototype.commentAfter = function(value) {
  1289. var child, i, removed;
  1290. i = this.parent.children.indexOf(this);
  1291. removed = this.parent.children.splice(i + 1);
  1292. child = this.parent.comment(value);
  1293. Array.prototype.push.apply(this.parent.children, removed);
  1294. return this;
  1295. };
  1296. XMLNode.prototype.raw = function(value) {
  1297. var child;
  1298. child = new XMLRaw(this, value);
  1299. this.children.push(child);
  1300. return this;
  1301. };
  1302. XMLNode.prototype.instruction = function(target, value) {
  1303. var insTarget, insValue, instruction, j, len;
  1304. if (target != null) {
  1305. target = target.valueOf();
  1306. }
  1307. if (value != null) {
  1308. value = value.valueOf();
  1309. }
  1310. if (Array.isArray(target)) {
  1311. for (j = 0, len = target.length; j < len; j++) {
  1312. insTarget = target[j];
  1313. this.instruction(insTarget);
  1314. }
  1315. } else if (isObject(target)) {
  1316. for (insTarget in target) {
  1317. if (!hasProp.call(target, insTarget)) continue;
  1318. insValue = target[insTarget];
  1319. this.instruction(insTarget, insValue);
  1320. }
  1321. } else {
  1322. if (isFunction(value)) {
  1323. value = value.apply();
  1324. }
  1325. instruction = new XMLProcessingInstruction(this, target, value);
  1326. this.children.push(instruction);
  1327. }
  1328. return this;
  1329. };
  1330. XMLNode.prototype.instructionBefore = function(target, value) {
  1331. var child, i, removed;
  1332. i = this.parent.children.indexOf(this);
  1333. removed = this.parent.children.splice(i);
  1334. child = this.parent.instruction(target, value);
  1335. Array.prototype.push.apply(this.parent.children, removed);
  1336. return this;
  1337. };
  1338. XMLNode.prototype.instructionAfter = function(target, value) {
  1339. var child, i, removed;
  1340. i = this.parent.children.indexOf(this);
  1341. removed = this.parent.children.splice(i + 1);
  1342. child = this.parent.instruction(target, value);
  1343. Array.prototype.push.apply(this.parent.children, removed);
  1344. return this;
  1345. };
  1346. XMLNode.prototype.declaration = function(version, encoding, standalone) {
  1347. var doc, xmldec;
  1348. doc = this.document();
  1349. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  1350. if (doc.children[0] instanceof XMLDeclaration) {
  1351. doc.children[0] = xmldec;
  1352. } else {
  1353. doc.children.unshift(xmldec);
  1354. }
  1355. return doc.root() || doc;
  1356. };
  1357. XMLNode.prototype.doctype = function(pubID, sysID) {
  1358. var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
  1359. doc = this.document();
  1360. doctype = new XMLDocType(doc, pubID, sysID);
  1361. ref1 = doc.children;
  1362. for (i = j = 0, len = ref1.length; j < len; i = ++j) {
  1363. child = ref1[i];
  1364. if (child instanceof XMLDocType) {
  1365. doc.children[i] = doctype;
  1366. return doctype;
  1367. }
  1368. }
  1369. ref2 = doc.children;
  1370. for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
  1371. child = ref2[i];
  1372. if (child.isRoot) {
  1373. doc.children.splice(i, 0, doctype);
  1374. return doctype;
  1375. }
  1376. }
  1377. doc.children.push(doctype);
  1378. return doctype;
  1379. };
  1380. XMLNode.prototype.up = function() {
  1381. if (this.isRoot) {
  1382. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  1383. }
  1384. return this.parent;
  1385. };
  1386. XMLNode.prototype.root = function() {
  1387. var node;
  1388. node = this;
  1389. while (node) {
  1390. if (node.isDocument) {
  1391. return node.rootObject;
  1392. } else if (node.isRoot) {
  1393. return node;
  1394. } else {
  1395. node = node.parent;
  1396. }
  1397. }
  1398. };
  1399. XMLNode.prototype.document = function() {
  1400. var node;
  1401. node = this;
  1402. while (node) {
  1403. if (node.isDocument) {
  1404. return node;
  1405. } else {
  1406. node = node.parent;
  1407. }
  1408. }
  1409. };
  1410. XMLNode.prototype.end = function(options) {
  1411. return this.document().end(options);
  1412. };
  1413. XMLNode.prototype.prev = function() {
  1414. var i;
  1415. i = this.parent.children.indexOf(this);
  1416. if (i < 1) {
  1417. throw new Error("Already at the first node");
  1418. }
  1419. return this.parent.children[i - 1];
  1420. };
  1421. XMLNode.prototype.next = function() {
  1422. var i;
  1423. i = this.parent.children.indexOf(this);
  1424. if (i === -1 || i === this.parent.children.length - 1) {
  1425. throw new Error("Already at the last node");
  1426. }
  1427. return this.parent.children[i + 1];
  1428. };
  1429. XMLNode.prototype.importDocument = function(doc) {
  1430. var clonedRoot;
  1431. clonedRoot = doc.root().clone();
  1432. clonedRoot.parent = this;
  1433. clonedRoot.isRoot = false;
  1434. this.children.push(clonedRoot);
  1435. return this;
  1436. };
  1437. XMLNode.prototype.ele = function(name, attributes, text) {
  1438. return this.element(name, attributes, text);
  1439. };
  1440. XMLNode.prototype.nod = function(name, attributes, text) {
  1441. return this.node(name, attributes, text);
  1442. };
  1443. XMLNode.prototype.txt = function(value) {
  1444. return this.text(value);
  1445. };
  1446. XMLNode.prototype.dat = function(value) {
  1447. return this.cdata(value);
  1448. };
  1449. XMLNode.prototype.com = function(value) {
  1450. return this.comment(value);
  1451. };
  1452. XMLNode.prototype.ins = function(target, value) {
  1453. return this.instruction(target, value);
  1454. };
  1455. XMLNode.prototype.doc = function() {
  1456. return this.document();
  1457. };
  1458. XMLNode.prototype.dec = function(version, encoding, standalone) {
  1459. return this.declaration(version, encoding, standalone);
  1460. };
  1461. XMLNode.prototype.dtd = function(pubID, sysID) {
  1462. return this.doctype(pubID, sysID);
  1463. };
  1464. XMLNode.prototype.e = function(name, attributes, text) {
  1465. return this.element(name, attributes, text);
  1466. };
  1467. XMLNode.prototype.n = function(name, attributes, text) {
  1468. return this.node(name, attributes, text);
  1469. };
  1470. XMLNode.prototype.t = function(value) {
  1471. return this.text(value);
  1472. };
  1473. XMLNode.prototype.d = function(value) {
  1474. return this.cdata(value);
  1475. };
  1476. XMLNode.prototype.c = function(value) {
  1477. return this.comment(value);
  1478. };
  1479. XMLNode.prototype.r = function(value) {
  1480. return this.raw(value);
  1481. };
  1482. XMLNode.prototype.i = function(target, value) {
  1483. return this.instruction(target, value);
  1484. };
  1485. XMLNode.prototype.u = function() {
  1486. return this.up();
  1487. };
  1488. XMLNode.prototype.importXMLBuilder = function(doc) {
  1489. return this.importDocument(doc);
  1490. };
  1491. return XMLNode;
  1492. })();
  1493. }).call(this);
  1494. },{"./Utility":4,"./XMLCData":6,"./XMLComment":7,"./XMLDeclaration":12,"./XMLDocType":13,"./XMLElement":16,"./XMLProcessingInstruction":18,"./XMLRaw":19,"./XMLText":23}],18:[function(require,module,exports){
  1495. // Generated by CoffeeScript 1.12.7
  1496. (function() {
  1497. var XMLNode, XMLProcessingInstruction,
  1498. 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; },
  1499. hasProp = {}.hasOwnProperty;
  1500. XMLNode = require('./XMLNode');
  1501. module.exports = XMLProcessingInstruction = (function(superClass) {
  1502. extend(XMLProcessingInstruction, superClass);
  1503. function XMLProcessingInstruction(parent, target, value) {
  1504. XMLProcessingInstruction.__super__.constructor.call(this, parent);
  1505. if (target == null) {
  1506. throw new Error("Missing instruction target");
  1507. }
  1508. this.target = this.stringify.insTarget(target);
  1509. if (value) {
  1510. this.value = this.stringify.insValue(value);
  1511. }
  1512. }
  1513. XMLProcessingInstruction.prototype.clone = function() {
  1514. return Object.create(this);
  1515. };
  1516. XMLProcessingInstruction.prototype.toString = function(options) {
  1517. return this.options.writer.set(options).processingInstruction(this);
  1518. };
  1519. return XMLProcessingInstruction;
  1520. })(XMLNode);
  1521. }).call(this);
  1522. },{"./XMLNode":17}],19:[function(require,module,exports){
  1523. // Generated by CoffeeScript 1.12.7
  1524. (function() {
  1525. var XMLNode, XMLRaw,
  1526. 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; },
  1527. hasProp = {}.hasOwnProperty;
  1528. XMLNode = require('./XMLNode');
  1529. module.exports = XMLRaw = (function(superClass) {
  1530. extend(XMLRaw, superClass);
  1531. function XMLRaw(parent, text) {
  1532. XMLRaw.__super__.constructor.call(this, parent);
  1533. if (text == null) {
  1534. throw new Error("Missing raw text");
  1535. }
  1536. this.value = this.stringify.raw(text);
  1537. }
  1538. XMLRaw.prototype.clone = function() {
  1539. return Object.create(this);
  1540. };
  1541. XMLRaw.prototype.toString = function(options) {
  1542. return this.options.writer.set(options).raw(this);
  1543. };
  1544. return XMLRaw;
  1545. })(XMLNode);
  1546. }).call(this);
  1547. },{"./XMLNode":17}],20:[function(require,module,exports){
  1548. // Generated by CoffeeScript 1.12.7
  1549. (function() {
  1550. var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
  1551. 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; },
  1552. hasProp = {}.hasOwnProperty;
  1553. XMLDeclaration = require('./XMLDeclaration');
  1554. XMLDocType = require('./XMLDocType');
  1555. XMLCData = require('./XMLCData');
  1556. XMLComment = require('./XMLComment');
  1557. XMLElement = require('./XMLElement');
  1558. XMLRaw = require('./XMLRaw');
  1559. XMLText = require('./XMLText');
  1560. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  1561. XMLDTDAttList = require('./XMLDTDAttList');
  1562. XMLDTDElement = require('./XMLDTDElement');
  1563. XMLDTDEntity = require('./XMLDTDEntity');
  1564. XMLDTDNotation = require('./XMLDTDNotation');
  1565. XMLWriterBase = require('./XMLWriterBase');
  1566. module.exports = XMLStreamWriter = (function(superClass) {
  1567. extend(XMLStreamWriter, superClass);
  1568. function XMLStreamWriter(stream, options) {
  1569. XMLStreamWriter.__super__.constructor.call(this, options);
  1570. this.stream = stream;
  1571. }
  1572. XMLStreamWriter.prototype.document = function(doc) {
  1573. var child, i, j, len, len1, ref, ref1, results;
  1574. ref = doc.children;
  1575. for (i = 0, len = ref.length; i < len; i++) {
  1576. child = ref[i];
  1577. child.isLastRootNode = false;
  1578. }
  1579. doc.children[doc.children.length - 1].isLastRootNode = true;
  1580. ref1 = doc.children;
  1581. results = [];
  1582. for (j = 0, len1 = ref1.length; j < len1; j++) {
  1583. child = ref1[j];
  1584. switch (false) {
  1585. case !(child instanceof XMLDeclaration):
  1586. results.push(this.declaration(child));
  1587. break;
  1588. case !(child instanceof XMLDocType):
  1589. results.push(this.docType(child));
  1590. break;
  1591. case !(child instanceof XMLComment):
  1592. results.push(this.comment(child));
  1593. break;
  1594. case !(child instanceof XMLProcessingInstruction):
  1595. results.push(this.processingInstruction(child));
  1596. break;
  1597. default:
  1598. results.push(this.element(child));
  1599. }
  1600. }
  1601. return results;
  1602. };
  1603. XMLStreamWriter.prototype.attribute = function(att) {
  1604. return this.stream.write(' ' + att.name + '="' + att.value + '"');
  1605. };
  1606. XMLStreamWriter.prototype.cdata = function(node, level) {
  1607. return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
  1608. };
  1609. XMLStreamWriter.prototype.comment = function(node, level) {
  1610. return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
  1611. };
  1612. XMLStreamWriter.prototype.declaration = function(node, level) {
  1613. this.stream.write(this.space(level));
  1614. this.stream.write('<?xml version="' + node.version + '"');
  1615. if (node.encoding != null) {
  1616. this.stream.write(' encoding="' + node.encoding + '"');
  1617. }
  1618. if (node.standalone != null) {
  1619. this.stream.write(' standalone="' + node.standalone + '"');
  1620. }
  1621. this.stream.write(this.spacebeforeslash + '?>');
  1622. return this.stream.write(this.endline(node));
  1623. };
  1624. XMLStreamWriter.prototype.docType = function(node, level) {
  1625. var child, i, len, ref;
  1626. level || (level = 0);
  1627. this.stream.write(this.space(level));
  1628. this.stream.write('<!DOCTYPE ' + node.root().name);
  1629. if (node.pubID && node.sysID) {
  1630. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  1631. } else if (node.sysID) {
  1632. this.stream.write(' SYSTEM "' + node.sysID + '"');
  1633. }
  1634. if (node.children.length > 0) {
  1635. this.stream.write(' [');
  1636. this.stream.write(this.endline(node));
  1637. ref = node.children;
  1638. for (i = 0, len = ref.length; i < len; i++) {
  1639. child = ref[i];
  1640. switch (false) {
  1641. case !(child instanceof XMLDTDAttList):
  1642. this.dtdAttList(child, level + 1);
  1643. break;
  1644. case !(child instanceof XMLDTDElement):
  1645. this.dtdElement(child, level + 1);
  1646. break;
  1647. case !(child instanceof XMLDTDEntity):
  1648. this.dtdEntity(child, level + 1);
  1649. break;
  1650. case !(child instanceof XMLDTDNotation):
  1651. this.dtdNotation(child, level + 1);
  1652. break;
  1653. case !(child instanceof XMLCData):
  1654. this.cdata(child, level + 1);
  1655. break;
  1656. case !(child instanceof XMLComment):
  1657. this.comment(child, level + 1);
  1658. break;
  1659. case !(child instanceof XMLProcessingInstruction):
  1660. this.processingInstruction(child, level + 1);
  1661. break;
  1662. default:
  1663. throw new Error("Unknown DTD node type: " + child.constructor.name);
  1664. }
  1665. }
  1666. this.stream.write(']');
  1667. }
  1668. this.stream.write(this.spacebeforeslash + '>');
  1669. return this.stream.write(this.endline(node));
  1670. };
  1671. XMLStreamWriter.prototype.element = function(node, level) {
  1672. var att, child, i, len, name, ref, ref1, space;
  1673. level || (level = 0);
  1674. space = this.space(level);
  1675. this.stream.write(space + '<' + node.name);
  1676. ref = node.attributes;
  1677. for (name in ref) {
  1678. if (!hasProp.call(ref, name)) continue;
  1679. att = ref[name];
  1680. this.attribute(att);
  1681. }
  1682. if (node.children.length === 0 || node.children.every(function(e) {
  1683. return e.value === '';
  1684. })) {
  1685. if (this.allowEmpty) {
  1686. this.stream.write('></' + node.name + '>');
  1687. } else {
  1688. this.stream.write(this.spacebeforeslash + '/>');
  1689. }
  1690. } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
  1691. this.stream.write('>');
  1692. this.stream.write(node.children[0].value);
  1693. this.stream.write('</' + node.name + '>');
  1694. } else {
  1695. this.stream.write('>' + this.newline);
  1696. ref1 = node.children;
  1697. for (i = 0, len = ref1.length; i < len; i++) {
  1698. child = ref1[i];
  1699. switch (false) {
  1700. case !(child instanceof XMLCData):
  1701. this.cdata(child, level + 1);
  1702. break;
  1703. case !(child instanceof XMLComment):
  1704. this.comment(child, level + 1);
  1705. break;
  1706. case !(child instanceof XMLElement):
  1707. this.element(child, level + 1);
  1708. break;
  1709. case !(child instanceof XMLRaw):
  1710. this.raw(child, level + 1);
  1711. break;
  1712. case !(child instanceof XMLText):
  1713. this.text(child, level + 1);
  1714. break;
  1715. case !(child instanceof XMLProcessingInstruction):
  1716. this.processingInstruction(child, level + 1);
  1717. break;
  1718. default:
  1719. throw new Error("Unknown XML node type: " + child.constructor.name);
  1720. }
  1721. }
  1722. this.stream.write(space + '</' + node.name + '>');
  1723. }
  1724. return this.stream.write(this.endline(node));
  1725. };
  1726. XMLStreamWriter.prototype.processingInstruction = function(node, level) {
  1727. this.stream.write(this.space(level) + '<?' + node.target);
  1728. if (node.value) {
  1729. this.stream.write(' ' + node.value);
  1730. }
  1731. return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
  1732. };
  1733. XMLStreamWriter.prototype.raw = function(node, level) {
  1734. return this.stream.write(this.space(level) + node.value + this.endline(node));
  1735. };
  1736. XMLStreamWriter.prototype.text = function(node, level) {
  1737. return this.stream.write(this.space(level) + node.value + this.endline(node));
  1738. };
  1739. XMLStreamWriter.prototype.dtdAttList = function(node, level) {
  1740. this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
  1741. if (node.defaultValueType !== '#DEFAULT') {
  1742. this.stream.write(' ' + node.defaultValueType);
  1743. }
  1744. if (node.defaultValue) {
  1745. this.stream.write(' "' + node.defaultValue + '"');
  1746. }
  1747. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  1748. };
  1749. XMLStreamWriter.prototype.dtdElement = function(node, level) {
  1750. this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
  1751. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  1752. };
  1753. XMLStreamWriter.prototype.dtdEntity = function(node, level) {
  1754. this.stream.write(this.space(level) + '<!ENTITY');
  1755. if (node.pe) {
  1756. this.stream.write(' %');
  1757. }
  1758. this.stream.write(' ' + node.name);
  1759. if (node.value) {
  1760. this.stream.write(' "' + node.value + '"');
  1761. } else {
  1762. if (node.pubID && node.sysID) {
  1763. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  1764. } else if (node.sysID) {
  1765. this.stream.write(' SYSTEM "' + node.sysID + '"');
  1766. }
  1767. if (node.nData) {
  1768. this.stream.write(' NDATA ' + node.nData);
  1769. }
  1770. }
  1771. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  1772. };
  1773. XMLStreamWriter.prototype.dtdNotation = function(node, level) {
  1774. this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
  1775. if (node.pubID && node.sysID) {
  1776. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  1777. } else if (node.pubID) {
  1778. this.stream.write(' PUBLIC "' + node.pubID + '"');
  1779. } else if (node.sysID) {
  1780. this.stream.write(' SYSTEM "' + node.sysID + '"');
  1781. }
  1782. return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
  1783. };
  1784. XMLStreamWriter.prototype.endline = function(node) {
  1785. if (!node.isLastRootNode) {
  1786. return this.newline;
  1787. } else {
  1788. return '';
  1789. }
  1790. };
  1791. return XMLStreamWriter;
  1792. })(XMLWriterBase);
  1793. }).call(this);
  1794. },{"./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){
  1795. // Generated by CoffeeScript 1.12.7
  1796. (function() {
  1797. var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
  1798. 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; },
  1799. hasProp = {}.hasOwnProperty;
  1800. XMLDeclaration = require('./XMLDeclaration');
  1801. XMLDocType = require('./XMLDocType');
  1802. XMLCData = require('./XMLCData');
  1803. XMLComment = require('./XMLComment');
  1804. XMLElement = require('./XMLElement');
  1805. XMLRaw = require('./XMLRaw');
  1806. XMLText = require('./XMLText');
  1807. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  1808. XMLDTDAttList = require('./XMLDTDAttList');
  1809. XMLDTDElement = require('./XMLDTDElement');
  1810. XMLDTDEntity = require('./XMLDTDEntity');
  1811. XMLDTDNotation = require('./XMLDTDNotation');
  1812. XMLWriterBase = require('./XMLWriterBase');
  1813. module.exports = XMLStringWriter = (function(superClass) {
  1814. extend(XMLStringWriter, superClass);
  1815. function XMLStringWriter(options) {
  1816. XMLStringWriter.__super__.constructor.call(this, options);
  1817. }
  1818. XMLStringWriter.prototype.document = function(doc) {
  1819. var child, i, len, r, ref;
  1820. this.textispresent = false;
  1821. r = '';
  1822. ref = doc.children;
  1823. for (i = 0, len = ref.length; i < len; i++) {
  1824. child = ref[i];
  1825. r += (function() {
  1826. switch (false) {
  1827. case !(child instanceof XMLDeclaration):
  1828. return this.declaration(child);
  1829. case !(child instanceof XMLDocType):
  1830. return this.docType(child);
  1831. case !(child instanceof XMLComment):
  1832. return this.comment(child);
  1833. case !(child instanceof XMLProcessingInstruction):
  1834. return this.processingInstruction(child);
  1835. default:
  1836. return this.element(child, 0);
  1837. }
  1838. }).call(this);
  1839. }
  1840. if (this.pretty && r.slice(-this.newline.length) === this.newline) {
  1841. r = r.slice(0, -this.newline.length);
  1842. }
  1843. return r;
  1844. };
  1845. XMLStringWriter.prototype.attribute = function(att) {
  1846. return ' ' + att.name + '="' + att.value + '"';
  1847. };
  1848. XMLStringWriter.prototype.cdata = function(node, level) {
  1849. return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
  1850. };
  1851. XMLStringWriter.prototype.comment = function(node, level) {
  1852. return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
  1853. };
  1854. XMLStringWriter.prototype.declaration = function(node, level) {
  1855. var r;
  1856. r = this.space(level);
  1857. r += '<?xml version="' + node.version + '"';
  1858. if (node.encoding != null) {
  1859. r += ' encoding="' + node.encoding + '"';
  1860. }
  1861. if (node.standalone != null) {
  1862. r += ' standalone="' + node.standalone + '"';
  1863. }
  1864. r += this.spacebeforeslash + '?>';
  1865. r += this.newline;
  1866. return r;
  1867. };
  1868. XMLStringWriter.prototype.docType = function(node, level) {
  1869. var child, i, len, r, ref;
  1870. level || (level = 0);
  1871. r = this.space(level);
  1872. r += '<!DOCTYPE ' + node.root().name;
  1873. if (node.pubID && node.sysID) {
  1874. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  1875. } else if (node.sysID) {
  1876. r += ' SYSTEM "' + node.sysID + '"';
  1877. }
  1878. if (node.children.length > 0) {
  1879. r += ' [';
  1880. r += this.newline;
  1881. ref = node.children;
  1882. for (i = 0, len = ref.length; i < len; i++) {
  1883. child = ref[i];
  1884. r += (function() {
  1885. switch (false) {
  1886. case !(child instanceof XMLDTDAttList):
  1887. return this.dtdAttList(child, level + 1);
  1888. case !(child instanceof XMLDTDElement):
  1889. return this.dtdElement(child, level + 1);
  1890. case !(child instanceof XMLDTDEntity):
  1891. return this.dtdEntity(child, level + 1);
  1892. case !(child instanceof XMLDTDNotation):
  1893. return this.dtdNotation(child, level + 1);
  1894. case !(child instanceof XMLCData):
  1895. return this.cdata(child, level + 1);
  1896. case !(child instanceof XMLComment):
  1897. return this.comment(child, level + 1);
  1898. case !(child instanceof XMLProcessingInstruction):
  1899. return this.processingInstruction(child, level + 1);
  1900. default:
  1901. throw new Error("Unknown DTD node type: " + child.constructor.name);
  1902. }
  1903. }).call(this);
  1904. }
  1905. r += ']';
  1906. }
  1907. r += this.spacebeforeslash + '>';
  1908. r += this.newline;
  1909. return r;
  1910. };
  1911. XMLStringWriter.prototype.element = function(node, level) {
  1912. var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
  1913. level || (level = 0);
  1914. textispresentwasset = false;
  1915. if (this.textispresent) {
  1916. this.newline = '';
  1917. this.pretty = false;
  1918. } else {
  1919. this.newline = this.newlinedefault;
  1920. this.pretty = this.prettydefault;
  1921. }
  1922. space = this.space(level);
  1923. r = '';
  1924. r += space + '<' + node.name;
  1925. ref = node.attributes;
  1926. for (name in ref) {
  1927. if (!hasProp.call(ref, name)) continue;
  1928. att = ref[name];
  1929. r += this.attribute(att);
  1930. }
  1931. if (node.children.length === 0 || node.children.every(function(e) {
  1932. return e.value === '';
  1933. })) {
  1934. if (this.allowEmpty) {
  1935. r += '></' + node.name + '>' + this.newline;
  1936. } else {
  1937. r += this.spacebeforeslash + '/>' + this.newline;
  1938. }
  1939. } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
  1940. r += '>';
  1941. r += node.children[0].value;
  1942. r += '</' + node.name + '>' + this.newline;
  1943. } else {
  1944. if (this.dontprettytextnodes) {
  1945. ref1 = node.children;
  1946. for (i = 0, len = ref1.length; i < len; i++) {
  1947. child = ref1[i];
  1948. if (child.value != null) {
  1949. this.textispresent++;
  1950. textispresentwasset = true;
  1951. break;
  1952. }
  1953. }
  1954. }
  1955. if (this.textispresent) {
  1956. this.newline = '';
  1957. this.pretty = false;
  1958. space = this.space(level);
  1959. }
  1960. r += '>' + this.newline;
  1961. ref2 = node.children;
  1962. for (j = 0, len1 = ref2.length; j < len1; j++) {
  1963. child = ref2[j];
  1964. r += (function() {
  1965. switch (false) {
  1966. case !(child instanceof XMLCData):
  1967. return this.cdata(child, level + 1);
  1968. case !(child instanceof XMLComment):
  1969. return this.comment(child, level + 1);
  1970. case !(child instanceof XMLElement):
  1971. return this.element(child, level + 1);
  1972. case !(child instanceof XMLRaw):
  1973. return this.raw(child, level + 1);
  1974. case !(child instanceof XMLText):
  1975. return this.text(child, level + 1);
  1976. case !(child instanceof XMLProcessingInstruction):
  1977. return this.processingInstruction(child, level + 1);
  1978. default:
  1979. throw new Error("Unknown XML node type: " + child.constructor.name);
  1980. }
  1981. }).call(this);
  1982. }
  1983. if (textispresentwasset) {
  1984. this.textispresent--;
  1985. }
  1986. if (!this.textispresent) {
  1987. this.newline = this.newlinedefault;
  1988. this.pretty = this.prettydefault;
  1989. }
  1990. r += space + '</' + node.name + '>' + this.newline;
  1991. }
  1992. return r;
  1993. };
  1994. XMLStringWriter.prototype.processingInstruction = function(node, level) {
  1995. var r;
  1996. r = this.space(level) + '<?' + node.target;
  1997. if (node.value) {
  1998. r += ' ' + node.value;
  1999. }
  2000. r += this.spacebeforeslash + '?>' + this.newline;
  2001. return r;
  2002. };
  2003. XMLStringWriter.prototype.raw = function(node, level) {
  2004. return this.space(level) + node.value + this.newline;
  2005. };
  2006. XMLStringWriter.prototype.text = function(node, level) {
  2007. return this.space(level) + node.value + this.newline;
  2008. };
  2009. XMLStringWriter.prototype.dtdAttList = function(node, level) {
  2010. var r;
  2011. r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
  2012. if (node.defaultValueType !== '#DEFAULT') {
  2013. r += ' ' + node.defaultValueType;
  2014. }
  2015. if (node.defaultValue) {
  2016. r += ' "' + node.defaultValue + '"';
  2017. }
  2018. r += this.spacebeforeslash + '>' + this.newline;
  2019. return r;
  2020. };
  2021. XMLStringWriter.prototype.dtdElement = function(node, level) {
  2022. return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
  2023. };
  2024. XMLStringWriter.prototype.dtdEntity = function(node, level) {
  2025. var r;
  2026. r = this.space(level) + '<!ENTITY';
  2027. if (node.pe) {
  2028. r += ' %';
  2029. }
  2030. r += ' ' + node.name;
  2031. if (node.value) {
  2032. r += ' "' + node.value + '"';
  2033. } else {
  2034. if (node.pubID && node.sysID) {
  2035. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  2036. } else if (node.sysID) {
  2037. r += ' SYSTEM "' + node.sysID + '"';
  2038. }
  2039. if (node.nData) {
  2040. r += ' NDATA ' + node.nData;
  2041. }
  2042. }
  2043. r += this.spacebeforeslash + '>' + this.newline;
  2044. return r;
  2045. };
  2046. XMLStringWriter.prototype.dtdNotation = function(node, level) {
  2047. var r;
  2048. r = this.space(level) + '<!NOTATION ' + node.name;
  2049. if (node.pubID && node.sysID) {
  2050. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  2051. } else if (node.pubID) {
  2052. r += ' PUBLIC "' + node.pubID + '"';
  2053. } else if (node.sysID) {
  2054. r += ' SYSTEM "' + node.sysID + '"';
  2055. }
  2056. r += this.spacebeforeslash + '>' + this.newline;
  2057. return r;
  2058. };
  2059. XMLStringWriter.prototype.openNode = function(node, level) {
  2060. var att, name, r, ref;
  2061. level || (level = 0);
  2062. if (node instanceof XMLElement) {
  2063. r = this.space(level) + '<' + node.name;
  2064. ref = node.attributes;
  2065. for (name in ref) {
  2066. if (!hasProp.call(ref, name)) continue;
  2067. att = ref[name];
  2068. r += this.attribute(att);
  2069. }
  2070. r += (node.children ? '>' : '/>') + this.newline;
  2071. return r;
  2072. } else {
  2073. r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
  2074. if (node.pubID && node.sysID) {
  2075. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  2076. } else if (node.sysID) {
  2077. r += ' SYSTEM "' + node.sysID + '"';
  2078. }
  2079. r += (node.children ? ' [' : '>') + this.newline;
  2080. return r;
  2081. }
  2082. };
  2083. XMLStringWriter.prototype.closeNode = function(node, level) {
  2084. level || (level = 0);
  2085. switch (false) {
  2086. case !(node instanceof XMLElement):
  2087. return this.space(level) + '</' + node.name + '>' + this.newline;
  2088. case !(node instanceof XMLDocType):
  2089. return this.space(level) + ']>' + this.newline;
  2090. }
  2091. };
  2092. return XMLStringWriter;
  2093. })(XMLWriterBase);
  2094. }).call(this);
  2095. },{"./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){
  2096. // Generated by CoffeeScript 1.12.7
  2097. (function() {
  2098. var XMLStringifier,
  2099. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2100. hasProp = {}.hasOwnProperty;
  2101. module.exports = XMLStringifier = (function() {
  2102. function XMLStringifier(options) {
  2103. this.assertLegalChar = bind(this.assertLegalChar, this);
  2104. var key, ref, value;
  2105. options || (options = {});
  2106. this.noDoubleEncoding = options.noDoubleEncoding;
  2107. ref = options.stringify || {};
  2108. for (key in ref) {
  2109. if (!hasProp.call(ref, key)) continue;
  2110. value = ref[key];
  2111. this[key] = value;
  2112. }
  2113. }
  2114. XMLStringifier.prototype.eleName = function(val) {
  2115. val = '' + val || '';
  2116. return this.assertLegalChar(val);
  2117. };
  2118. XMLStringifier.prototype.eleText = function(val) {
  2119. val = '' + val || '';
  2120. return this.assertLegalChar(this.elEscape(val));
  2121. };
  2122. XMLStringifier.prototype.cdata = function(val) {
  2123. val = '' + val || '';
  2124. val = val.replace(']]>', ']]]]><![CDATA[>');
  2125. return this.assertLegalChar(val);
  2126. };
  2127. XMLStringifier.prototype.comment = function(val) {
  2128. val = '' + val || '';
  2129. if (val.match(/--/)) {
  2130. throw new Error("Comment text cannot contain double-hypen: " + val);
  2131. }
  2132. return this.assertLegalChar(val);
  2133. };
  2134. XMLStringifier.prototype.raw = function(val) {
  2135. return '' + val || '';
  2136. };
  2137. XMLStringifier.prototype.attName = function(val) {
  2138. return val = '' + val || '';
  2139. };
  2140. XMLStringifier.prototype.attValue = function(val) {
  2141. val = '' + val || '';
  2142. return this.attEscape(val);
  2143. };
  2144. XMLStringifier.prototype.insTarget = function(val) {
  2145. return '' + val || '';
  2146. };
  2147. XMLStringifier.prototype.insValue = function(val) {
  2148. val = '' + val || '';
  2149. if (val.match(/\?>/)) {
  2150. throw new Error("Invalid processing instruction value: " + val);
  2151. }
  2152. return val;
  2153. };
  2154. XMLStringifier.prototype.xmlVersion = function(val) {
  2155. val = '' + val || '';
  2156. if (!val.match(/1\.[0-9]+/)) {
  2157. throw new Error("Invalid version number: " + val);
  2158. }
  2159. return val;
  2160. };
  2161. XMLStringifier.prototype.xmlEncoding = function(val) {
  2162. val = '' + val || '';
  2163. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
  2164. throw new Error("Invalid encoding: " + val);
  2165. }
  2166. return val;
  2167. };
  2168. XMLStringifier.prototype.xmlStandalone = function(val) {
  2169. if (val) {
  2170. return "yes";
  2171. } else {
  2172. return "no";
  2173. }
  2174. };
  2175. XMLStringifier.prototype.dtdPubID = function(val) {
  2176. return '' + val || '';
  2177. };
  2178. XMLStringifier.prototype.dtdSysID = function(val) {
  2179. return '' + val || '';
  2180. };
  2181. XMLStringifier.prototype.dtdElementValue = function(val) {
  2182. return '' + val || '';
  2183. };
  2184. XMLStringifier.prototype.dtdAttType = function(val) {
  2185. return '' + val || '';
  2186. };
  2187. XMLStringifier.prototype.dtdAttDefault = function(val) {
  2188. if (val != null) {
  2189. return '' + val || '';
  2190. } else {
  2191. return val;
  2192. }
  2193. };
  2194. XMLStringifier.prototype.dtdEntityValue = function(val) {
  2195. return '' + val || '';
  2196. };
  2197. XMLStringifier.prototype.dtdNData = function(val) {
  2198. return '' + val || '';
  2199. };
  2200. XMLStringifier.prototype.convertAttKey = '@';
  2201. XMLStringifier.prototype.convertPIKey = '?';
  2202. XMLStringifier.prototype.convertTextKey = '#text';
  2203. XMLStringifier.prototype.convertCDataKey = '#cdata';
  2204. XMLStringifier.prototype.convertCommentKey = '#comment';
  2205. XMLStringifier.prototype.convertRawKey = '#raw';
  2206. XMLStringifier.prototype.assertLegalChar = function(str) {
  2207. var res;
  2208. res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
  2209. if (res) {
  2210. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  2211. }
  2212. return str;
  2213. };
  2214. XMLStringifier.prototype.elEscape = function(str) {
  2215. var ampregex;
  2216. ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  2217. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  2218. };
  2219. XMLStringifier.prototype.attEscape = function(str) {
  2220. var ampregex;
  2221. ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  2222. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
  2223. };
  2224. return XMLStringifier;
  2225. })();
  2226. }).call(this);
  2227. },{}],23:[function(require,module,exports){
  2228. // Generated by CoffeeScript 1.12.7
  2229. (function() {
  2230. var XMLNode, XMLText,
  2231. 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; },
  2232. hasProp = {}.hasOwnProperty;
  2233. XMLNode = require('./XMLNode');
  2234. module.exports = XMLText = (function(superClass) {
  2235. extend(XMLText, superClass);
  2236. function XMLText(parent, text) {
  2237. XMLText.__super__.constructor.call(this, parent);
  2238. if (text == null) {
  2239. throw new Error("Missing element text");
  2240. }
  2241. this.value = this.stringify.eleText(text);
  2242. }
  2243. XMLText.prototype.clone = function() {
  2244. return Object.create(this);
  2245. };
  2246. XMLText.prototype.toString = function(options) {
  2247. return this.options.writer.set(options).text(this);
  2248. };
  2249. return XMLText;
  2250. })(XMLNode);
  2251. }).call(this);
  2252. },{"./XMLNode":17}],24:[function(require,module,exports){
  2253. // Generated by CoffeeScript 1.12.7
  2254. (function() {
  2255. var XMLWriterBase,
  2256. hasProp = {}.hasOwnProperty;
  2257. module.exports = XMLWriterBase = (function() {
  2258. function XMLWriterBase(options) {
  2259. var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
  2260. options || (options = {});
  2261. this.pretty = options.pretty || false;
  2262. this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
  2263. if (this.pretty) {
  2264. this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
  2265. this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
  2266. this.offset = (ref3 = options.offset) != null ? ref3 : 0;
  2267. this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
  2268. } else {
  2269. this.indent = '';
  2270. this.newline = '';
  2271. this.offset = 0;
  2272. this.dontprettytextnodes = 0;
  2273. }
  2274. this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
  2275. if (this.spacebeforeslash === true) {
  2276. this.spacebeforeslash = ' ';
  2277. }
  2278. this.newlinedefault = this.newline;
  2279. this.prettydefault = this.pretty;
  2280. ref6 = options.writer || {};
  2281. for (key in ref6) {
  2282. if (!hasProp.call(ref6, key)) continue;
  2283. value = ref6[key];
  2284. this[key] = value;
  2285. }
  2286. }
  2287. XMLWriterBase.prototype.set = function(options) {
  2288. var key, ref, value;
  2289. options || (options = {});
  2290. if ("pretty" in options) {
  2291. this.pretty = options.pretty;
  2292. }
  2293. if ("allowEmpty" in options) {
  2294. this.allowEmpty = options.allowEmpty;
  2295. }
  2296. if (this.pretty) {
  2297. this.indent = "indent" in options ? options.indent : ' ';
  2298. this.newline = "newline" in options ? options.newline : '\n';
  2299. this.offset = "offset" in options ? options.offset : 0;
  2300. this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
  2301. } else {
  2302. this.indent = '';
  2303. this.newline = '';
  2304. this.offset = 0;
  2305. this.dontprettytextnodes = 0;
  2306. }
  2307. this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
  2308. if (this.spacebeforeslash === true) {
  2309. this.spacebeforeslash = ' ';
  2310. }
  2311. this.newlinedefault = this.newline;
  2312. this.prettydefault = this.pretty;
  2313. ref = options.writer || {};
  2314. for (key in ref) {
  2315. if (!hasProp.call(ref, key)) continue;
  2316. value = ref[key];
  2317. this[key] = value;
  2318. }
  2319. return this;
  2320. };
  2321. XMLWriterBase.prototype.space = function(level) {
  2322. var indent;
  2323. if (this.pretty) {
  2324. indent = (level || 0) + this.offset + 1;
  2325. if (indent > 0) {
  2326. return new Array(indent).join(this.indent);
  2327. } else {
  2328. return '';
  2329. }
  2330. } else {
  2331. return '';
  2332. }
  2333. };
  2334. return XMLWriterBase;
  2335. })();
  2336. }).call(this);
  2337. },{}],25:[function(require,module,exports){
  2338. // Generated by CoffeeScript 1.12.7
  2339. (function() {
  2340. var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
  2341. ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
  2342. XMLDocument = require('./XMLDocument');
  2343. XMLDocumentCB = require('./XMLDocumentCB');
  2344. XMLStringWriter = require('./XMLStringWriter');
  2345. XMLStreamWriter = require('./XMLStreamWriter');
  2346. module.exports.create = function(name, xmldec, doctype, options) {
  2347. var doc, root;
  2348. if (name == null) {
  2349. throw new Error("Root element needs a name");
  2350. }
  2351. options = assign({}, xmldec, doctype, options);
  2352. doc = new XMLDocument(options);
  2353. root = doc.element(name);
  2354. if (!options.headless) {
  2355. doc.declaration(options);
  2356. if ((options.pubID != null) || (options.sysID != null)) {
  2357. doc.doctype(options);
  2358. }
  2359. }
  2360. return root;
  2361. };
  2362. module.exports.begin = function(options, onData, onEnd) {
  2363. var ref1;
  2364. if (isFunction(options)) {
  2365. ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
  2366. options = {};
  2367. }
  2368. if (onData) {
  2369. return new XMLDocumentCB(options, onData, onEnd);
  2370. } else {
  2371. return new XMLDocument(options);
  2372. }
  2373. };
  2374. module.exports.stringWriter = function(options) {
  2375. return new XMLStringWriter(options);
  2376. };
  2377. module.exports.streamWriter = function(stream, options) {
  2378. return new XMLStreamWriter(stream, options);
  2379. };
  2380. }).call(this);
  2381. },{"./Utility":4,"./XMLDocument":14,"./XMLDocumentCB":15,"./XMLStreamWriter":20,"./XMLStringWriter":21}]},{},[1])(1)
  2382. });