plist-build.js 164 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345
  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 r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. (function (Buffer){(function (){
  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. } else if ('Null' === name) {
  113. next_child.ele('null').txt('');
  114. }
  115. }
  116. }).call(this)}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
  117. },{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":36}],2:[function(require,module,exports){
  118. 'use strict'
  119. exports.byteLength = byteLength
  120. exports.toByteArray = toByteArray
  121. exports.fromByteArray = fromByteArray
  122. var lookup = []
  123. var revLookup = []
  124. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  125. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  126. for (var i = 0, len = code.length; i < len; ++i) {
  127. lookup[i] = code[i]
  128. revLookup[code.charCodeAt(i)] = i
  129. }
  130. // Support decoding URL-safe base64 strings, as Node.js does.
  131. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  132. revLookup['-'.charCodeAt(0)] = 62
  133. revLookup['_'.charCodeAt(0)] = 63
  134. function getLens (b64) {
  135. var len = b64.length
  136. if (len % 4 > 0) {
  137. throw new Error('Invalid string. Length must be a multiple of 4')
  138. }
  139. // Trim off extra bytes after placeholder bytes are found
  140. // See: https://github.com/beatgammit/base64-js/issues/42
  141. var validLen = b64.indexOf('=')
  142. if (validLen === -1) validLen = len
  143. var placeHoldersLen = validLen === len
  144. ? 0
  145. : 4 - (validLen % 4)
  146. return [validLen, placeHoldersLen]
  147. }
  148. // base64 is 4/3 + up to two characters of the original data
  149. function byteLength (b64) {
  150. var lens = getLens(b64)
  151. var validLen = lens[0]
  152. var placeHoldersLen = lens[1]
  153. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  154. }
  155. function _byteLength (b64, validLen, placeHoldersLen) {
  156. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  157. }
  158. function toByteArray (b64) {
  159. var tmp
  160. var lens = getLens(b64)
  161. var validLen = lens[0]
  162. var placeHoldersLen = lens[1]
  163. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  164. var curByte = 0
  165. // if there are placeholders, only get up to the last complete 4 chars
  166. var len = placeHoldersLen > 0
  167. ? validLen - 4
  168. : validLen
  169. var i
  170. for (i = 0; i < len; i += 4) {
  171. tmp =
  172. (revLookup[b64.charCodeAt(i)] << 18) |
  173. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  174. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  175. revLookup[b64.charCodeAt(i + 3)]
  176. arr[curByte++] = (tmp >> 16) & 0xFF
  177. arr[curByte++] = (tmp >> 8) & 0xFF
  178. arr[curByte++] = tmp & 0xFF
  179. }
  180. if (placeHoldersLen === 2) {
  181. tmp =
  182. (revLookup[b64.charCodeAt(i)] << 2) |
  183. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  184. arr[curByte++] = tmp & 0xFF
  185. }
  186. if (placeHoldersLen === 1) {
  187. tmp =
  188. (revLookup[b64.charCodeAt(i)] << 10) |
  189. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  190. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  191. arr[curByte++] = (tmp >> 8) & 0xFF
  192. arr[curByte++] = tmp & 0xFF
  193. }
  194. return arr
  195. }
  196. function tripletToBase64 (num) {
  197. return lookup[num >> 18 & 0x3F] +
  198. lookup[num >> 12 & 0x3F] +
  199. lookup[num >> 6 & 0x3F] +
  200. lookup[num & 0x3F]
  201. }
  202. function encodeChunk (uint8, start, end) {
  203. var tmp
  204. var output = []
  205. for (var i = start; i < end; i += 3) {
  206. tmp =
  207. ((uint8[i] << 16) & 0xFF0000) +
  208. ((uint8[i + 1] << 8) & 0xFF00) +
  209. (uint8[i + 2] & 0xFF)
  210. output.push(tripletToBase64(tmp))
  211. }
  212. return output.join('')
  213. }
  214. function fromByteArray (uint8) {
  215. var tmp
  216. var len = uint8.length
  217. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  218. var parts = []
  219. var maxChunkLength = 16383 // must be multiple of 3
  220. // go through the array every three bytes, we'll deal with trailing stuff later
  221. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  222. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  223. }
  224. // pad the end with zeros, but make sure to not forget the extra bytes
  225. if (extraBytes === 1) {
  226. tmp = uint8[len - 1]
  227. parts.push(
  228. lookup[tmp >> 2] +
  229. lookup[(tmp << 4) & 0x3F] +
  230. '=='
  231. )
  232. } else if (extraBytes === 2) {
  233. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  234. parts.push(
  235. lookup[tmp >> 10] +
  236. lookup[(tmp >> 4) & 0x3F] +
  237. lookup[(tmp << 2) & 0x3F] +
  238. '='
  239. )
  240. }
  241. return parts.join('')
  242. }
  243. },{}],3:[function(require,module,exports){
  244. /*!
  245. * Determine if an object is a Buffer
  246. *
  247. * @author Feross Aboukhadijeh <https://feross.org>
  248. * @license MIT
  249. */
  250. // The _isBuffer check is for Safari 5-7 support, because it's missing
  251. // Object.prototype.constructor. Remove this eventually
  252. module.exports = function (obj) {
  253. return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
  254. }
  255. function isBuffer (obj) {
  256. return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
  257. }
  258. // For Node v0.10 support. Remove this eventually.
  259. function isSlowBuffer (obj) {
  260. return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
  261. }
  262. },{}],4:[function(require,module,exports){
  263. // Generated by CoffeeScript 2.4.1
  264. (function() {
  265. module.exports = {
  266. Disconnected: 1,
  267. Preceding: 2,
  268. Following: 4,
  269. Contains: 8,
  270. ContainedBy: 16,
  271. ImplementationSpecific: 32
  272. };
  273. }).call(this);
  274. },{}],5:[function(require,module,exports){
  275. // Generated by CoffeeScript 2.4.1
  276. (function() {
  277. module.exports = {
  278. Element: 1,
  279. Attribute: 2,
  280. Text: 3,
  281. CData: 4,
  282. EntityReference: 5,
  283. EntityDeclaration: 6,
  284. ProcessingInstruction: 7,
  285. Comment: 8,
  286. Document: 9,
  287. DocType: 10,
  288. DocumentFragment: 11,
  289. NotationDeclaration: 12,
  290. // Numeric codes up to 200 are reserved to W3C for possible future use.
  291. // Following are types internal to this library:
  292. Declaration: 201,
  293. Raw: 202,
  294. AttributeDeclaration: 203,
  295. ElementDeclaration: 204,
  296. Dummy: 205
  297. };
  298. }).call(this);
  299. },{}],6:[function(require,module,exports){
  300. // Generated by CoffeeScript 2.4.1
  301. (function() {
  302. // Copies all enumerable own properties from `sources` to `target`
  303. var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
  304. hasProp = {}.hasOwnProperty;
  305. assign = function(target, ...sources) {
  306. var i, key, len, source;
  307. if (isFunction(Object.assign)) {
  308. Object.assign.apply(null, arguments);
  309. } else {
  310. for (i = 0, len = sources.length; i < len; i++) {
  311. source = sources[i];
  312. if (source != null) {
  313. for (key in source) {
  314. if (!hasProp.call(source, key)) continue;
  315. target[key] = source[key];
  316. }
  317. }
  318. }
  319. }
  320. return target;
  321. };
  322. // Determines if `val` is a Function object
  323. isFunction = function(val) {
  324. return !!val && Object.prototype.toString.call(val) === '[object Function]';
  325. };
  326. // Determines if `val` is an Object
  327. isObject = function(val) {
  328. var ref;
  329. return !!val && ((ref = typeof val) === 'function' || ref === 'object');
  330. };
  331. // Determines if `val` is an Array
  332. isArray = function(val) {
  333. if (isFunction(Array.isArray)) {
  334. return Array.isArray(val);
  335. } else {
  336. return Object.prototype.toString.call(val) === '[object Array]';
  337. }
  338. };
  339. // Determines if `val` is an empty Array or an Object with no own properties
  340. isEmpty = function(val) {
  341. var key;
  342. if (isArray(val)) {
  343. return !val.length;
  344. } else {
  345. for (key in val) {
  346. if (!hasProp.call(val, key)) continue;
  347. return false;
  348. }
  349. return true;
  350. }
  351. };
  352. // Determines if `val` is a plain Object
  353. isPlainObject = function(val) {
  354. var ctor, proto;
  355. 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));
  356. };
  357. // Gets the primitive value of an object
  358. getValue = function(obj) {
  359. if (isFunction(obj.valueOf)) {
  360. return obj.valueOf();
  361. } else {
  362. return obj;
  363. }
  364. };
  365. module.exports.assign = assign;
  366. module.exports.isFunction = isFunction;
  367. module.exports.isObject = isObject;
  368. module.exports.isArray = isArray;
  369. module.exports.isEmpty = isEmpty;
  370. module.exports.isPlainObject = isPlainObject;
  371. module.exports.getValue = getValue;
  372. }).call(this);
  373. },{}],7:[function(require,module,exports){
  374. // Generated by CoffeeScript 2.4.1
  375. (function() {
  376. module.exports = {
  377. None: 0,
  378. OpenTag: 1,
  379. InsideTag: 2,
  380. CloseTag: 3
  381. };
  382. }).call(this);
  383. },{}],8:[function(require,module,exports){
  384. // Generated by CoffeeScript 2.4.1
  385. (function() {
  386. var NodeType, XMLAttribute, XMLNode;
  387. NodeType = require('./NodeType');
  388. XMLNode = require('./XMLNode');
  389. // Represents an attribute
  390. module.exports = XMLAttribute = (function() {
  391. class XMLAttribute {
  392. // Initializes a new instance of `XMLAttribute`
  393. // `parent` the parent node
  394. // `name` attribute target
  395. // `value` attribute value
  396. constructor(parent, name, value) {
  397. this.parent = parent;
  398. if (this.parent) {
  399. this.options = this.parent.options;
  400. this.stringify = this.parent.stringify;
  401. }
  402. if (name == null) {
  403. throw new Error("Missing attribute name. " + this.debugInfo(name));
  404. }
  405. this.name = this.stringify.name(name);
  406. this.value = this.stringify.attValue(value);
  407. this.type = NodeType.Attribute;
  408. // DOM level 3
  409. this.isId = false;
  410. this.schemaTypeInfo = null;
  411. }
  412. // Creates and returns a deep clone of `this`
  413. clone() {
  414. return Object.create(this);
  415. }
  416. // Converts the XML fragment to string
  417. // `options.pretty` pretty prints the result
  418. // `options.indent` indentation for pretty print
  419. // `options.offset` how many indentations to add to every line for pretty print
  420. // `options.newline` newline sequence for pretty print
  421. toString(options) {
  422. return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
  423. }
  424. // Returns debug string for this node
  425. debugInfo(name) {
  426. name = name || this.name;
  427. if (name == null) {
  428. return "parent: <" + this.parent.name + ">";
  429. } else {
  430. return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
  431. }
  432. }
  433. isEqualNode(node) {
  434. if (node.namespaceURI !== this.namespaceURI) {
  435. return false;
  436. }
  437. if (node.prefix !== this.prefix) {
  438. return false;
  439. }
  440. if (node.localName !== this.localName) {
  441. return false;
  442. }
  443. if (node.value !== this.value) {
  444. return false;
  445. }
  446. return true;
  447. }
  448. };
  449. // DOM level 1
  450. Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
  451. get: function() {
  452. return this.type;
  453. }
  454. });
  455. Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
  456. get: function() {
  457. return this.parent;
  458. }
  459. });
  460. // DOM level 3
  461. Object.defineProperty(XMLAttribute.prototype, 'textContent', {
  462. get: function() {
  463. return this.value;
  464. },
  465. set: function(value) {
  466. return this.value = value || '';
  467. }
  468. });
  469. // DOM level 4
  470. Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
  471. get: function() {
  472. return '';
  473. }
  474. });
  475. Object.defineProperty(XMLAttribute.prototype, 'prefix', {
  476. get: function() {
  477. return '';
  478. }
  479. });
  480. Object.defineProperty(XMLAttribute.prototype, 'localName', {
  481. get: function() {
  482. return this.name;
  483. }
  484. });
  485. Object.defineProperty(XMLAttribute.prototype, 'specified', {
  486. get: function() {
  487. return true;
  488. }
  489. });
  490. return XMLAttribute;
  491. }).call(this);
  492. }).call(this);
  493. },{"./NodeType":5,"./XMLNode":27}],9:[function(require,module,exports){
  494. // Generated by CoffeeScript 2.4.1
  495. (function() {
  496. var NodeType, XMLCData, XMLCharacterData;
  497. NodeType = require('./NodeType');
  498. XMLCharacterData = require('./XMLCharacterData');
  499. // Represents a CDATA node
  500. module.exports = XMLCData = class XMLCData extends XMLCharacterData {
  501. // Initializes a new instance of `XMLCData`
  502. // `text` CDATA text
  503. constructor(parent, text) {
  504. super(parent);
  505. if (text == null) {
  506. throw new Error("Missing CDATA text. " + this.debugInfo());
  507. }
  508. this.name = "#cdata-section";
  509. this.type = NodeType.CData;
  510. this.value = this.stringify.cdata(text);
  511. }
  512. // Creates and returns a deep clone of `this`
  513. clone() {
  514. return Object.create(this);
  515. }
  516. // Converts the XML fragment to string
  517. // `options.pretty` pretty prints the result
  518. // `options.indent` indentation for pretty print
  519. // `options.offset` how many indentations to add to every line for pretty print
  520. // `options.newline` newline sequence for pretty print
  521. toString(options) {
  522. return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
  523. }
  524. };
  525. }).call(this);
  526. },{"./NodeType":5,"./XMLCharacterData":10}],10:[function(require,module,exports){
  527. // Generated by CoffeeScript 2.4.1
  528. (function() {
  529. var XMLCharacterData, XMLNode;
  530. XMLNode = require('./XMLNode');
  531. // Represents a character data node
  532. module.exports = XMLCharacterData = (function() {
  533. class XMLCharacterData extends XMLNode {
  534. // Initializes a new instance of `XMLCharacterData`
  535. constructor(parent) {
  536. super(parent);
  537. this.value = '';
  538. }
  539. // Creates and returns a deep clone of `this`
  540. clone() {
  541. return Object.create(this);
  542. }
  543. // DOM level 1 functions to be implemented later
  544. substringData(offset, count) {
  545. throw new Error("This DOM method is not implemented." + this.debugInfo());
  546. }
  547. appendData(arg) {
  548. throw new Error("This DOM method is not implemented." + this.debugInfo());
  549. }
  550. insertData(offset, arg) {
  551. throw new Error("This DOM method is not implemented." + this.debugInfo());
  552. }
  553. deleteData(offset, count) {
  554. throw new Error("This DOM method is not implemented." + this.debugInfo());
  555. }
  556. replaceData(offset, count, arg) {
  557. throw new Error("This DOM method is not implemented." + this.debugInfo());
  558. }
  559. isEqualNode(node) {
  560. if (!super.isEqualNode(node)) {
  561. return false;
  562. }
  563. if (node.data !== this.data) {
  564. return false;
  565. }
  566. return true;
  567. }
  568. };
  569. // DOM level 1
  570. Object.defineProperty(XMLCharacterData.prototype, 'data', {
  571. get: function() {
  572. return this.value;
  573. },
  574. set: function(value) {
  575. return this.value = value || '';
  576. }
  577. });
  578. Object.defineProperty(XMLCharacterData.prototype, 'length', {
  579. get: function() {
  580. return this.value.length;
  581. }
  582. });
  583. // DOM level 3
  584. Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
  585. get: function() {
  586. return this.value;
  587. },
  588. set: function(value) {
  589. return this.value = value || '';
  590. }
  591. });
  592. return XMLCharacterData;
  593. }).call(this);
  594. }).call(this);
  595. },{"./XMLNode":27}],11:[function(require,module,exports){
  596. // Generated by CoffeeScript 2.4.1
  597. (function() {
  598. var NodeType, XMLCharacterData, XMLComment;
  599. NodeType = require('./NodeType');
  600. XMLCharacterData = require('./XMLCharacterData');
  601. // Represents a comment node
  602. module.exports = XMLComment = class XMLComment extends XMLCharacterData {
  603. // Initializes a new instance of `XMLComment`
  604. // `text` comment text
  605. constructor(parent, text) {
  606. super(parent);
  607. if (text == null) {
  608. throw new Error("Missing comment text. " + this.debugInfo());
  609. }
  610. this.name = "#comment";
  611. this.type = NodeType.Comment;
  612. this.value = this.stringify.comment(text);
  613. }
  614. // Creates and returns a deep clone of `this`
  615. clone() {
  616. return Object.create(this);
  617. }
  618. // Converts the XML fragment to string
  619. // `options.pretty` pretty prints the result
  620. // `options.indent` indentation for pretty print
  621. // `options.offset` how many indentations to add to every line for pretty print
  622. // `options.newline` newline sequence for pretty print
  623. toString(options) {
  624. return this.options.writer.comment(this, this.options.writer.filterOptions(options));
  625. }
  626. };
  627. }).call(this);
  628. },{"./NodeType":5,"./XMLCharacterData":10}],12:[function(require,module,exports){
  629. // Generated by CoffeeScript 2.4.1
  630. (function() {
  631. var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
  632. XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
  633. XMLDOMStringList = require('./XMLDOMStringList');
  634. // Implements the DOMConfiguration interface
  635. module.exports = XMLDOMConfiguration = (function() {
  636. class XMLDOMConfiguration {
  637. constructor() {
  638. var clonedSelf;
  639. this.defaultParams = {
  640. "canonical-form": false,
  641. "cdata-sections": false,
  642. "comments": false,
  643. "datatype-normalization": false,
  644. "element-content-whitespace": true,
  645. "entities": true,
  646. "error-handler": new XMLDOMErrorHandler(),
  647. "infoset": true,
  648. "validate-if-schema": false,
  649. "namespaces": true,
  650. "namespace-declarations": true,
  651. "normalize-characters": false,
  652. "schema-location": '',
  653. "schema-type": '',
  654. "split-cdata-sections": true,
  655. "validate": false,
  656. "well-formed": true
  657. };
  658. this.params = clonedSelf = Object.create(this.defaultParams);
  659. }
  660. // Gets the value of a parameter.
  661. // `name` name of the parameter
  662. getParameter(name) {
  663. if (this.params.hasOwnProperty(name)) {
  664. return this.params[name];
  665. } else {
  666. return null;
  667. }
  668. }
  669. // Checks if setting a parameter to a specific value is supported.
  670. // `name` name of the parameter
  671. // `value` parameter value
  672. canSetParameter(name, value) {
  673. return true;
  674. }
  675. // Sets the value of a parameter.
  676. // `name` name of the parameter
  677. // `value` new value or null if the user wishes to unset the parameter
  678. setParameter(name, value) {
  679. if (value != null) {
  680. return this.params[name] = value;
  681. } else {
  682. return delete this.params[name];
  683. }
  684. }
  685. };
  686. // Returns the list of parameter names
  687. Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
  688. get: function() {
  689. return new XMLDOMStringList(Object.keys(this.defaultParams));
  690. }
  691. });
  692. return XMLDOMConfiguration;
  693. }).call(this);
  694. }).call(this);
  695. },{"./XMLDOMErrorHandler":13,"./XMLDOMStringList":15}],13:[function(require,module,exports){
  696. // Generated by CoffeeScript 2.4.1
  697. (function() {
  698. // Represents the error handler for DOM operations
  699. var XMLDOMErrorHandler;
  700. module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler {
  701. // Initializes a new instance of `XMLDOMErrorHandler`
  702. constructor() {}
  703. // Called on the error handler when an error occurs.
  704. // `error` the error message as a string
  705. handleError(error) {
  706. throw new Error(error);
  707. }
  708. };
  709. }).call(this);
  710. },{}],14:[function(require,module,exports){
  711. // Generated by CoffeeScript 2.4.1
  712. (function() {
  713. // Implements the DOMImplementation interface
  714. var XMLDOMImplementation;
  715. module.exports = XMLDOMImplementation = class XMLDOMImplementation {
  716. // Tests if the DOM implementation implements a specific feature.
  717. // `feature` package name of the feature to test. In Level 1, the
  718. // legal values are "HTML" and "XML" (case-insensitive).
  719. // `version` version number of the package name to test.
  720. // In Level 1, this is the string "1.0". If the version is
  721. // not specified, supporting any version of the feature will
  722. // cause the method to return true.
  723. hasFeature(feature, version) {
  724. return true;
  725. }
  726. // Creates a new document type declaration.
  727. // `qualifiedName` qualified name of the document type to be created
  728. // `publicId` public identifier of the external subset
  729. // `systemId` system identifier of the external subset
  730. createDocumentType(qualifiedName, publicId, systemId) {
  731. throw new Error("This DOM method is not implemented.");
  732. }
  733. // Creates a new document.
  734. // `namespaceURI` namespace URI of the document element to create
  735. // `qualifiedName` the qualified name of the document to be created
  736. // `doctype` the type of document to be created or null
  737. createDocument(namespaceURI, qualifiedName, doctype) {
  738. throw new Error("This DOM method is not implemented.");
  739. }
  740. // Creates a new HTML document.
  741. // `title` document title
  742. createHTMLDocument(title) {
  743. throw new Error("This DOM method is not implemented.");
  744. }
  745. // Returns a specialized object which implements the specialized APIs
  746. // of the specified feature and version.
  747. // `feature` name of the feature requested.
  748. // `version` version number of the feature to test
  749. getFeature(feature, version) {
  750. throw new Error("This DOM method is not implemented.");
  751. }
  752. };
  753. }).call(this);
  754. },{}],15:[function(require,module,exports){
  755. // Generated by CoffeeScript 2.4.1
  756. (function() {
  757. // Represents a list of string entries
  758. var XMLDOMStringList;
  759. module.exports = XMLDOMStringList = (function() {
  760. class XMLDOMStringList {
  761. // Initializes a new instance of `XMLDOMStringList`
  762. // This is just a wrapper around an ordinary
  763. // JS array.
  764. // `arr` the array of string values
  765. constructor(arr) {
  766. this.arr = arr || [];
  767. }
  768. // Returns the indexth item in the collection.
  769. // `index` index into the collection
  770. item(index) {
  771. return this.arr[index] || null;
  772. }
  773. // Test if a string is part of this DOMStringList.
  774. // `str` the string to look for
  775. contains(str) {
  776. return this.arr.indexOf(str) !== -1;
  777. }
  778. };
  779. // Returns the number of strings in the list.
  780. Object.defineProperty(XMLDOMStringList.prototype, 'length', {
  781. get: function() {
  782. return this.arr.length;
  783. }
  784. });
  785. return XMLDOMStringList;
  786. }).call(this);
  787. }).call(this);
  788. },{}],16:[function(require,module,exports){
  789. // Generated by CoffeeScript 2.4.1
  790. (function() {
  791. var NodeType, XMLDTDAttList, XMLNode;
  792. XMLNode = require('./XMLNode');
  793. NodeType = require('./NodeType');
  794. // Represents an attribute list
  795. module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode {
  796. // Initializes a new instance of `XMLDTDAttList`
  797. // `parent` the parent `XMLDocType` element
  798. // `elementName` the name of the element containing this attribute
  799. // `attributeName` attribute name
  800. // `attributeType` type of the attribute
  801. // `defaultValueType` default value type (either #REQUIRED, #IMPLIED,
  802. // #FIXED or #DEFAULT)
  803. // `defaultValue` default value of the attribute
  804. // (only used for #FIXED or #DEFAULT)
  805. constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  806. super(parent);
  807. if (elementName == null) {
  808. throw new Error("Missing DTD element name. " + this.debugInfo());
  809. }
  810. if (attributeName == null) {
  811. throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
  812. }
  813. if (!attributeType) {
  814. throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
  815. }
  816. if (!defaultValueType) {
  817. throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
  818. }
  819. if (defaultValueType.indexOf('#') !== 0) {
  820. defaultValueType = '#' + defaultValueType;
  821. }
  822. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  823. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  824. }
  825. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  826. throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  827. }
  828. this.elementName = this.stringify.name(elementName);
  829. this.type = NodeType.AttributeDeclaration;
  830. this.attributeName = this.stringify.name(attributeName);
  831. this.attributeType = this.stringify.dtdAttType(attributeType);
  832. if (defaultValue) {
  833. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  834. }
  835. this.defaultValueType = defaultValueType;
  836. }
  837. // Converts the XML fragment to string
  838. // `options.pretty` pretty prints the result
  839. // `options.indent` indentation for pretty print
  840. // `options.offset` how many indentations to add to every line for pretty print
  841. // `options.newline` newline sequence for pretty print
  842. toString(options) {
  843. return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
  844. }
  845. };
  846. }).call(this);
  847. },{"./NodeType":5,"./XMLNode":27}],17:[function(require,module,exports){
  848. // Generated by CoffeeScript 2.4.1
  849. (function() {
  850. var NodeType, XMLDTDElement, XMLNode;
  851. XMLNode = require('./XMLNode');
  852. NodeType = require('./NodeType');
  853. // Represents an attribute
  854. module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode {
  855. // Initializes a new instance of `XMLDTDElement`
  856. // `parent` the parent `XMLDocType` element
  857. // `name` element name
  858. // `value` element content (defaults to #PCDATA)
  859. constructor(parent, name, value) {
  860. super(parent);
  861. if (name == null) {
  862. throw new Error("Missing DTD element name. " + this.debugInfo());
  863. }
  864. if (!value) {
  865. value = '(#PCDATA)';
  866. }
  867. if (Array.isArray(value)) {
  868. value = '(' + value.join(',') + ')';
  869. }
  870. this.name = this.stringify.name(name);
  871. this.type = NodeType.ElementDeclaration;
  872. this.value = this.stringify.dtdElementValue(value);
  873. }
  874. // Converts the XML fragment to string
  875. // `options.pretty` pretty prints the result
  876. // `options.indent` indentation for pretty print
  877. // `options.offset` how many indentations to add to every line for pretty print
  878. // `options.newline` newline sequence for pretty print
  879. toString(options) {
  880. return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
  881. }
  882. };
  883. }).call(this);
  884. },{"./NodeType":5,"./XMLNode":27}],18:[function(require,module,exports){
  885. // Generated by CoffeeScript 2.4.1
  886. (function() {
  887. var NodeType, XMLDTDEntity, XMLNode, isObject;
  888. ({isObject} = require('./Utility'));
  889. XMLNode = require('./XMLNode');
  890. NodeType = require('./NodeType');
  891. // Represents an entity declaration in the DTD
  892. module.exports = XMLDTDEntity = (function() {
  893. class XMLDTDEntity extends XMLNode {
  894. // Initializes a new instance of `XMLDTDEntity`
  895. // `parent` the parent `XMLDocType` element
  896. // `pe` whether this is a parameter entity or a general entity
  897. // defaults to `false` (general entity)
  898. // `name` the name of the entity
  899. // `value` internal entity value or an object with external entity details
  900. // `value.pubID` public identifier
  901. // `value.sysID` system identifier
  902. // `value.nData` notation declaration
  903. constructor(parent, pe, name, value) {
  904. super(parent);
  905. if (name == null) {
  906. throw new Error("Missing DTD entity name. " + this.debugInfo(name));
  907. }
  908. if (value == null) {
  909. throw new Error("Missing DTD entity value. " + this.debugInfo(name));
  910. }
  911. this.pe = !!pe;
  912. this.name = this.stringify.name(name);
  913. this.type = NodeType.EntityDeclaration;
  914. if (!isObject(value)) {
  915. this.value = this.stringify.dtdEntityValue(value);
  916. this.internal = true;
  917. } else {
  918. if (!value.pubID && !value.sysID) {
  919. throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
  920. }
  921. if (value.pubID && !value.sysID) {
  922. throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
  923. }
  924. this.internal = false;
  925. if (value.pubID != null) {
  926. this.pubID = this.stringify.dtdPubID(value.pubID);
  927. }
  928. if (value.sysID != null) {
  929. this.sysID = this.stringify.dtdSysID(value.sysID);
  930. }
  931. if (value.nData != null) {
  932. this.nData = this.stringify.dtdNData(value.nData);
  933. }
  934. if (this.pe && this.nData) {
  935. throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
  936. }
  937. }
  938. }
  939. // Converts the XML fragment to string
  940. // `options.pretty` pretty prints the result
  941. // `options.indent` indentation for pretty print
  942. // `options.offset` how many indentations to add to every line for pretty print
  943. // `options.newline` newline sequence for pretty print
  944. toString(options) {
  945. return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
  946. }
  947. };
  948. // DOM level 1
  949. Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
  950. get: function() {
  951. return this.pubID;
  952. }
  953. });
  954. Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
  955. get: function() {
  956. return this.sysID;
  957. }
  958. });
  959. Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
  960. get: function() {
  961. return this.nData || null;
  962. }
  963. });
  964. // DOM level 3
  965. Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
  966. get: function() {
  967. return null;
  968. }
  969. });
  970. Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
  971. get: function() {
  972. return null;
  973. }
  974. });
  975. Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
  976. get: function() {
  977. return null;
  978. }
  979. });
  980. return XMLDTDEntity;
  981. }).call(this);
  982. }).call(this);
  983. },{"./NodeType":5,"./Utility":6,"./XMLNode":27}],19:[function(require,module,exports){
  984. // Generated by CoffeeScript 2.4.1
  985. (function() {
  986. var NodeType, XMLDTDNotation, XMLNode;
  987. XMLNode = require('./XMLNode');
  988. NodeType = require('./NodeType');
  989. // Represents a NOTATION entry in the DTD
  990. module.exports = XMLDTDNotation = (function() {
  991. class XMLDTDNotation extends XMLNode {
  992. // Initializes a new instance of `XMLDTDNotation`
  993. // `parent` the parent `XMLDocType` element
  994. // `name` the name of the notation
  995. // `value` an object with external entity details
  996. // `value.pubID` public identifier
  997. // `value.sysID` system identifier
  998. constructor(parent, name, value) {
  999. super(parent);
  1000. if (name == null) {
  1001. throw new Error("Missing DTD notation name. " + this.debugInfo(name));
  1002. }
  1003. if (!value.pubID && !value.sysID) {
  1004. throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
  1005. }
  1006. this.name = this.stringify.name(name);
  1007. this.type = NodeType.NotationDeclaration;
  1008. if (value.pubID != null) {
  1009. this.pubID = this.stringify.dtdPubID(value.pubID);
  1010. }
  1011. if (value.sysID != null) {
  1012. this.sysID = this.stringify.dtdSysID(value.sysID);
  1013. }
  1014. }
  1015. // Converts the XML fragment to string
  1016. // `options.pretty` pretty prints the result
  1017. // `options.indent` indentation for pretty print
  1018. // `options.offset` how many indentations to add to every line for pretty print
  1019. // `options.newline` newline sequence for pretty print
  1020. toString(options) {
  1021. return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
  1022. }
  1023. };
  1024. // DOM level 1
  1025. Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
  1026. get: function() {
  1027. return this.pubID;
  1028. }
  1029. });
  1030. Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
  1031. get: function() {
  1032. return this.sysID;
  1033. }
  1034. });
  1035. return XMLDTDNotation;
  1036. }).call(this);
  1037. }).call(this);
  1038. },{"./NodeType":5,"./XMLNode":27}],20:[function(require,module,exports){
  1039. // Generated by CoffeeScript 2.4.1
  1040. (function() {
  1041. var NodeType, XMLDeclaration, XMLNode, isObject;
  1042. ({isObject} = require('./Utility'));
  1043. XMLNode = require('./XMLNode');
  1044. NodeType = require('./NodeType');
  1045. // Represents the XML declaration
  1046. module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode {
  1047. // Initializes a new instance of `XMLDeclaration`
  1048. // `parent` the document object
  1049. // `version` A version number string, e.g. 1.0
  1050. // `encoding` Encoding declaration, e.g. UTF-8
  1051. // `standalone` standalone document declaration: true or false
  1052. constructor(parent, version, encoding, standalone) {
  1053. super(parent);
  1054. // arguments may also be passed as an object
  1055. if (isObject(version)) {
  1056. ({version, encoding, standalone} = version);
  1057. }
  1058. if (!version) {
  1059. version = '1.0';
  1060. }
  1061. this.type = NodeType.Declaration;
  1062. this.version = this.stringify.xmlVersion(version);
  1063. if (encoding != null) {
  1064. this.encoding = this.stringify.xmlEncoding(encoding);
  1065. }
  1066. if (standalone != null) {
  1067. this.standalone = this.stringify.xmlStandalone(standalone);
  1068. }
  1069. }
  1070. // Converts to string
  1071. // `options.pretty` pretty prints the result
  1072. // `options.indent` indentation for pretty print
  1073. // `options.offset` how many indentations to add to every line for pretty print
  1074. // `options.newline` newline sequence for pretty print
  1075. toString(options) {
  1076. return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
  1077. }
  1078. };
  1079. }).call(this);
  1080. },{"./NodeType":5,"./Utility":6,"./XMLNode":27}],21:[function(require,module,exports){
  1081. // Generated by CoffeeScript 2.4.1
  1082. (function() {
  1083. var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject;
  1084. ({isObject} = require('./Utility'));
  1085. XMLNode = require('./XMLNode');
  1086. NodeType = require('./NodeType');
  1087. XMLDTDAttList = require('./XMLDTDAttList');
  1088. XMLDTDEntity = require('./XMLDTDEntity');
  1089. XMLDTDElement = require('./XMLDTDElement');
  1090. XMLDTDNotation = require('./XMLDTDNotation');
  1091. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  1092. // Represents doctype declaration
  1093. module.exports = XMLDocType = (function() {
  1094. class XMLDocType extends XMLNode {
  1095. // Initializes a new instance of `XMLDocType`
  1096. // `parent` the document object
  1097. // `pubID` public identifier of the external subset
  1098. // `sysID` system identifier of the external subset
  1099. constructor(parent, pubID, sysID) {
  1100. var child, i, len, ref;
  1101. super(parent);
  1102. this.type = NodeType.DocType;
  1103. // set DTD name to the name of the root node
  1104. if (parent.children) {
  1105. ref = parent.children;
  1106. for (i = 0, len = ref.length; i < len; i++) {
  1107. child = ref[i];
  1108. if (child.type === NodeType.Element) {
  1109. this.name = child.name;
  1110. break;
  1111. }
  1112. }
  1113. }
  1114. this.documentObject = parent;
  1115. // arguments may also be passed as an object
  1116. if (isObject(pubID)) {
  1117. ({pubID, sysID} = pubID);
  1118. }
  1119. if (sysID == null) {
  1120. [sysID, pubID] = [pubID, sysID];
  1121. }
  1122. if (pubID != null) {
  1123. this.pubID = this.stringify.dtdPubID(pubID);
  1124. }
  1125. if (sysID != null) {
  1126. this.sysID = this.stringify.dtdSysID(sysID);
  1127. }
  1128. }
  1129. // Creates an element type declaration
  1130. // `name` element name
  1131. // `value` element content (defaults to #PCDATA)
  1132. element(name, value) {
  1133. var child;
  1134. child = new XMLDTDElement(this, name, value);
  1135. this.children.push(child);
  1136. return this;
  1137. }
  1138. // Creates an attribute declaration
  1139. // `elementName` the name of the element containing this attribute
  1140. // `attributeName` attribute name
  1141. // `attributeType` type of the attribute (defaults to CDATA)
  1142. // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
  1143. // #DEFAULT) (defaults to #IMPLIED)
  1144. // `defaultValue` default value of the attribute
  1145. // (only used for #FIXED or #DEFAULT)
  1146. attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  1147. var child;
  1148. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  1149. this.children.push(child);
  1150. return this;
  1151. }
  1152. // Creates a general entity declaration
  1153. // `name` the name of the entity
  1154. // `value` internal entity value or an object with external entity details
  1155. // `value.pubID` public identifier
  1156. // `value.sysID` system identifier
  1157. // `value.nData` notation declaration
  1158. entity(name, value) {
  1159. var child;
  1160. child = new XMLDTDEntity(this, false, name, value);
  1161. this.children.push(child);
  1162. return this;
  1163. }
  1164. // Creates a parameter entity declaration
  1165. // `name` the name of the entity
  1166. // `value` internal entity value or an object with external entity details
  1167. // `value.pubID` public identifier
  1168. // `value.sysID` system identifier
  1169. pEntity(name, value) {
  1170. var child;
  1171. child = new XMLDTDEntity(this, true, name, value);
  1172. this.children.push(child);
  1173. return this;
  1174. }
  1175. // Creates a NOTATION declaration
  1176. // `name` the name of the notation
  1177. // `value` an object with external entity details
  1178. // `value.pubID` public identifier
  1179. // `value.sysID` system identifier
  1180. notation(name, value) {
  1181. var child;
  1182. child = new XMLDTDNotation(this, name, value);
  1183. this.children.push(child);
  1184. return this;
  1185. }
  1186. // Converts to string
  1187. // `options.pretty` pretty prints the result
  1188. // `options.indent` indentation for pretty print
  1189. // `options.offset` how many indentations to add to every line for pretty print
  1190. // `options.newline` newline sequence for pretty print
  1191. toString(options) {
  1192. return this.options.writer.docType(this, this.options.writer.filterOptions(options));
  1193. }
  1194. // Aliases
  1195. ele(name, value) {
  1196. return this.element(name, value);
  1197. }
  1198. att(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  1199. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  1200. }
  1201. ent(name, value) {
  1202. return this.entity(name, value);
  1203. }
  1204. pent(name, value) {
  1205. return this.pEntity(name, value);
  1206. }
  1207. not(name, value) {
  1208. return this.notation(name, value);
  1209. }
  1210. up() {
  1211. return this.root() || this.documentObject;
  1212. }
  1213. isEqualNode(node) {
  1214. if (!super.isEqualNode(node)) {
  1215. return false;
  1216. }
  1217. if (node.name !== this.name) {
  1218. return false;
  1219. }
  1220. if (node.publicId !== this.publicId) {
  1221. return false;
  1222. }
  1223. if (node.systemId !== this.systemId) {
  1224. return false;
  1225. }
  1226. return true;
  1227. }
  1228. };
  1229. // DOM level 1
  1230. Object.defineProperty(XMLDocType.prototype, 'entities', {
  1231. get: function() {
  1232. var child, i, len, nodes, ref;
  1233. nodes = {};
  1234. ref = this.children;
  1235. for (i = 0, len = ref.length; i < len; i++) {
  1236. child = ref[i];
  1237. if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
  1238. nodes[child.name] = child;
  1239. }
  1240. }
  1241. return new XMLNamedNodeMap(nodes);
  1242. }
  1243. });
  1244. Object.defineProperty(XMLDocType.prototype, 'notations', {
  1245. get: function() {
  1246. var child, i, len, nodes, ref;
  1247. nodes = {};
  1248. ref = this.children;
  1249. for (i = 0, len = ref.length; i < len; i++) {
  1250. child = ref[i];
  1251. if (child.type === NodeType.NotationDeclaration) {
  1252. nodes[child.name] = child;
  1253. }
  1254. }
  1255. return new XMLNamedNodeMap(nodes);
  1256. }
  1257. });
  1258. // DOM level 2
  1259. Object.defineProperty(XMLDocType.prototype, 'publicId', {
  1260. get: function() {
  1261. return this.pubID;
  1262. }
  1263. });
  1264. Object.defineProperty(XMLDocType.prototype, 'systemId', {
  1265. get: function() {
  1266. return this.sysID;
  1267. }
  1268. });
  1269. Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
  1270. get: function() {
  1271. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1272. }
  1273. });
  1274. return XMLDocType;
  1275. }).call(this);
  1276. }).call(this);
  1277. },{"./NodeType":5,"./Utility":6,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLNamedNodeMap":26,"./XMLNode":27}],22:[function(require,module,exports){
  1278. // Generated by CoffeeScript 2.4.1
  1279. (function() {
  1280. var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject;
  1281. ({isPlainObject} = require('./Utility'));
  1282. XMLDOMImplementation = require('./XMLDOMImplementation');
  1283. XMLDOMConfiguration = require('./XMLDOMConfiguration');
  1284. XMLNode = require('./XMLNode');
  1285. NodeType = require('./NodeType');
  1286. XMLStringifier = require('./XMLStringifier');
  1287. XMLStringWriter = require('./XMLStringWriter');
  1288. // Represents an XML builder
  1289. module.exports = XMLDocument = (function() {
  1290. class XMLDocument extends XMLNode {
  1291. // Initializes a new instance of `XMLDocument`
  1292. // `options.keepNullNodes` whether nodes with null values will be kept
  1293. // or ignored: true or false
  1294. // `options.keepNullAttributes` whether attributes with null values will be
  1295. // kept or ignored: true or false
  1296. // `options.ignoreDecorators` whether decorator strings will be ignored when
  1297. // converting JS objects: true or false
  1298. // `options.separateArrayItems` whether array items are created as separate
  1299. // nodes when passed as an object value: true or false
  1300. // `options.noDoubleEncoding` whether existing html entities are encoded:
  1301. // true or false
  1302. // `options.stringify` a set of functions to use for converting values to
  1303. // strings
  1304. // `options.writer` the default XML writer to use for converting nodes to
  1305. // string. If the default writer is not set, the built-in XMLStringWriter
  1306. // will be used instead.
  1307. constructor(options) {
  1308. super(null);
  1309. this.name = "#document";
  1310. this.type = NodeType.Document;
  1311. this.documentURI = null;
  1312. this.domConfig = new XMLDOMConfiguration();
  1313. options || (options = {});
  1314. if (!options.writer) {
  1315. options.writer = new XMLStringWriter();
  1316. }
  1317. this.options = options;
  1318. this.stringify = new XMLStringifier(options);
  1319. }
  1320. // Ends the document and passes it to the given XML writer
  1321. // `writer` is either an XML writer or a plain object to pass to the
  1322. // constructor of the default XML writer. The default writer is assigned when
  1323. // creating the XML document. Following flags are recognized by the
  1324. // built-in XMLStringWriter:
  1325. // `writer.pretty` pretty prints the result
  1326. // `writer.indent` indentation for pretty print
  1327. // `writer.offset` how many indentations to add to every line for pretty print
  1328. // `writer.newline` newline sequence for pretty print
  1329. end(writer) {
  1330. var writerOptions;
  1331. writerOptions = {};
  1332. if (!writer) {
  1333. writer = this.options.writer;
  1334. } else if (isPlainObject(writer)) {
  1335. writerOptions = writer;
  1336. writer = this.options.writer;
  1337. }
  1338. return writer.document(this, writer.filterOptions(writerOptions));
  1339. }
  1340. // Converts the XML document to string
  1341. // `options.pretty` pretty prints the result
  1342. // `options.indent` indentation for pretty print
  1343. // `options.offset` how many indentations to add to every line for pretty print
  1344. // `options.newline` newline sequence for pretty print
  1345. toString(options) {
  1346. return this.options.writer.document(this, this.options.writer.filterOptions(options));
  1347. }
  1348. // DOM level 1 functions to be implemented later
  1349. createElement(tagName) {
  1350. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1351. }
  1352. createDocumentFragment() {
  1353. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1354. }
  1355. createTextNode(data) {
  1356. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1357. }
  1358. createComment(data) {
  1359. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1360. }
  1361. createCDATASection(data) {
  1362. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1363. }
  1364. createProcessingInstruction(target, data) {
  1365. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1366. }
  1367. createAttribute(name) {
  1368. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1369. }
  1370. createEntityReference(name) {
  1371. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1372. }
  1373. getElementsByTagName(tagname) {
  1374. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1375. }
  1376. // DOM level 2 functions to be implemented later
  1377. importNode(importedNode, deep) {
  1378. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1379. }
  1380. createElementNS(namespaceURI, qualifiedName) {
  1381. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1382. }
  1383. createAttributeNS(namespaceURI, qualifiedName) {
  1384. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1385. }
  1386. getElementsByTagNameNS(namespaceURI, localName) {
  1387. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1388. }
  1389. getElementById(elementId) {
  1390. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1391. }
  1392. // DOM level 3 functions to be implemented later
  1393. adoptNode(source) {
  1394. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1395. }
  1396. normalizeDocument() {
  1397. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1398. }
  1399. renameNode(node, namespaceURI, qualifiedName) {
  1400. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1401. }
  1402. // DOM level 4 functions to be implemented later
  1403. getElementsByClassName(classNames) {
  1404. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1405. }
  1406. createEvent(eventInterface) {
  1407. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1408. }
  1409. createRange() {
  1410. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1411. }
  1412. createNodeIterator(root, whatToShow, filter) {
  1413. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1414. }
  1415. createTreeWalker(root, whatToShow, filter) {
  1416. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1417. }
  1418. };
  1419. // DOM level 1
  1420. Object.defineProperty(XMLDocument.prototype, 'implementation', {
  1421. value: new XMLDOMImplementation()
  1422. });
  1423. Object.defineProperty(XMLDocument.prototype, 'doctype', {
  1424. get: function() {
  1425. var child, i, len, ref;
  1426. ref = this.children;
  1427. for (i = 0, len = ref.length; i < len; i++) {
  1428. child = ref[i];
  1429. if (child.type === NodeType.DocType) {
  1430. return child;
  1431. }
  1432. }
  1433. return null;
  1434. }
  1435. });
  1436. Object.defineProperty(XMLDocument.prototype, 'documentElement', {
  1437. get: function() {
  1438. return this.rootObject || null;
  1439. }
  1440. });
  1441. // DOM level 3
  1442. Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
  1443. get: function() {
  1444. return null;
  1445. }
  1446. });
  1447. Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
  1448. get: function() {
  1449. return false;
  1450. }
  1451. });
  1452. Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
  1453. get: function() {
  1454. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  1455. return this.children[0].encoding;
  1456. } else {
  1457. return null;
  1458. }
  1459. }
  1460. });
  1461. Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
  1462. get: function() {
  1463. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  1464. return this.children[0].standalone === 'yes';
  1465. } else {
  1466. return false;
  1467. }
  1468. }
  1469. });
  1470. Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
  1471. get: function() {
  1472. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  1473. return this.children[0].version;
  1474. } else {
  1475. return "1.0";
  1476. }
  1477. }
  1478. });
  1479. // DOM level 4
  1480. Object.defineProperty(XMLDocument.prototype, 'URL', {
  1481. get: function() {
  1482. return this.documentURI;
  1483. }
  1484. });
  1485. Object.defineProperty(XMLDocument.prototype, 'origin', {
  1486. get: function() {
  1487. return null;
  1488. }
  1489. });
  1490. Object.defineProperty(XMLDocument.prototype, 'compatMode', {
  1491. get: function() {
  1492. return null;
  1493. }
  1494. });
  1495. Object.defineProperty(XMLDocument.prototype, 'characterSet', {
  1496. get: function() {
  1497. return null;
  1498. }
  1499. });
  1500. Object.defineProperty(XMLDocument.prototype, 'contentType', {
  1501. get: function() {
  1502. return null;
  1503. }
  1504. });
  1505. return XMLDocument;
  1506. }).call(this);
  1507. }).call(this);
  1508. },{"./NodeType":5,"./Utility":6,"./XMLDOMConfiguration":12,"./XMLDOMImplementation":14,"./XMLNode":27,"./XMLStringWriter":32,"./XMLStringifier":33}],23:[function(require,module,exports){
  1509. // Generated by CoffeeScript 2.4.1
  1510. (function() {
  1511. var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject,
  1512. hasProp = {}.hasOwnProperty;
  1513. ({isObject, isFunction, isPlainObject, getValue} = require('./Utility'));
  1514. NodeType = require('./NodeType');
  1515. XMLDocument = require('./XMLDocument');
  1516. XMLElement = require('./XMLElement');
  1517. XMLCData = require('./XMLCData');
  1518. XMLComment = require('./XMLComment');
  1519. XMLRaw = require('./XMLRaw');
  1520. XMLText = require('./XMLText');
  1521. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  1522. XMLDeclaration = require('./XMLDeclaration');
  1523. XMLDocType = require('./XMLDocType');
  1524. XMLDTDAttList = require('./XMLDTDAttList');
  1525. XMLDTDEntity = require('./XMLDTDEntity');
  1526. XMLDTDElement = require('./XMLDTDElement');
  1527. XMLDTDNotation = require('./XMLDTDNotation');
  1528. XMLAttribute = require('./XMLAttribute');
  1529. XMLStringifier = require('./XMLStringifier');
  1530. XMLStringWriter = require('./XMLStringWriter');
  1531. WriterState = require('./WriterState');
  1532. // Represents an XML builder
  1533. module.exports = XMLDocumentCB = class XMLDocumentCB {
  1534. // Initializes a new instance of `XMLDocumentCB`
  1535. // `options.keepNullNodes` whether nodes with null values will be kept
  1536. // or ignored: true or false
  1537. // `options.keepNullAttributes` whether attributes with null values will be
  1538. // kept or ignored: true or false
  1539. // `options.ignoreDecorators` whether decorator strings will be ignored when
  1540. // converting JS objects: true or false
  1541. // `options.separateArrayItems` whether array items are created as separate
  1542. // nodes when passed as an object value: true or false
  1543. // `options.noDoubleEncoding` whether existing html entities are encoded:
  1544. // true or false
  1545. // `options.stringify` a set of functions to use for converting values to
  1546. // strings
  1547. // `options.writer` the default XML writer to use for converting nodes to
  1548. // string. If the default writer is not set, the built-in XMLStringWriter
  1549. // will be used instead.
  1550. // `onData` the function to be called when a new chunk of XML is output. The
  1551. // string containing the XML chunk is passed to `onData` as its first
  1552. // argument, and the current indentation level as its second argument.
  1553. // `onEnd` the function to be called when the XML document is completed with
  1554. // `end`. `onEnd` does not receive any arguments.
  1555. constructor(options, onData, onEnd) {
  1556. var writerOptions;
  1557. this.name = "?xml";
  1558. this.type = NodeType.Document;
  1559. options || (options = {});
  1560. writerOptions = {};
  1561. if (!options.writer) {
  1562. options.writer = new XMLStringWriter();
  1563. } else if (isPlainObject(options.writer)) {
  1564. writerOptions = options.writer;
  1565. options.writer = new XMLStringWriter();
  1566. }
  1567. this.options = options;
  1568. this.writer = options.writer;
  1569. this.writerOptions = this.writer.filterOptions(writerOptions);
  1570. this.stringify = new XMLStringifier(options);
  1571. this.onDataCallback = onData || function() {};
  1572. this.onEndCallback = onEnd || function() {};
  1573. this.currentNode = null;
  1574. this.currentLevel = -1;
  1575. this.openTags = {};
  1576. this.documentStarted = false;
  1577. this.documentCompleted = false;
  1578. this.root = null;
  1579. }
  1580. // Creates a child element node from the given XMLNode
  1581. // `node` the child node
  1582. createChildNode(node) {
  1583. var att, attName, attributes, child, i, len, ref, ref1;
  1584. switch (node.type) {
  1585. case NodeType.CData:
  1586. this.cdata(node.value);
  1587. break;
  1588. case NodeType.Comment:
  1589. this.comment(node.value);
  1590. break;
  1591. case NodeType.Element:
  1592. attributes = {};
  1593. ref = node.attribs;
  1594. for (attName in ref) {
  1595. if (!hasProp.call(ref, attName)) continue;
  1596. att = ref[attName];
  1597. attributes[attName] = att.value;
  1598. }
  1599. this.node(node.name, attributes);
  1600. break;
  1601. case NodeType.Dummy:
  1602. this.dummy();
  1603. break;
  1604. case NodeType.Raw:
  1605. this.raw(node.value);
  1606. break;
  1607. case NodeType.Text:
  1608. this.text(node.value);
  1609. break;
  1610. case NodeType.ProcessingInstruction:
  1611. this.instruction(node.target, node.value);
  1612. break;
  1613. default:
  1614. throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
  1615. }
  1616. ref1 = node.children;
  1617. // write child nodes recursively
  1618. for (i = 0, len = ref1.length; i < len; i++) {
  1619. child = ref1[i];
  1620. this.createChildNode(child);
  1621. if (child.type === NodeType.Element) {
  1622. this.up();
  1623. }
  1624. }
  1625. return this;
  1626. }
  1627. // Creates a dummy node
  1628. dummy() {
  1629. // no-op, just return this
  1630. return this;
  1631. }
  1632. // Creates a node
  1633. // `name` name of the node
  1634. // `attributes` an object containing name/value pairs of attributes
  1635. // `text` element text
  1636. node(name, attributes, text) {
  1637. if (name == null) {
  1638. throw new Error("Missing node name.");
  1639. }
  1640. if (this.root && this.currentLevel === -1) {
  1641. throw new Error("Document can only have one root node. " + this.debugInfo(name));
  1642. }
  1643. this.openCurrent();
  1644. name = getValue(name);
  1645. if (attributes == null) {
  1646. attributes = {};
  1647. }
  1648. attributes = getValue(attributes);
  1649. // swap argument order: text <-> attributes
  1650. if (!isObject(attributes)) {
  1651. [text, attributes] = [attributes, text];
  1652. }
  1653. this.currentNode = new XMLElement(this, name, attributes);
  1654. this.currentNode.children = false;
  1655. this.currentLevel++;
  1656. this.openTags[this.currentLevel] = this.currentNode;
  1657. if (text != null) {
  1658. this.text(text);
  1659. }
  1660. return this;
  1661. }
  1662. // Creates a child element node or an element type declaration when called
  1663. // inside the DTD
  1664. // `name` name of the node
  1665. // `attributes` an object containing name/value pairs of attributes
  1666. // `text` element text
  1667. element(name, attributes, text) {
  1668. var child, i, len, oldValidationFlag, ref, root;
  1669. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  1670. this.dtdElement(...arguments);
  1671. } else {
  1672. if (Array.isArray(name) || isObject(name) || isFunction(name)) {
  1673. oldValidationFlag = this.options.noValidation;
  1674. this.options.noValidation = true;
  1675. root = new XMLDocument(this.options).element('TEMP_ROOT');
  1676. root.element(name);
  1677. this.options.noValidation = oldValidationFlag;
  1678. ref = root.children;
  1679. for (i = 0, len = ref.length; i < len; i++) {
  1680. child = ref[i];
  1681. this.createChildNode(child);
  1682. if (child.type === NodeType.Element) {
  1683. this.up();
  1684. }
  1685. }
  1686. } else {
  1687. this.node(name, attributes, text);
  1688. }
  1689. }
  1690. return this;
  1691. }
  1692. // Adds or modifies an attribute
  1693. // `name` attribute name
  1694. // `value` attribute value
  1695. attribute(name, value) {
  1696. var attName, attValue;
  1697. if (!this.currentNode || this.currentNode.children) {
  1698. throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
  1699. }
  1700. if (name != null) {
  1701. name = getValue(name);
  1702. }
  1703. if (isObject(name)) { // expand if object
  1704. for (attName in name) {
  1705. if (!hasProp.call(name, attName)) continue;
  1706. attValue = name[attName];
  1707. this.attribute(attName, attValue);
  1708. }
  1709. } else {
  1710. if (isFunction(value)) {
  1711. value = value.apply();
  1712. }
  1713. if (this.options.keepNullAttributes && (value == null)) {
  1714. this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
  1715. } else if (value != null) {
  1716. this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
  1717. }
  1718. }
  1719. return this;
  1720. }
  1721. // Creates a text node
  1722. // `value` element text
  1723. text(value) {
  1724. var node;
  1725. this.openCurrent();
  1726. node = new XMLText(this, value);
  1727. this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1728. return this;
  1729. }
  1730. // Creates a CDATA node
  1731. // `value` element text without CDATA delimiters
  1732. cdata(value) {
  1733. var node;
  1734. this.openCurrent();
  1735. node = new XMLCData(this, value);
  1736. this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1737. return this;
  1738. }
  1739. // Creates a comment node
  1740. // `value` comment text
  1741. comment(value) {
  1742. var node;
  1743. this.openCurrent();
  1744. node = new XMLComment(this, value);
  1745. this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1746. return this;
  1747. }
  1748. // Adds unescaped raw text
  1749. // `value` text
  1750. raw(value) {
  1751. var node;
  1752. this.openCurrent();
  1753. node = new XMLRaw(this, value);
  1754. this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1755. return this;
  1756. }
  1757. // Adds a processing instruction
  1758. // `target` instruction target
  1759. // `value` instruction value
  1760. instruction(target, value) {
  1761. var i, insTarget, insValue, len, node;
  1762. this.openCurrent();
  1763. if (target != null) {
  1764. target = getValue(target);
  1765. }
  1766. if (value != null) {
  1767. value = getValue(value);
  1768. }
  1769. if (Array.isArray(target)) { // expand if array
  1770. for (i = 0, len = target.length; i < len; i++) {
  1771. insTarget = target[i];
  1772. this.instruction(insTarget);
  1773. }
  1774. } else if (isObject(target)) { // expand if object
  1775. for (insTarget in target) {
  1776. if (!hasProp.call(target, insTarget)) continue;
  1777. insValue = target[insTarget];
  1778. this.instruction(insTarget, insValue);
  1779. }
  1780. } else {
  1781. if (isFunction(value)) {
  1782. value = value.apply();
  1783. }
  1784. node = new XMLProcessingInstruction(this, target, value);
  1785. this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1786. }
  1787. return this;
  1788. }
  1789. // Creates the xml declaration
  1790. // `version` A version number string, e.g. 1.0
  1791. // `encoding` Encoding declaration, e.g. UTF-8
  1792. // `standalone` standalone document declaration: true or false
  1793. declaration(version, encoding, standalone) {
  1794. var node;
  1795. this.openCurrent();
  1796. if (this.documentStarted) {
  1797. throw new Error("declaration() must be the first node.");
  1798. }
  1799. node = new XMLDeclaration(this, version, encoding, standalone);
  1800. this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1801. return this;
  1802. }
  1803. // Creates the document type declaration
  1804. // `root` the name of the root node
  1805. // `pubID` the public identifier of the external subset
  1806. // `sysID` the system identifier of the external subset
  1807. doctype(root, pubID, sysID) {
  1808. this.openCurrent();
  1809. if (root == null) {
  1810. throw new Error("Missing root node name.");
  1811. }
  1812. if (this.root) {
  1813. throw new Error("dtd() must come before the root node.");
  1814. }
  1815. this.currentNode = new XMLDocType(this, pubID, sysID);
  1816. this.currentNode.rootNodeName = root;
  1817. this.currentNode.children = false;
  1818. this.currentLevel++;
  1819. this.openTags[this.currentLevel] = this.currentNode;
  1820. return this;
  1821. }
  1822. // Creates an element type declaration
  1823. // `name` element name
  1824. // `value` element content (defaults to #PCDATA)
  1825. dtdElement(name, value) {
  1826. var node;
  1827. this.openCurrent();
  1828. node = new XMLDTDElement(this, name, value);
  1829. this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1830. return this;
  1831. }
  1832. // Creates an attribute declaration
  1833. // `elementName` the name of the element containing this attribute
  1834. // `attributeName` attribute name
  1835. // `attributeType` type of the attribute (defaults to CDATA)
  1836. // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
  1837. // #DEFAULT) (defaults to #IMPLIED)
  1838. // `defaultValue` default value of the attribute
  1839. // (only used for #FIXED or #DEFAULT)
  1840. attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  1841. var node;
  1842. this.openCurrent();
  1843. node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  1844. this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1845. return this;
  1846. }
  1847. // Creates a general entity declaration
  1848. // `name` the name of the entity
  1849. // `value` internal entity value or an object with external entity details
  1850. // `value.pubID` public identifier
  1851. // `value.sysID` system identifier
  1852. // `value.nData` notation declaration
  1853. entity(name, value) {
  1854. var node;
  1855. this.openCurrent();
  1856. node = new XMLDTDEntity(this, false, name, value);
  1857. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1858. return this;
  1859. }
  1860. // Creates a parameter entity declaration
  1861. // `name` the name of the entity
  1862. // `value` internal entity value or an object with external entity details
  1863. // `value.pubID` public identifier
  1864. // `value.sysID` system identifier
  1865. pEntity(name, value) {
  1866. var node;
  1867. this.openCurrent();
  1868. node = new XMLDTDEntity(this, true, name, value);
  1869. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1870. return this;
  1871. }
  1872. // Creates a NOTATION declaration
  1873. // `name` the name of the notation
  1874. // `value` an object with external entity details
  1875. // `value.pubID` public identifier
  1876. // `value.sysID` system identifier
  1877. notation(name, value) {
  1878. var node;
  1879. this.openCurrent();
  1880. node = new XMLDTDNotation(this, name, value);
  1881. this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  1882. return this;
  1883. }
  1884. // Gets the parent node
  1885. up() {
  1886. if (this.currentLevel < 0) {
  1887. throw new Error("The document node has no parent.");
  1888. }
  1889. if (this.currentNode) {
  1890. if (this.currentNode.children) {
  1891. this.closeNode(this.currentNode);
  1892. } else {
  1893. this.openNode(this.currentNode);
  1894. }
  1895. this.currentNode = null;
  1896. } else {
  1897. this.closeNode(this.openTags[this.currentLevel]);
  1898. }
  1899. delete this.openTags[this.currentLevel];
  1900. this.currentLevel--;
  1901. return this;
  1902. }
  1903. // Ends the document
  1904. end() {
  1905. while (this.currentLevel >= 0) {
  1906. this.up();
  1907. }
  1908. return this.onEnd();
  1909. }
  1910. // Opens the current parent node
  1911. openCurrent() {
  1912. if (this.currentNode) {
  1913. this.currentNode.children = true;
  1914. return this.openNode(this.currentNode);
  1915. }
  1916. }
  1917. // Writes the opening tag of the current node or the entire node if it has
  1918. // no child nodes
  1919. openNode(node) {
  1920. var att, chunk, name, ref;
  1921. if (!node.isOpen) {
  1922. if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
  1923. this.root = node;
  1924. }
  1925. chunk = '';
  1926. if (node.type === NodeType.Element) {
  1927. this.writerOptions.state = WriterState.OpenTag;
  1928. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
  1929. ref = node.attribs;
  1930. for (name in ref) {
  1931. if (!hasProp.call(ref, name)) continue;
  1932. att = ref[name];
  1933. chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
  1934. }
  1935. chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
  1936. this.writerOptions.state = WriterState.InsideTag; // if node.type is NodeType.DocType
  1937. } else {
  1938. this.writerOptions.state = WriterState.OpenTag;
  1939. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
  1940. // external identifier
  1941. if (node.pubID && node.sysID) {
  1942. chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  1943. } else if (node.sysID) {
  1944. chunk += ' SYSTEM "' + node.sysID + '"';
  1945. }
  1946. // internal subset
  1947. if (node.children) {
  1948. chunk += ' [';
  1949. this.writerOptions.state = WriterState.InsideTag;
  1950. } else {
  1951. this.writerOptions.state = WriterState.CloseTag;
  1952. chunk += '>';
  1953. }
  1954. chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
  1955. }
  1956. this.onData(chunk, this.currentLevel);
  1957. return node.isOpen = true;
  1958. }
  1959. }
  1960. // Writes the closing tag of the current node
  1961. closeNode(node) {
  1962. var chunk;
  1963. if (!node.isClosed) {
  1964. chunk = '';
  1965. this.writerOptions.state = WriterState.CloseTag;
  1966. if (node.type === NodeType.Element) {
  1967. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel); // if node.type is NodeType.DocType
  1968. } else {
  1969. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
  1970. }
  1971. this.writerOptions.state = WriterState.None;
  1972. this.onData(chunk, this.currentLevel);
  1973. return node.isClosed = true;
  1974. }
  1975. }
  1976. // Called when a new chunk of XML is output
  1977. // `chunk` a string containing the XML chunk
  1978. // `level` current indentation level
  1979. onData(chunk, level) {
  1980. this.documentStarted = true;
  1981. return this.onDataCallback(chunk, level + 1);
  1982. }
  1983. // Called when the XML document is completed
  1984. onEnd() {
  1985. this.documentCompleted = true;
  1986. return this.onEndCallback();
  1987. }
  1988. // Returns debug string
  1989. debugInfo(name) {
  1990. if (name == null) {
  1991. return "";
  1992. } else {
  1993. return "node: <" + name + ">";
  1994. }
  1995. }
  1996. // Node aliases
  1997. ele() {
  1998. return this.element(...arguments);
  1999. }
  2000. nod(name, attributes, text) {
  2001. return this.node(name, attributes, text);
  2002. }
  2003. txt(value) {
  2004. return this.text(value);
  2005. }
  2006. dat(value) {
  2007. return this.cdata(value);
  2008. }
  2009. com(value) {
  2010. return this.comment(value);
  2011. }
  2012. ins(target, value) {
  2013. return this.instruction(target, value);
  2014. }
  2015. dec(version, encoding, standalone) {
  2016. return this.declaration(version, encoding, standalone);
  2017. }
  2018. dtd(root, pubID, sysID) {
  2019. return this.doctype(root, pubID, sysID);
  2020. }
  2021. e(name, attributes, text) {
  2022. return this.element(name, attributes, text);
  2023. }
  2024. n(name, attributes, text) {
  2025. return this.node(name, attributes, text);
  2026. }
  2027. t(value) {
  2028. return this.text(value);
  2029. }
  2030. d(value) {
  2031. return this.cdata(value);
  2032. }
  2033. c(value) {
  2034. return this.comment(value);
  2035. }
  2036. r(value) {
  2037. return this.raw(value);
  2038. }
  2039. i(target, value) {
  2040. return this.instruction(target, value);
  2041. }
  2042. // Attribute aliases
  2043. att() {
  2044. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  2045. return this.attList(...arguments);
  2046. } else {
  2047. return this.attribute(...arguments);
  2048. }
  2049. }
  2050. a() {
  2051. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  2052. return this.attList(...arguments);
  2053. } else {
  2054. return this.attribute(...arguments);
  2055. }
  2056. }
  2057. // DTD aliases
  2058. // att() and ele() are defined above
  2059. ent(name, value) {
  2060. return this.entity(name, value);
  2061. }
  2062. pent(name, value) {
  2063. return this.pEntity(name, value);
  2064. }
  2065. not(name, value) {
  2066. return this.notation(name, value);
  2067. }
  2068. };
  2069. }).call(this);
  2070. },{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLAttribute":8,"./XMLCData":9,"./XMLComment":11,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDocument":22,"./XMLElement":25,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLStringWriter":32,"./XMLStringifier":33,"./XMLText":34}],24:[function(require,module,exports){
  2071. // Generated by CoffeeScript 2.4.1
  2072. (function() {
  2073. var NodeType, XMLDummy, XMLNode;
  2074. XMLNode = require('./XMLNode');
  2075. NodeType = require('./NodeType');
  2076. // Represents a raw node
  2077. module.exports = XMLDummy = class XMLDummy extends XMLNode {
  2078. // Initializes a new instance of `XMLDummy`
  2079. // `XMLDummy` is a special node representing a node with
  2080. // a null value. Dummy nodes are created while recursively
  2081. // building the XML tree. Simply skipping null values doesn't
  2082. // work because that would break the recursive chain.
  2083. constructor(parent) {
  2084. super(parent);
  2085. this.type = NodeType.Dummy;
  2086. }
  2087. // Creates and returns a deep clone of `this`
  2088. clone() {
  2089. return Object.create(this);
  2090. }
  2091. // Converts the XML fragment to string
  2092. // `options.pretty` pretty prints the result
  2093. // `options.indent` indentation for pretty print
  2094. // `options.offset` how many indentations to add to every line for pretty print
  2095. // `options.newline` newline sequence for pretty print
  2096. toString(options) {
  2097. return '';
  2098. }
  2099. };
  2100. }).call(this);
  2101. },{"./NodeType":5,"./XMLNode":27}],25:[function(require,module,exports){
  2102. // Generated by CoffeeScript 2.4.1
  2103. (function() {
  2104. var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject,
  2105. hasProp = {}.hasOwnProperty;
  2106. ({isObject, isFunction, getValue} = require('./Utility'));
  2107. XMLNode = require('./XMLNode');
  2108. NodeType = require('./NodeType');
  2109. XMLAttribute = require('./XMLAttribute');
  2110. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  2111. // Represents an element of the XML document
  2112. module.exports = XMLElement = (function() {
  2113. class XMLElement extends XMLNode {
  2114. // Initializes a new instance of `XMLElement`
  2115. // `parent` the parent node
  2116. // `name` element name
  2117. // `attributes` an object containing name/value pairs of attributes
  2118. constructor(parent, name, attributes) {
  2119. var child, j, len, ref;
  2120. super(parent);
  2121. if (name == null) {
  2122. throw new Error("Missing element name. " + this.debugInfo());
  2123. }
  2124. this.name = this.stringify.name(name);
  2125. this.type = NodeType.Element;
  2126. this.attribs = {};
  2127. this.schemaTypeInfo = null;
  2128. if (attributes != null) {
  2129. this.attribute(attributes);
  2130. }
  2131. // set properties if this is the root node
  2132. if (parent.type === NodeType.Document) {
  2133. this.isRoot = true;
  2134. this.documentObject = parent;
  2135. parent.rootObject = this;
  2136. // set dtd name
  2137. if (parent.children) {
  2138. ref = parent.children;
  2139. for (j = 0, len = ref.length; j < len; j++) {
  2140. child = ref[j];
  2141. if (child.type === NodeType.DocType) {
  2142. child.name = this.name;
  2143. break;
  2144. }
  2145. }
  2146. }
  2147. }
  2148. }
  2149. // Creates and returns a deep clone of `this`
  2150. clone() {
  2151. var att, attName, clonedSelf, ref;
  2152. clonedSelf = Object.create(this);
  2153. // remove document element
  2154. if (clonedSelf.isRoot) {
  2155. clonedSelf.documentObject = null;
  2156. }
  2157. // clone attributes
  2158. clonedSelf.attribs = {};
  2159. ref = this.attribs;
  2160. for (attName in ref) {
  2161. if (!hasProp.call(ref, attName)) continue;
  2162. att = ref[attName];
  2163. clonedSelf.attribs[attName] = att.clone();
  2164. }
  2165. // clone child nodes
  2166. clonedSelf.children = [];
  2167. this.children.forEach(function(child) {
  2168. var clonedChild;
  2169. clonedChild = child.clone();
  2170. clonedChild.parent = clonedSelf;
  2171. return clonedSelf.children.push(clonedChild);
  2172. });
  2173. return clonedSelf;
  2174. }
  2175. // Adds or modifies an attribute
  2176. // `name` attribute name
  2177. // `value` attribute value
  2178. attribute(name, value) {
  2179. var attName, attValue;
  2180. if (name != null) {
  2181. name = getValue(name);
  2182. }
  2183. if (isObject(name)) { // expand if object
  2184. for (attName in name) {
  2185. if (!hasProp.call(name, attName)) continue;
  2186. attValue = name[attName];
  2187. this.attribute(attName, attValue);
  2188. }
  2189. } else {
  2190. if (isFunction(value)) {
  2191. value = value.apply();
  2192. }
  2193. if (this.options.keepNullAttributes && (value == null)) {
  2194. this.attribs[name] = new XMLAttribute(this, name, "");
  2195. } else if (value != null) {
  2196. this.attribs[name] = new XMLAttribute(this, name, value);
  2197. }
  2198. }
  2199. return this;
  2200. }
  2201. // Removes an attribute
  2202. // `name` attribute name
  2203. removeAttribute(name) {
  2204. var attName, j, len;
  2205. // Also defined in DOM level 1
  2206. // removeAttribute(name) removes an attribute by name.
  2207. if (name == null) {
  2208. throw new Error("Missing attribute name. " + this.debugInfo());
  2209. }
  2210. name = getValue(name);
  2211. if (Array.isArray(name)) { // expand if array
  2212. for (j = 0, len = name.length; j < len; j++) {
  2213. attName = name[j];
  2214. delete this.attribs[attName];
  2215. }
  2216. } else {
  2217. delete this.attribs[name];
  2218. }
  2219. return this;
  2220. }
  2221. // Converts the XML fragment to string
  2222. // `options.pretty` pretty prints the result
  2223. // `options.indent` indentation for pretty print
  2224. // `options.offset` how many indentations to add to every line for pretty print
  2225. // `options.newline` newline sequence for pretty print
  2226. // `options.allowEmpty` do not self close empty element tags
  2227. toString(options) {
  2228. return this.options.writer.element(this, this.options.writer.filterOptions(options));
  2229. }
  2230. // Aliases
  2231. att(name, value) {
  2232. return this.attribute(name, value);
  2233. }
  2234. a(name, value) {
  2235. return this.attribute(name, value);
  2236. }
  2237. // DOM Level 1
  2238. getAttribute(name) {
  2239. if (this.attribs.hasOwnProperty(name)) {
  2240. return this.attribs[name].value;
  2241. } else {
  2242. return null;
  2243. }
  2244. }
  2245. setAttribute(name, value) {
  2246. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2247. }
  2248. getAttributeNode(name) {
  2249. if (this.attribs.hasOwnProperty(name)) {
  2250. return this.attribs[name];
  2251. } else {
  2252. return null;
  2253. }
  2254. }
  2255. setAttributeNode(newAttr) {
  2256. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2257. }
  2258. removeAttributeNode(oldAttr) {
  2259. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2260. }
  2261. getElementsByTagName(name) {
  2262. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2263. }
  2264. // DOM Level 2
  2265. getAttributeNS(namespaceURI, localName) {
  2266. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2267. }
  2268. setAttributeNS(namespaceURI, qualifiedName, value) {
  2269. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2270. }
  2271. removeAttributeNS(namespaceURI, localName) {
  2272. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2273. }
  2274. getAttributeNodeNS(namespaceURI, localName) {
  2275. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2276. }
  2277. setAttributeNodeNS(newAttr) {
  2278. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2279. }
  2280. getElementsByTagNameNS(namespaceURI, localName) {
  2281. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2282. }
  2283. hasAttribute(name) {
  2284. return this.attribs.hasOwnProperty(name);
  2285. }
  2286. hasAttributeNS(namespaceURI, localName) {
  2287. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2288. }
  2289. // DOM Level 3
  2290. setIdAttribute(name, isId) {
  2291. if (this.attribs.hasOwnProperty(name)) {
  2292. return this.attribs[name].isId;
  2293. } else {
  2294. return isId;
  2295. }
  2296. }
  2297. setIdAttributeNS(namespaceURI, localName, isId) {
  2298. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2299. }
  2300. setIdAttributeNode(idAttr, isId) {
  2301. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2302. }
  2303. // DOM Level 4
  2304. getElementsByTagName(tagname) {
  2305. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2306. }
  2307. getElementsByTagNameNS(namespaceURI, localName) {
  2308. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2309. }
  2310. getElementsByClassName(classNames) {
  2311. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2312. }
  2313. isEqualNode(node) {
  2314. var i, j, ref;
  2315. if (!super.isEqualNode(node)) {
  2316. return false;
  2317. }
  2318. if (node.namespaceURI !== this.namespaceURI) {
  2319. return false;
  2320. }
  2321. if (node.prefix !== this.prefix) {
  2322. return false;
  2323. }
  2324. if (node.localName !== this.localName) {
  2325. return false;
  2326. }
  2327. if (node.attribs.length !== this.attribs.length) {
  2328. return false;
  2329. }
  2330. for (i = j = 0, ref = this.attribs.length - 1; (0 <= ref ? j <= ref : j >= ref); i = 0 <= ref ? ++j : --j) {
  2331. if (!this.attribs[i].isEqualNode(node.attribs[i])) {
  2332. return false;
  2333. }
  2334. }
  2335. return true;
  2336. }
  2337. };
  2338. // DOM level 1
  2339. Object.defineProperty(XMLElement.prototype, 'tagName', {
  2340. get: function() {
  2341. return this.name;
  2342. }
  2343. });
  2344. // DOM level 4
  2345. Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
  2346. get: function() {
  2347. return '';
  2348. }
  2349. });
  2350. Object.defineProperty(XMLElement.prototype, 'prefix', {
  2351. get: function() {
  2352. return '';
  2353. }
  2354. });
  2355. Object.defineProperty(XMLElement.prototype, 'localName', {
  2356. get: function() {
  2357. return this.name;
  2358. }
  2359. });
  2360. Object.defineProperty(XMLElement.prototype, 'id', {
  2361. get: function() {
  2362. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2363. }
  2364. });
  2365. Object.defineProperty(XMLElement.prototype, 'className', {
  2366. get: function() {
  2367. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2368. }
  2369. });
  2370. Object.defineProperty(XMLElement.prototype, 'classList', {
  2371. get: function() {
  2372. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2373. }
  2374. });
  2375. Object.defineProperty(XMLElement.prototype, 'attributes', {
  2376. get: function() {
  2377. if (!this.attributeMap || !this.attributeMap.nodes) {
  2378. this.attributeMap = new XMLNamedNodeMap(this.attribs);
  2379. }
  2380. return this.attributeMap;
  2381. }
  2382. });
  2383. return XMLElement;
  2384. }).call(this);
  2385. }).call(this);
  2386. },{"./NodeType":5,"./Utility":6,"./XMLAttribute":8,"./XMLNamedNodeMap":26,"./XMLNode":27}],26:[function(require,module,exports){
  2387. // Generated by CoffeeScript 2.4.1
  2388. (function() {
  2389. // Represents a map of nodes accessed by a string key
  2390. var XMLNamedNodeMap;
  2391. module.exports = XMLNamedNodeMap = (function() {
  2392. class XMLNamedNodeMap {
  2393. // Initializes a new instance of `XMLNamedNodeMap`
  2394. // This is just a wrapper around an ordinary
  2395. // JS object.
  2396. // `nodes` the object containing nodes.
  2397. constructor(nodes) {
  2398. this.nodes = nodes;
  2399. }
  2400. // Creates and returns a deep clone of `this`
  2401. clone() {
  2402. // this class should not be cloned since it wraps
  2403. // around a given object. The calling function should check
  2404. // whether the wrapped object is null and supply a new object
  2405. // (from the clone).
  2406. return this.nodes = null;
  2407. }
  2408. // DOM Level 1
  2409. getNamedItem(name) {
  2410. return this.nodes[name];
  2411. }
  2412. setNamedItem(node) {
  2413. var oldNode;
  2414. oldNode = this.nodes[node.nodeName];
  2415. this.nodes[node.nodeName] = node;
  2416. return oldNode || null;
  2417. }
  2418. removeNamedItem(name) {
  2419. var oldNode;
  2420. oldNode = this.nodes[name];
  2421. delete this.nodes[name];
  2422. return oldNode || null;
  2423. }
  2424. item(index) {
  2425. return this.nodes[Object.keys(this.nodes)[index]] || null;
  2426. }
  2427. // DOM level 2 functions to be implemented later
  2428. getNamedItemNS(namespaceURI, localName) {
  2429. throw new Error("This DOM method is not implemented.");
  2430. }
  2431. setNamedItemNS(node) {
  2432. throw new Error("This DOM method is not implemented.");
  2433. }
  2434. removeNamedItemNS(namespaceURI, localName) {
  2435. throw new Error("This DOM method is not implemented.");
  2436. }
  2437. };
  2438. // DOM level 1
  2439. Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
  2440. get: function() {
  2441. return Object.keys(this.nodes).length || 0;
  2442. }
  2443. });
  2444. return XMLNamedNodeMap;
  2445. }).call(this);
  2446. }).call(this);
  2447. },{}],27:[function(require,module,exports){
  2448. // Generated by CoffeeScript 2.4.1
  2449. (function() {
  2450. var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject,
  2451. hasProp = {}.hasOwnProperty,
  2452. splice = [].splice;
  2453. ({isObject, isFunction, isEmpty, getValue} = require('./Utility'));
  2454. XMLElement = null;
  2455. XMLCData = null;
  2456. XMLComment = null;
  2457. XMLDeclaration = null;
  2458. XMLDocType = null;
  2459. XMLRaw = null;
  2460. XMLText = null;
  2461. XMLProcessingInstruction = null;
  2462. XMLDummy = null;
  2463. NodeType = null;
  2464. XMLNodeList = null;
  2465. XMLNamedNodeMap = null;
  2466. DocumentPosition = null;
  2467. // Represents a generic XMl element
  2468. module.exports = XMLNode = (function() {
  2469. class XMLNode {
  2470. // Initializes a new instance of `XMLNode`
  2471. // `parent` the parent node
  2472. constructor(parent1) {
  2473. this.parent = parent1;
  2474. if (this.parent) {
  2475. this.options = this.parent.options;
  2476. this.stringify = this.parent.stringify;
  2477. }
  2478. this.value = null;
  2479. this.children = [];
  2480. this.baseURI = null;
  2481. // first execution, load dependencies that are otherwise
  2482. // circular (so we can't load them at the top)
  2483. if (!XMLElement) {
  2484. XMLElement = require('./XMLElement');
  2485. XMLCData = require('./XMLCData');
  2486. XMLComment = require('./XMLComment');
  2487. XMLDeclaration = require('./XMLDeclaration');
  2488. XMLDocType = require('./XMLDocType');
  2489. XMLRaw = require('./XMLRaw');
  2490. XMLText = require('./XMLText');
  2491. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  2492. XMLDummy = require('./XMLDummy');
  2493. NodeType = require('./NodeType');
  2494. XMLNodeList = require('./XMLNodeList');
  2495. XMLNamedNodeMap = require('./XMLNamedNodeMap');
  2496. DocumentPosition = require('./DocumentPosition');
  2497. }
  2498. }
  2499. // Sets the parent node of this node and its children recursively
  2500. // `parent` the parent node
  2501. setParent(parent) {
  2502. var child, j, len, ref1, results;
  2503. this.parent = parent;
  2504. if (parent) {
  2505. this.options = parent.options;
  2506. this.stringify = parent.stringify;
  2507. }
  2508. ref1 = this.children;
  2509. results = [];
  2510. for (j = 0, len = ref1.length; j < len; j++) {
  2511. child = ref1[j];
  2512. results.push(child.setParent(this));
  2513. }
  2514. return results;
  2515. }
  2516. // Creates a child element node
  2517. // `name` node name or an object describing the XML tree
  2518. // `attributes` an object containing name/value pairs of attributes
  2519. // `text` element text
  2520. element(name, attributes, text) {
  2521. var childNode, item, j, k, key, lastChild, len, len1, val;
  2522. lastChild = null;
  2523. if (attributes === null && (text == null)) {
  2524. [attributes, text] = [{}, null];
  2525. }
  2526. if (attributes == null) {
  2527. attributes = {};
  2528. }
  2529. attributes = getValue(attributes);
  2530. // swap argument order: text <-> attributes
  2531. if (!isObject(attributes)) {
  2532. [text, attributes] = [attributes, text];
  2533. }
  2534. if (name != null) {
  2535. name = getValue(name);
  2536. }
  2537. // expand if array
  2538. if (Array.isArray(name)) {
  2539. for (j = 0, len = name.length; j < len; j++) {
  2540. item = name[j];
  2541. lastChild = this.element(item);
  2542. }
  2543. // evaluate if function
  2544. } else if (isFunction(name)) {
  2545. lastChild = this.element(name.apply());
  2546. // expand if object
  2547. } else if (isObject(name)) {
  2548. for (key in name) {
  2549. if (!hasProp.call(name, key)) continue;
  2550. val = name[key];
  2551. if (isFunction(val)) {
  2552. // evaluate if function
  2553. val = val.apply();
  2554. }
  2555. // assign attributes
  2556. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  2557. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  2558. // skip empty arrays
  2559. } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
  2560. lastChild = this.dummy();
  2561. // empty objects produce one node
  2562. } else if (isObject(val) && isEmpty(val)) {
  2563. lastChild = this.element(key);
  2564. // skip null and undefined nodes
  2565. } else if (!this.options.keepNullNodes && (val == null)) {
  2566. lastChild = this.dummy();
  2567. // expand list by creating child nodes
  2568. } else if (!this.options.separateArrayItems && Array.isArray(val)) {
  2569. for (k = 0, len1 = val.length; k < len1; k++) {
  2570. item = val[k];
  2571. childNode = {};
  2572. childNode[key] = item;
  2573. lastChild = this.element(childNode);
  2574. }
  2575. // expand child nodes under parent
  2576. } else if (isObject(val)) {
  2577. // if the key is #text expand child nodes under this node to support mixed content
  2578. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
  2579. lastChild = this.element(val);
  2580. } else {
  2581. lastChild = this.element(key);
  2582. lastChild.element(val);
  2583. }
  2584. } else {
  2585. // text node
  2586. lastChild = this.element(key, val);
  2587. }
  2588. }
  2589. // skip null nodes
  2590. } else if (!this.options.keepNullNodes && text === null) {
  2591. lastChild = this.dummy();
  2592. } else {
  2593. // text node
  2594. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  2595. lastChild = this.text(text);
  2596. // cdata node
  2597. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  2598. lastChild = this.cdata(text);
  2599. // comment node
  2600. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  2601. lastChild = this.comment(text);
  2602. // raw text node
  2603. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  2604. lastChild = this.raw(text);
  2605. // processing instruction
  2606. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
  2607. lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
  2608. } else {
  2609. // element node
  2610. lastChild = this.node(name, attributes, text);
  2611. }
  2612. }
  2613. if (lastChild == null) {
  2614. throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
  2615. }
  2616. return lastChild;
  2617. }
  2618. // Creates a child element node before the current node
  2619. // `name` node name or an object describing the XML tree
  2620. // `attributes` an object containing name/value pairs of attributes
  2621. // `text` element text
  2622. insertBefore(name, attributes, text) {
  2623. var child, i, newChild, refChild, removed;
  2624. // DOM level 1
  2625. // insertBefore(newChild, refChild) inserts the child node newChild before refChild
  2626. if (name != null ? name.type : void 0) {
  2627. newChild = name;
  2628. refChild = attributes;
  2629. newChild.setParent(this);
  2630. if (refChild) {
  2631. // temporarily remove children starting *with* refChild
  2632. i = children.indexOf(refChild);
  2633. removed = children.splice(i);
  2634. // add the new child
  2635. children.push(newChild);
  2636. // add back removed children after new child
  2637. Array.prototype.push.apply(children, removed);
  2638. } else {
  2639. children.push(newChild);
  2640. }
  2641. return newChild;
  2642. } else {
  2643. if (this.isRoot) {
  2644. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  2645. }
  2646. // temporarily remove children starting *with* this
  2647. i = this.parent.children.indexOf(this);
  2648. removed = this.parent.children.splice(i);
  2649. // add the new child
  2650. child = this.parent.element(name, attributes, text);
  2651. // add back removed children after new child
  2652. Array.prototype.push.apply(this.parent.children, removed);
  2653. return child;
  2654. }
  2655. }
  2656. // Creates a child element node after the current node
  2657. // `name` node name or an object describing the XML tree
  2658. // `attributes` an object containing name/value pairs of attributes
  2659. // `text` element text
  2660. insertAfter(name, attributes, text) {
  2661. var child, i, removed;
  2662. if (this.isRoot) {
  2663. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  2664. }
  2665. // temporarily remove children starting *after* this
  2666. i = this.parent.children.indexOf(this);
  2667. removed = this.parent.children.splice(i + 1);
  2668. // add the new child
  2669. child = this.parent.element(name, attributes, text);
  2670. // add back removed children after new child
  2671. Array.prototype.push.apply(this.parent.children, removed);
  2672. return child;
  2673. }
  2674. // Deletes a child element node
  2675. remove() {
  2676. var i, ref1;
  2677. if (this.isRoot) {
  2678. throw new Error("Cannot remove the root element. " + this.debugInfo());
  2679. }
  2680. i = this.parent.children.indexOf(this);
  2681. splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
  2682. return this.parent;
  2683. }
  2684. // Creates a node
  2685. // `name` name of the node
  2686. // `attributes` an object containing name/value pairs of attributes
  2687. // `text` element text
  2688. node(name, attributes, text) {
  2689. var child;
  2690. if (name != null) {
  2691. name = getValue(name);
  2692. }
  2693. attributes || (attributes = {});
  2694. attributes = getValue(attributes);
  2695. // swap argument order: text <-> attributes
  2696. if (!isObject(attributes)) {
  2697. [text, attributes] = [attributes, text];
  2698. }
  2699. child = new XMLElement(this, name, attributes);
  2700. if (text != null) {
  2701. child.text(text);
  2702. }
  2703. this.children.push(child);
  2704. return child;
  2705. }
  2706. // Creates a text node
  2707. // `value` element text
  2708. text(value) {
  2709. var child;
  2710. if (isObject(value)) {
  2711. this.element(value);
  2712. }
  2713. child = new XMLText(this, value);
  2714. this.children.push(child);
  2715. return this;
  2716. }
  2717. // Creates a CDATA node
  2718. // `value` element text without CDATA delimiters
  2719. cdata(value) {
  2720. var child;
  2721. child = new XMLCData(this, value);
  2722. this.children.push(child);
  2723. return this;
  2724. }
  2725. // Creates a comment node
  2726. // `value` comment text
  2727. comment(value) {
  2728. var child;
  2729. child = new XMLComment(this, value);
  2730. this.children.push(child);
  2731. return this;
  2732. }
  2733. // Creates a comment node before the current node
  2734. // `value` comment text
  2735. commentBefore(value) {
  2736. var child, i, removed;
  2737. // temporarily remove children starting *with* this
  2738. i = this.parent.children.indexOf(this);
  2739. removed = this.parent.children.splice(i);
  2740. // add the new child
  2741. child = this.parent.comment(value);
  2742. // add back removed children after new child
  2743. Array.prototype.push.apply(this.parent.children, removed);
  2744. return this;
  2745. }
  2746. // Creates a comment node after the current node
  2747. // `value` comment text
  2748. commentAfter(value) {
  2749. var child, i, removed;
  2750. // temporarily remove children starting *after* this
  2751. i = this.parent.children.indexOf(this);
  2752. removed = this.parent.children.splice(i + 1);
  2753. // add the new child
  2754. child = this.parent.comment(value);
  2755. // add back removed children after new child
  2756. Array.prototype.push.apply(this.parent.children, removed);
  2757. return this;
  2758. }
  2759. // Adds unescaped raw text
  2760. // `value` text
  2761. raw(value) {
  2762. var child;
  2763. child = new XMLRaw(this, value);
  2764. this.children.push(child);
  2765. return this;
  2766. }
  2767. // Adds a dummy node
  2768. dummy() {
  2769. var child;
  2770. child = new XMLDummy(this);
  2771. // Normally when a new node is created it is added to the child node collection.
  2772. // However, dummy nodes are never added to the XML tree. They are created while
  2773. // converting JS objects to XML nodes in order not to break the recursive function
  2774. // chain. They can be thought of as invisible nodes. They can be traversed through
  2775. // by using prev(), next(), up(), etc. functions but they do not exists in the tree.
  2776. // @children.push child
  2777. return child;
  2778. }
  2779. // Adds a processing instruction
  2780. // `target` instruction target
  2781. // `value` instruction value
  2782. instruction(target, value) {
  2783. var insTarget, insValue, instruction, j, len;
  2784. if (target != null) {
  2785. target = getValue(target);
  2786. }
  2787. if (value != null) {
  2788. value = getValue(value);
  2789. }
  2790. if (Array.isArray(target)) { // expand if array
  2791. for (j = 0, len = target.length; j < len; j++) {
  2792. insTarget = target[j];
  2793. this.instruction(insTarget);
  2794. }
  2795. } else if (isObject(target)) { // expand if object
  2796. for (insTarget in target) {
  2797. if (!hasProp.call(target, insTarget)) continue;
  2798. insValue = target[insTarget];
  2799. this.instruction(insTarget, insValue);
  2800. }
  2801. } else {
  2802. if (isFunction(value)) {
  2803. value = value.apply();
  2804. }
  2805. instruction = new XMLProcessingInstruction(this, target, value);
  2806. this.children.push(instruction);
  2807. }
  2808. return this;
  2809. }
  2810. // Creates a processing instruction node before the current node
  2811. // `target` instruction target
  2812. // `value` instruction value
  2813. instructionBefore(target, value) {
  2814. var child, i, removed;
  2815. // temporarily remove children starting *with* this
  2816. i = this.parent.children.indexOf(this);
  2817. removed = this.parent.children.splice(i);
  2818. // add the new child
  2819. child = this.parent.instruction(target, value);
  2820. // add back removed children after new child
  2821. Array.prototype.push.apply(this.parent.children, removed);
  2822. return this;
  2823. }
  2824. // Creates a processing instruction node after the current node
  2825. // `target` instruction target
  2826. // `value` instruction value
  2827. instructionAfter(target, value) {
  2828. var child, i, removed;
  2829. // temporarily remove children starting *after* this
  2830. i = this.parent.children.indexOf(this);
  2831. removed = this.parent.children.splice(i + 1);
  2832. // add the new child
  2833. child = this.parent.instruction(target, value);
  2834. // add back removed children after new child
  2835. Array.prototype.push.apply(this.parent.children, removed);
  2836. return this;
  2837. }
  2838. // Creates the xml declaration
  2839. // `version` A version number string, e.g. 1.0
  2840. // `encoding` Encoding declaration, e.g. UTF-8
  2841. // `standalone` standalone document declaration: true or false
  2842. declaration(version, encoding, standalone) {
  2843. var doc, xmldec;
  2844. doc = this.document();
  2845. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  2846. // Replace XML declaration if exists, otherwise insert at top
  2847. if (doc.children.length === 0) {
  2848. doc.children.unshift(xmldec);
  2849. } else if (doc.children[0].type === NodeType.Declaration) {
  2850. doc.children[0] = xmldec;
  2851. } else {
  2852. doc.children.unshift(xmldec);
  2853. }
  2854. return doc.root() || doc;
  2855. }
  2856. // Creates the document type declaration
  2857. // `pubID` the public identifier of the external subset
  2858. // `sysID` the system identifier of the external subset
  2859. dtd(pubID, sysID) {
  2860. var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
  2861. doc = this.document();
  2862. doctype = new XMLDocType(doc, pubID, sysID);
  2863. ref1 = doc.children;
  2864. // Replace DTD if exists
  2865. for (i = j = 0, len = ref1.length; j < len; i = ++j) {
  2866. child = ref1[i];
  2867. if (child.type === NodeType.DocType) {
  2868. doc.children[i] = doctype;
  2869. return doctype;
  2870. }
  2871. }
  2872. ref2 = doc.children;
  2873. // insert before root node if the root node exists
  2874. for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
  2875. child = ref2[i];
  2876. if (child.isRoot) {
  2877. doc.children.splice(i, 0, doctype);
  2878. return doctype;
  2879. }
  2880. }
  2881. // otherwise append to end
  2882. doc.children.push(doctype);
  2883. return doctype;
  2884. }
  2885. // Gets the parent node
  2886. up() {
  2887. if (this.isRoot) {
  2888. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  2889. }
  2890. return this.parent;
  2891. }
  2892. // Gets the root node
  2893. root() {
  2894. var node;
  2895. node = this;
  2896. while (node) {
  2897. if (node.type === NodeType.Document) {
  2898. return node.rootObject;
  2899. } else if (node.isRoot) {
  2900. return node;
  2901. } else {
  2902. node = node.parent;
  2903. }
  2904. }
  2905. }
  2906. // Gets the node representing the XML document
  2907. document() {
  2908. var node;
  2909. node = this;
  2910. while (node) {
  2911. if (node.type === NodeType.Document) {
  2912. return node;
  2913. } else {
  2914. node = node.parent;
  2915. }
  2916. }
  2917. }
  2918. // Ends the document and converts string
  2919. end(options) {
  2920. return this.document().end(options);
  2921. }
  2922. // Gets the previous node
  2923. prev() {
  2924. var i;
  2925. i = this.parent.children.indexOf(this);
  2926. if (i < 1) {
  2927. throw new Error("Already at the first node. " + this.debugInfo());
  2928. }
  2929. return this.parent.children[i - 1];
  2930. }
  2931. // Gets the next node
  2932. next() {
  2933. var i;
  2934. i = this.parent.children.indexOf(this);
  2935. if (i === -1 || i === this.parent.children.length - 1) {
  2936. throw new Error("Already at the last node. " + this.debugInfo());
  2937. }
  2938. return this.parent.children[i + 1];
  2939. }
  2940. // Imports cloned root from another XML document
  2941. // `doc` the XML document to insert nodes from
  2942. importDocument(doc) {
  2943. var child, clonedRoot, j, len, ref1;
  2944. clonedRoot = doc.root().clone();
  2945. clonedRoot.parent = this;
  2946. clonedRoot.isRoot = false;
  2947. this.children.push(clonedRoot);
  2948. // set properties if imported element becomes the root node
  2949. if (this.type === NodeType.Document) {
  2950. clonedRoot.isRoot = true;
  2951. clonedRoot.documentObject = this;
  2952. this.rootObject = clonedRoot;
  2953. // set dtd name
  2954. if (this.children) {
  2955. ref1 = this.children;
  2956. for (j = 0, len = ref1.length; j < len; j++) {
  2957. child = ref1[j];
  2958. if (child.type === NodeType.DocType) {
  2959. child.name = clonedRoot.name;
  2960. break;
  2961. }
  2962. }
  2963. }
  2964. }
  2965. return this;
  2966. }
  2967. // Returns debug string for this node
  2968. debugInfo(name) {
  2969. var ref1, ref2;
  2970. name = name || this.name;
  2971. if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) {
  2972. return "";
  2973. } else if (name == null) {
  2974. return "parent: <" + this.parent.name + ">";
  2975. } else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) {
  2976. return "node: <" + name + ">";
  2977. } else {
  2978. return "node: <" + name + ">, parent: <" + this.parent.name + ">";
  2979. }
  2980. }
  2981. // Aliases
  2982. ele(name, attributes, text) {
  2983. return this.element(name, attributes, text);
  2984. }
  2985. nod(name, attributes, text) {
  2986. return this.node(name, attributes, text);
  2987. }
  2988. txt(value) {
  2989. return this.text(value);
  2990. }
  2991. dat(value) {
  2992. return this.cdata(value);
  2993. }
  2994. com(value) {
  2995. return this.comment(value);
  2996. }
  2997. ins(target, value) {
  2998. return this.instruction(target, value);
  2999. }
  3000. doc() {
  3001. return this.document();
  3002. }
  3003. dec(version, encoding, standalone) {
  3004. return this.declaration(version, encoding, standalone);
  3005. }
  3006. e(name, attributes, text) {
  3007. return this.element(name, attributes, text);
  3008. }
  3009. n(name, attributes, text) {
  3010. return this.node(name, attributes, text);
  3011. }
  3012. t(value) {
  3013. return this.text(value);
  3014. }
  3015. d(value) {
  3016. return this.cdata(value);
  3017. }
  3018. c(value) {
  3019. return this.comment(value);
  3020. }
  3021. r(value) {
  3022. return this.raw(value);
  3023. }
  3024. i(target, value) {
  3025. return this.instruction(target, value);
  3026. }
  3027. u() {
  3028. return this.up();
  3029. }
  3030. // can be deprecated in a future release
  3031. importXMLBuilder(doc) {
  3032. return this.importDocument(doc);
  3033. }
  3034. // Adds or modifies an attribute.
  3035. // `name` attribute name
  3036. // `value` attribute value
  3037. attribute(name, value) {
  3038. throw new Error("attribute() applies to element nodes only.");
  3039. }
  3040. att(name, value) {
  3041. return this.attribute(name, value);
  3042. }
  3043. a(name, value) {
  3044. return this.attribute(name, value);
  3045. }
  3046. // Removes an attribute
  3047. // `name` attribute name
  3048. removeAttribute(name) {
  3049. throw new Error("attribute() applies to element nodes only.");
  3050. }
  3051. // DOM level 1 functions to be implemented later
  3052. replaceChild(newChild, oldChild) {
  3053. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3054. }
  3055. removeChild(oldChild) {
  3056. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3057. }
  3058. appendChild(newChild) {
  3059. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3060. }
  3061. hasChildNodes() {
  3062. return this.children.length !== 0;
  3063. }
  3064. cloneNode(deep) {
  3065. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3066. }
  3067. normalize() {
  3068. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3069. }
  3070. // DOM level 2
  3071. isSupported(feature, version) {
  3072. return true;
  3073. }
  3074. hasAttributes() {
  3075. return this.attribs.length !== 0;
  3076. }
  3077. // DOM level 3 functions to be implemented later
  3078. compareDocumentPosition(other) {
  3079. var ref, res;
  3080. ref = this;
  3081. if (ref === other) {
  3082. return 0;
  3083. } else if (this.document() !== other.document()) {
  3084. res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
  3085. if (Math.random() < 0.5) {
  3086. res |= DocumentPosition.Preceding;
  3087. } else {
  3088. res |= DocumentPosition.Following;
  3089. }
  3090. return res;
  3091. } else if (ref.isAncestor(other)) {
  3092. return DocumentPosition.Contains | DocumentPosition.Preceding;
  3093. } else if (ref.isDescendant(other)) {
  3094. return DocumentPosition.Contains | DocumentPosition.Following;
  3095. } else if (ref.isPreceding(other)) {
  3096. return DocumentPosition.Preceding;
  3097. } else {
  3098. return DocumentPosition.Following;
  3099. }
  3100. }
  3101. isSameNode(other) {
  3102. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3103. }
  3104. lookupPrefix(namespaceURI) {
  3105. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3106. }
  3107. isDefaultNamespace(namespaceURI) {
  3108. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3109. }
  3110. lookupNamespaceURI(prefix) {
  3111. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3112. }
  3113. isEqualNode(node) {
  3114. var i, j, ref1;
  3115. if (node.nodeType !== this.nodeType) {
  3116. return false;
  3117. }
  3118. if (node.children.length !== this.children.length) {
  3119. return false;
  3120. }
  3121. for (i = j = 0, ref1 = this.children.length - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) {
  3122. if (!this.children[i].isEqualNode(node.children[i])) {
  3123. return false;
  3124. }
  3125. }
  3126. return true;
  3127. }
  3128. getFeature(feature, version) {
  3129. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3130. }
  3131. setUserData(key, data, handler) {
  3132. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3133. }
  3134. getUserData(key) {
  3135. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3136. }
  3137. // Returns true if other is an inclusive descendant of node,
  3138. // and false otherwise.
  3139. contains(other) {
  3140. if (!other) {
  3141. return false;
  3142. }
  3143. return other === this || this.isDescendant(other);
  3144. }
  3145. // An object A is called a descendant of an object B, if either A is
  3146. // a child of B or A is a child of an object C that is a descendant of B.
  3147. isDescendant(node) {
  3148. var child, isDescendantChild, j, len, ref1;
  3149. ref1 = this.children;
  3150. for (j = 0, len = ref1.length; j < len; j++) {
  3151. child = ref1[j];
  3152. if (node === child) {
  3153. return true;
  3154. }
  3155. isDescendantChild = child.isDescendant(node);
  3156. if (isDescendantChild) {
  3157. return true;
  3158. }
  3159. }
  3160. return false;
  3161. }
  3162. // An object A is called an ancestor of an object B if and only if
  3163. // B is a descendant of A.
  3164. isAncestor(node) {
  3165. return node.isDescendant(this);
  3166. }
  3167. // An object A is preceding an object B if A and B are in the
  3168. // same tree and A comes before B in tree order.
  3169. isPreceding(node) {
  3170. var nodePos, thisPos;
  3171. nodePos = this.treePosition(node);
  3172. thisPos = this.treePosition(this);
  3173. if (nodePos === -1 || thisPos === -1) {
  3174. return false;
  3175. } else {
  3176. return nodePos < thisPos;
  3177. }
  3178. }
  3179. // An object A is folllowing an object B if A and B are in the
  3180. // same tree and A comes after B in tree order.
  3181. isFollowing(node) {
  3182. var nodePos, thisPos;
  3183. nodePos = this.treePosition(node);
  3184. thisPos = this.treePosition(this);
  3185. if (nodePos === -1 || thisPos === -1) {
  3186. return false;
  3187. } else {
  3188. return nodePos > thisPos;
  3189. }
  3190. }
  3191. // Returns the preorder position of the given node in the tree, or -1
  3192. // if the node is not in the tree.
  3193. treePosition(node) {
  3194. var found, pos;
  3195. pos = 0;
  3196. found = false;
  3197. this.foreachTreeNode(this.document(), function(childNode) {
  3198. pos++;
  3199. if (!found && childNode === node) {
  3200. return found = true;
  3201. }
  3202. });
  3203. if (found) {
  3204. return pos;
  3205. } else {
  3206. return -1;
  3207. }
  3208. }
  3209. // Depth-first preorder traversal through the XML tree
  3210. foreachTreeNode(node, func) {
  3211. var child, j, len, ref1, res;
  3212. node || (node = this.document());
  3213. ref1 = node.children;
  3214. for (j = 0, len = ref1.length; j < len; j++) {
  3215. child = ref1[j];
  3216. if (res = func(child)) {
  3217. return res;
  3218. } else {
  3219. res = this.foreachTreeNode(child, func);
  3220. if (res) {
  3221. return res;
  3222. }
  3223. }
  3224. }
  3225. }
  3226. };
  3227. // DOM level 1
  3228. Object.defineProperty(XMLNode.prototype, 'nodeName', {
  3229. get: function() {
  3230. return this.name;
  3231. }
  3232. });
  3233. Object.defineProperty(XMLNode.prototype, 'nodeType', {
  3234. get: function() {
  3235. return this.type;
  3236. }
  3237. });
  3238. Object.defineProperty(XMLNode.prototype, 'nodeValue', {
  3239. get: function() {
  3240. return this.value;
  3241. }
  3242. });
  3243. Object.defineProperty(XMLNode.prototype, 'parentNode', {
  3244. get: function() {
  3245. return this.parent;
  3246. }
  3247. });
  3248. Object.defineProperty(XMLNode.prototype, 'childNodes', {
  3249. get: function() {
  3250. if (!this.childNodeList || !this.childNodeList.nodes) {
  3251. this.childNodeList = new XMLNodeList(this.children);
  3252. }
  3253. return this.childNodeList;
  3254. }
  3255. });
  3256. Object.defineProperty(XMLNode.prototype, 'firstChild', {
  3257. get: function() {
  3258. return this.children[0] || null;
  3259. }
  3260. });
  3261. Object.defineProperty(XMLNode.prototype, 'lastChild', {
  3262. get: function() {
  3263. return this.children[this.children.length - 1] || null;
  3264. }
  3265. });
  3266. Object.defineProperty(XMLNode.prototype, 'previousSibling', {
  3267. get: function() {
  3268. var i;
  3269. i = this.parent.children.indexOf(this);
  3270. return this.parent.children[i - 1] || null;
  3271. }
  3272. });
  3273. Object.defineProperty(XMLNode.prototype, 'nextSibling', {
  3274. get: function() {
  3275. var i;
  3276. i = this.parent.children.indexOf(this);
  3277. return this.parent.children[i + 1] || null;
  3278. }
  3279. });
  3280. Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
  3281. get: function() {
  3282. return this.document() || null;
  3283. }
  3284. });
  3285. // DOM level 3
  3286. Object.defineProperty(XMLNode.prototype, 'textContent', {
  3287. get: function() {
  3288. var child, j, len, ref1, str;
  3289. if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
  3290. str = '';
  3291. ref1 = this.children;
  3292. for (j = 0, len = ref1.length; j < len; j++) {
  3293. child = ref1[j];
  3294. if (child.textContent) {
  3295. str += child.textContent;
  3296. }
  3297. }
  3298. return str;
  3299. } else {
  3300. return null;
  3301. }
  3302. },
  3303. set: function(value) {
  3304. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3305. }
  3306. });
  3307. return XMLNode;
  3308. }).call(this);
  3309. }).call(this);
  3310. },{"./DocumentPosition":4,"./NodeType":5,"./Utility":6,"./XMLCData":9,"./XMLComment":11,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDummy":24,"./XMLElement":25,"./XMLNamedNodeMap":26,"./XMLNodeList":28,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLText":34}],28:[function(require,module,exports){
  3311. // Generated by CoffeeScript 2.4.1
  3312. (function() {
  3313. // Represents a list of nodes
  3314. var XMLNodeList;
  3315. module.exports = XMLNodeList = (function() {
  3316. class XMLNodeList {
  3317. // Initializes a new instance of `XMLNodeList`
  3318. // This is just a wrapper around an ordinary
  3319. // JS array.
  3320. // `nodes` the array containing nodes.
  3321. constructor(nodes) {
  3322. this.nodes = nodes;
  3323. }
  3324. // Creates and returns a deep clone of `this`
  3325. clone() {
  3326. // this class should not be cloned since it wraps
  3327. // around a given array. The calling function should check
  3328. // whether the wrapped array is null and supply a new array
  3329. // (from the clone).
  3330. return this.nodes = null;
  3331. }
  3332. // DOM Level 1
  3333. item(index) {
  3334. return this.nodes[index] || null;
  3335. }
  3336. };
  3337. // DOM level 1
  3338. Object.defineProperty(XMLNodeList.prototype, 'length', {
  3339. get: function() {
  3340. return this.nodes.length || 0;
  3341. }
  3342. });
  3343. return XMLNodeList;
  3344. }).call(this);
  3345. }).call(this);
  3346. },{}],29:[function(require,module,exports){
  3347. // Generated by CoffeeScript 2.4.1
  3348. (function() {
  3349. var NodeType, XMLCharacterData, XMLProcessingInstruction;
  3350. NodeType = require('./NodeType');
  3351. XMLCharacterData = require('./XMLCharacterData');
  3352. // Represents a processing instruction
  3353. module.exports = XMLProcessingInstruction = class XMLProcessingInstruction extends XMLCharacterData {
  3354. // Initializes a new instance of `XMLProcessingInstruction`
  3355. // `parent` the parent node
  3356. // `target` instruction target
  3357. // `value` instruction value
  3358. constructor(parent, target, value) {
  3359. super(parent);
  3360. if (target == null) {
  3361. throw new Error("Missing instruction target. " + this.debugInfo());
  3362. }
  3363. this.type = NodeType.ProcessingInstruction;
  3364. this.target = this.stringify.insTarget(target);
  3365. this.name = this.target;
  3366. if (value) {
  3367. this.value = this.stringify.insValue(value);
  3368. }
  3369. }
  3370. // Creates and returns a deep clone of `this`
  3371. clone() {
  3372. return Object.create(this);
  3373. }
  3374. // Converts the XML fragment to string
  3375. // `options.pretty` pretty prints the result
  3376. // `options.indent` indentation for pretty print
  3377. // `options.offset` how many indentations to add to every line for pretty print
  3378. // `options.newline` newline sequence for pretty print
  3379. toString(options) {
  3380. return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
  3381. }
  3382. isEqualNode(node) {
  3383. if (!super.isEqualNode(node)) {
  3384. return false;
  3385. }
  3386. if (node.target !== this.target) {
  3387. return false;
  3388. }
  3389. return true;
  3390. }
  3391. };
  3392. }).call(this);
  3393. },{"./NodeType":5,"./XMLCharacterData":10}],30:[function(require,module,exports){
  3394. // Generated by CoffeeScript 2.4.1
  3395. (function() {
  3396. var NodeType, XMLNode, XMLRaw;
  3397. NodeType = require('./NodeType');
  3398. XMLNode = require('./XMLNode');
  3399. // Represents a raw node
  3400. module.exports = XMLRaw = class XMLRaw extends XMLNode {
  3401. // Initializes a new instance of `XMLRaw`
  3402. // `text` raw text
  3403. constructor(parent, text) {
  3404. super(parent);
  3405. if (text == null) {
  3406. throw new Error("Missing raw text. " + this.debugInfo());
  3407. }
  3408. this.type = NodeType.Raw;
  3409. this.value = this.stringify.raw(text);
  3410. }
  3411. // Creates and returns a deep clone of `this`
  3412. clone() {
  3413. return Object.create(this);
  3414. }
  3415. // Converts the XML fragment to string
  3416. // `options.pretty` pretty prints the result
  3417. // `options.indent` indentation for pretty print
  3418. // `options.offset` how many indentations to add to every line for pretty print
  3419. // `options.newline` newline sequence for pretty print
  3420. toString(options) {
  3421. return this.options.writer.raw(this, this.options.writer.filterOptions(options));
  3422. }
  3423. };
  3424. }).call(this);
  3425. },{"./NodeType":5,"./XMLNode":27}],31:[function(require,module,exports){
  3426. // Generated by CoffeeScript 2.4.1
  3427. (function() {
  3428. var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
  3429. hasProp = {}.hasOwnProperty;
  3430. NodeType = require('./NodeType');
  3431. XMLWriterBase = require('./XMLWriterBase');
  3432. WriterState = require('./WriterState');
  3433. // Prints XML nodes to a stream
  3434. module.exports = XMLStreamWriter = class XMLStreamWriter extends XMLWriterBase {
  3435. // Initializes a new instance of `XMLStreamWriter`
  3436. // `stream` output stream
  3437. // `options.pretty` pretty prints the result
  3438. // `options.indent` indentation string
  3439. // `options.newline` newline sequence
  3440. // `options.offset` a fixed number of indentations to add to every line
  3441. // `options.allowEmpty` do not self close empty element tags
  3442. // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
  3443. // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
  3444. constructor(stream, options) {
  3445. super(options);
  3446. this.stream = stream;
  3447. }
  3448. endline(node, options, level) {
  3449. if (node.isLastRootNode && options.state === WriterState.CloseTag) {
  3450. return '';
  3451. } else {
  3452. return super.endline(node, options, level);
  3453. }
  3454. }
  3455. document(doc, options) {
  3456. var child, i, j, k, len1, len2, ref, ref1, results;
  3457. ref = doc.children;
  3458. // set a flag so that we don't insert a newline after the last root level node
  3459. for (i = j = 0, len1 = ref.length; j < len1; i = ++j) {
  3460. child = ref[i];
  3461. child.isLastRootNode = i === doc.children.length - 1;
  3462. }
  3463. options = this.filterOptions(options);
  3464. ref1 = doc.children;
  3465. results = [];
  3466. for (k = 0, len2 = ref1.length; k < len2; k++) {
  3467. child = ref1[k];
  3468. results.push(this.writeChildNode(child, options, 0));
  3469. }
  3470. return results;
  3471. }
  3472. cdata(node, options, level) {
  3473. return this.stream.write(super.cdata(node, options, level));
  3474. }
  3475. comment(node, options, level) {
  3476. return this.stream.write(super.comment(node, options, level));
  3477. }
  3478. declaration(node, options, level) {
  3479. return this.stream.write(super.declaration(node, options, level));
  3480. }
  3481. docType(node, options, level) {
  3482. var child, j, len1, ref;
  3483. level || (level = 0);
  3484. this.openNode(node, options, level);
  3485. options.state = WriterState.OpenTag;
  3486. this.stream.write(this.indent(node, options, level));
  3487. this.stream.write('<!DOCTYPE ' + node.root().name);
  3488. // external identifier
  3489. if (node.pubID && node.sysID) {
  3490. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  3491. } else if (node.sysID) {
  3492. this.stream.write(' SYSTEM "' + node.sysID + '"');
  3493. }
  3494. // internal subset
  3495. if (node.children.length > 0) {
  3496. this.stream.write(' [');
  3497. this.stream.write(this.endline(node, options, level));
  3498. options.state = WriterState.InsideTag;
  3499. ref = node.children;
  3500. for (j = 0, len1 = ref.length; j < len1; j++) {
  3501. child = ref[j];
  3502. this.writeChildNode(child, options, level + 1);
  3503. }
  3504. options.state = WriterState.CloseTag;
  3505. this.stream.write(']');
  3506. }
  3507. // close tag
  3508. options.state = WriterState.CloseTag;
  3509. this.stream.write(options.spaceBeforeSlash + '>');
  3510. this.stream.write(this.endline(node, options, level));
  3511. options.state = WriterState.None;
  3512. return this.closeNode(node, options, level);
  3513. }
  3514. element(node, options, level) {
  3515. var att, attLen, child, childNodeCount, firstChildNode, j, len, len1, name, prettySuppressed, r, ratt, ref, ref1, ref2, rline;
  3516. level || (level = 0);
  3517. // open tag
  3518. this.openNode(node, options, level);
  3519. options.state = WriterState.OpenTag;
  3520. r = this.indent(node, options, level) + '<' + node.name;
  3521. // attributes
  3522. if (options.pretty && options.width > 0) {
  3523. len = r.length;
  3524. ref = node.attribs;
  3525. for (name in ref) {
  3526. if (!hasProp.call(ref, name)) continue;
  3527. att = ref[name];
  3528. ratt = this.attribute(att, options, level);
  3529. attLen = ratt.length;
  3530. if (len + attLen > options.width) {
  3531. rline = this.indent(node, options, level + 1) + ratt;
  3532. r += this.endline(node, options, level) + rline;
  3533. len = rline.length;
  3534. } else {
  3535. rline = ' ' + ratt;
  3536. r += rline;
  3537. len += rline.length;
  3538. }
  3539. }
  3540. } else {
  3541. ref1 = node.attribs;
  3542. for (name in ref1) {
  3543. if (!hasProp.call(ref1, name)) continue;
  3544. att = ref1[name];
  3545. r += this.attribute(att, options, level);
  3546. }
  3547. }
  3548. this.stream.write(r);
  3549. childNodeCount = node.children.length;
  3550. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  3551. if (childNodeCount === 0 || node.children.every(function(e) {
  3552. return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
  3553. })) {
  3554. // empty element
  3555. if (options.allowEmpty) {
  3556. this.stream.write('>');
  3557. options.state = WriterState.CloseTag;
  3558. this.stream.write('</' + node.name + '>');
  3559. } else {
  3560. options.state = WriterState.CloseTag;
  3561. this.stream.write(options.spaceBeforeSlash + '/>');
  3562. }
  3563. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
  3564. // do not indent text-only nodes
  3565. this.stream.write('>');
  3566. options.state = WriterState.InsideTag;
  3567. options.suppressPrettyCount++;
  3568. prettySuppressed = true;
  3569. this.writeChildNode(firstChildNode, options, level + 1);
  3570. options.suppressPrettyCount--;
  3571. prettySuppressed = false;
  3572. options.state = WriterState.CloseTag;
  3573. this.stream.write('</' + node.name + '>');
  3574. } else {
  3575. this.stream.write('>' + this.endline(node, options, level));
  3576. options.state = WriterState.InsideTag;
  3577. ref2 = node.children;
  3578. // inner tags
  3579. for (j = 0, len1 = ref2.length; j < len1; j++) {
  3580. child = ref2[j];
  3581. this.writeChildNode(child, options, level + 1);
  3582. }
  3583. // close tag
  3584. options.state = WriterState.CloseTag;
  3585. this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
  3586. }
  3587. this.stream.write(this.endline(node, options, level));
  3588. options.state = WriterState.None;
  3589. return this.closeNode(node, options, level);
  3590. }
  3591. processingInstruction(node, options, level) {
  3592. return this.stream.write(super.processingInstruction(node, options, level));
  3593. }
  3594. raw(node, options, level) {
  3595. return this.stream.write(super.raw(node, options, level));
  3596. }
  3597. text(node, options, level) {
  3598. return this.stream.write(super.text(node, options, level));
  3599. }
  3600. dtdAttList(node, options, level) {
  3601. return this.stream.write(super.dtdAttList(node, options, level));
  3602. }
  3603. dtdElement(node, options, level) {
  3604. return this.stream.write(super.dtdElement(node, options, level));
  3605. }
  3606. dtdEntity(node, options, level) {
  3607. return this.stream.write(super.dtdEntity(node, options, level));
  3608. }
  3609. dtdNotation(node, options, level) {
  3610. return this.stream.write(super.dtdNotation(node, options, level));
  3611. }
  3612. };
  3613. }).call(this);
  3614. },{"./NodeType":5,"./WriterState":7,"./XMLWriterBase":35}],32:[function(require,module,exports){
  3615. // Generated by CoffeeScript 2.4.1
  3616. (function() {
  3617. var XMLStringWriter, XMLWriterBase;
  3618. XMLWriterBase = require('./XMLWriterBase');
  3619. // Prints XML nodes as plain text
  3620. module.exports = XMLStringWriter = class XMLStringWriter extends XMLWriterBase {
  3621. // Initializes a new instance of `XMLStringWriter`
  3622. // `options.pretty` pretty prints the result
  3623. // `options.indent` indentation string
  3624. // `options.newline` newline sequence
  3625. // `options.offset` a fixed number of indentations to add to every line
  3626. // `options.allowEmpty` do not self close empty element tags
  3627. // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
  3628. // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
  3629. constructor(options) {
  3630. super(options);
  3631. }
  3632. document(doc, options) {
  3633. var child, i, len, r, ref;
  3634. options = this.filterOptions(options);
  3635. r = '';
  3636. ref = doc.children;
  3637. for (i = 0, len = ref.length; i < len; i++) {
  3638. child = ref[i];
  3639. r += this.writeChildNode(child, options, 0);
  3640. }
  3641. // remove trailing newline
  3642. if (options.pretty && r.slice(-options.newline.length) === options.newline) {
  3643. r = r.slice(0, -options.newline.length);
  3644. }
  3645. return r;
  3646. }
  3647. };
  3648. }).call(this);
  3649. },{"./XMLWriterBase":35}],33:[function(require,module,exports){
  3650. // Generated by CoffeeScript 2.4.1
  3651. (function() {
  3652. // Converts values to strings
  3653. var XMLStringifier,
  3654. hasProp = {}.hasOwnProperty;
  3655. module.exports = XMLStringifier = (function() {
  3656. class XMLStringifier {
  3657. // Initializes a new instance of `XMLStringifier`
  3658. // `options.version` The version number string of the XML spec to validate against, e.g. 1.0
  3659. // `options.noDoubleEncoding` whether existing html entities are encoded: true or false
  3660. // `options.stringify` a set of functions to use for converting values to strings
  3661. // `options.noValidation` whether values will be validated and escaped or returned as is
  3662. // `options.invalidCharReplacement` a character to replace invalid characters and disable character validation
  3663. constructor(options) {
  3664. var key, ref, value;
  3665. // Checks whether the given string contains legal characters
  3666. // Fails with an exception on error
  3667. // `str` the string to check
  3668. this.assertLegalChar = this.assertLegalChar.bind(this);
  3669. // Checks whether the given string contains legal characters for a name
  3670. // Fails with an exception on error
  3671. // `str` the string to check
  3672. this.assertLegalName = this.assertLegalName.bind(this);
  3673. options || (options = {});
  3674. this.options = options;
  3675. if (!this.options.version) {
  3676. this.options.version = '1.0';
  3677. }
  3678. ref = options.stringify || {};
  3679. for (key in ref) {
  3680. if (!hasProp.call(ref, key)) continue;
  3681. value = ref[key];
  3682. this[key] = value;
  3683. }
  3684. }
  3685. // Defaults
  3686. name(val) {
  3687. if (this.options.noValidation) {
  3688. return val;
  3689. }
  3690. return this.assertLegalName('' + val || '');
  3691. }
  3692. text(val) {
  3693. if (this.options.noValidation) {
  3694. return val;
  3695. }
  3696. return this.assertLegalChar(this.textEscape('' + val || ''));
  3697. }
  3698. cdata(val) {
  3699. if (this.options.noValidation) {
  3700. return val;
  3701. }
  3702. val = '' + val || '';
  3703. val = val.replace(']]>', ']]]]><![CDATA[>');
  3704. return this.assertLegalChar(val);
  3705. }
  3706. comment(val) {
  3707. if (this.options.noValidation) {
  3708. return val;
  3709. }
  3710. val = '' + val || '';
  3711. if (val.match(/--/)) {
  3712. throw new Error("Comment text cannot contain double-hypen: " + val);
  3713. }
  3714. return this.assertLegalChar(val);
  3715. }
  3716. raw(val) {
  3717. if (this.options.noValidation) {
  3718. return val;
  3719. }
  3720. return '' + val || '';
  3721. }
  3722. attValue(val) {
  3723. if (this.options.noValidation) {
  3724. return val;
  3725. }
  3726. return this.assertLegalChar(this.attEscape(val = '' + val || ''));
  3727. }
  3728. insTarget(val) {
  3729. if (this.options.noValidation) {
  3730. return val;
  3731. }
  3732. return this.assertLegalChar('' + val || '');
  3733. }
  3734. insValue(val) {
  3735. if (this.options.noValidation) {
  3736. return val;
  3737. }
  3738. val = '' + val || '';
  3739. if (val.match(/\?>/)) {
  3740. throw new Error("Invalid processing instruction value: " + val);
  3741. }
  3742. return this.assertLegalChar(val);
  3743. }
  3744. xmlVersion(val) {
  3745. if (this.options.noValidation) {
  3746. return val;
  3747. }
  3748. val = '' + val || '';
  3749. if (!val.match(/1\.[0-9]+/)) {
  3750. throw new Error("Invalid version number: " + val);
  3751. }
  3752. return val;
  3753. }
  3754. xmlEncoding(val) {
  3755. if (this.options.noValidation) {
  3756. return val;
  3757. }
  3758. val = '' + val || '';
  3759. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
  3760. throw new Error("Invalid encoding: " + val);
  3761. }
  3762. return this.assertLegalChar(val);
  3763. }
  3764. xmlStandalone(val) {
  3765. if (this.options.noValidation) {
  3766. return val;
  3767. }
  3768. if (val) {
  3769. return "yes";
  3770. } else {
  3771. return "no";
  3772. }
  3773. }
  3774. dtdPubID(val) {
  3775. if (this.options.noValidation) {
  3776. return val;
  3777. }
  3778. return this.assertLegalChar('' + val || '');
  3779. }
  3780. dtdSysID(val) {
  3781. if (this.options.noValidation) {
  3782. return val;
  3783. }
  3784. return this.assertLegalChar('' + val || '');
  3785. }
  3786. dtdElementValue(val) {
  3787. if (this.options.noValidation) {
  3788. return val;
  3789. }
  3790. return this.assertLegalChar('' + val || '');
  3791. }
  3792. dtdAttType(val) {
  3793. if (this.options.noValidation) {
  3794. return val;
  3795. }
  3796. return this.assertLegalChar('' + val || '');
  3797. }
  3798. dtdAttDefault(val) {
  3799. if (this.options.noValidation) {
  3800. return val;
  3801. }
  3802. return this.assertLegalChar('' + val || '');
  3803. }
  3804. dtdEntityValue(val) {
  3805. if (this.options.noValidation) {
  3806. return val;
  3807. }
  3808. return this.assertLegalChar('' + val || '');
  3809. }
  3810. dtdNData(val) {
  3811. if (this.options.noValidation) {
  3812. return val;
  3813. }
  3814. return this.assertLegalChar('' + val || '');
  3815. }
  3816. assertLegalChar(str) {
  3817. var regex, res;
  3818. if (this.options.noValidation) {
  3819. return str;
  3820. }
  3821. if (this.options.version === '1.0') {
  3822. // Valid characters from https://www.w3.org/TR/xml/#charsets
  3823. // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
  3824. // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
  3825. // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
  3826. // let xml_10_InvalidChars = regenerate()
  3827. // .addRange(0x0000, 0x0008)
  3828. // .add(0x000B, 0x000C)
  3829. // .addRange(0x000E, 0x001F)
  3830. // .addRange(0xD800, 0xDFFF)
  3831. // .addRange(0xFFFE, 0xFFFF)
  3832. regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
  3833. if (this.options.invalidCharReplacement !== void 0) {
  3834. str = str.replace(regex, this.options.invalidCharReplacement);
  3835. } else if (res = str.match(regex)) {
  3836. throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
  3837. }
  3838. } else if (this.options.version === '1.1') {
  3839. // Valid characters from https://www.w3.org/TR/xml11/#charsets
  3840. // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
  3841. // [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
  3842. // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
  3843. // let xml_11_InvalidChars = regenerate()
  3844. // .add(0x0000)
  3845. // .addRange(0xD800, 0xDFFF)
  3846. // .addRange(0xFFFE, 0xFFFF)
  3847. regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
  3848. if (this.options.invalidCharReplacement !== void 0) {
  3849. str = str.replace(regex, this.options.invalidCharReplacement);
  3850. } else if (res = str.match(regex)) {
  3851. throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
  3852. }
  3853. }
  3854. return str;
  3855. }
  3856. assertLegalName(str) {
  3857. var regex;
  3858. if (this.options.noValidation) {
  3859. return str;
  3860. }
  3861. str = this.assertLegalChar(str);
  3862. regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
  3863. if (!str.match(regex)) {
  3864. throw new Error(`Invalid character in name: ${str}`);
  3865. }
  3866. return str;
  3867. }
  3868. // Escapes special characters in text
  3869. // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
  3870. // `str` the string to escape
  3871. textEscape(str) {
  3872. var ampregex;
  3873. if (this.options.noValidation) {
  3874. return str;
  3875. }
  3876. ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
  3877. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  3878. }
  3879. // Escapes special characters in attribute values
  3880. // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
  3881. // `str` the string to escape
  3882. attEscape(str) {
  3883. var ampregex;
  3884. if (this.options.noValidation) {
  3885. return str;
  3886. }
  3887. ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
  3888. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
  3889. }
  3890. };
  3891. // strings to match while converting from JS objects
  3892. XMLStringifier.prototype.convertAttKey = '@';
  3893. XMLStringifier.prototype.convertPIKey = '?';
  3894. XMLStringifier.prototype.convertTextKey = '#text';
  3895. XMLStringifier.prototype.convertCDataKey = '#cdata';
  3896. XMLStringifier.prototype.convertCommentKey = '#comment';
  3897. XMLStringifier.prototype.convertRawKey = '#raw';
  3898. return XMLStringifier;
  3899. }).call(this);
  3900. }).call(this);
  3901. },{}],34:[function(require,module,exports){
  3902. // Generated by CoffeeScript 2.4.1
  3903. (function() {
  3904. var NodeType, XMLCharacterData, XMLText;
  3905. NodeType = require('./NodeType');
  3906. XMLCharacterData = require('./XMLCharacterData');
  3907. // Represents a text node
  3908. module.exports = XMLText = (function() {
  3909. class XMLText extends XMLCharacterData {
  3910. // Initializes a new instance of `XMLText`
  3911. // `text` element text
  3912. constructor(parent, text) {
  3913. super(parent);
  3914. if (text == null) {
  3915. throw new Error("Missing element text. " + this.debugInfo());
  3916. }
  3917. this.name = "#text";
  3918. this.type = NodeType.Text;
  3919. this.value = this.stringify.text(text);
  3920. }
  3921. // Creates and returns a deep clone of `this`
  3922. clone() {
  3923. return Object.create(this);
  3924. }
  3925. // Converts the XML fragment to string
  3926. // `options.pretty` pretty prints the result
  3927. // `options.indent` indentation for pretty print
  3928. // `options.offset` how many indentations to add to every line for pretty print
  3929. // `options.newline` newline sequence for pretty print
  3930. toString(options) {
  3931. return this.options.writer.text(this, this.options.writer.filterOptions(options));
  3932. }
  3933. // DOM level 1 functions to be implemented later
  3934. splitText(offset) {
  3935. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3936. }
  3937. // DOM level 3 functions to be implemented later
  3938. replaceWholeText(content) {
  3939. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3940. }
  3941. };
  3942. // DOM level 3
  3943. Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
  3944. get: function() {
  3945. throw new Error("This DOM method is not implemented." + this.debugInfo());
  3946. }
  3947. });
  3948. Object.defineProperty(XMLText.prototype, 'wholeText', {
  3949. get: function() {
  3950. var next, prev, str;
  3951. str = '';
  3952. prev = this.previousSibling;
  3953. while (prev) {
  3954. str = prev.data + str;
  3955. prev = prev.previousSibling;
  3956. }
  3957. str += this.data;
  3958. next = this.nextSibling;
  3959. while (next) {
  3960. str = str + next.data;
  3961. next = next.nextSibling;
  3962. }
  3963. return str;
  3964. }
  3965. });
  3966. return XMLText;
  3967. }).call(this);
  3968. }).call(this);
  3969. },{"./NodeType":5,"./XMLCharacterData":10}],35:[function(require,module,exports){
  3970. // Generated by CoffeeScript 2.4.1
  3971. (function() {
  3972. var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
  3973. hasProp = {}.hasOwnProperty;
  3974. ({assign} = require('./Utility'));
  3975. NodeType = require('./NodeType');
  3976. XMLDeclaration = require('./XMLDeclaration');
  3977. XMLDocType = require('./XMLDocType');
  3978. XMLCData = require('./XMLCData');
  3979. XMLComment = require('./XMLComment');
  3980. XMLElement = require('./XMLElement');
  3981. XMLRaw = require('./XMLRaw');
  3982. XMLText = require('./XMLText');
  3983. XMLProcessingInstruction = require('./XMLProcessingInstruction');
  3984. XMLDummy = require('./XMLDummy');
  3985. XMLDTDAttList = require('./XMLDTDAttList');
  3986. XMLDTDElement = require('./XMLDTDElement');
  3987. XMLDTDEntity = require('./XMLDTDEntity');
  3988. XMLDTDNotation = require('./XMLDTDNotation');
  3989. WriterState = require('./WriterState');
  3990. // Base class for XML writers
  3991. module.exports = XMLWriterBase = class XMLWriterBase {
  3992. // Initializes a new instance of `XMLWriterBase`
  3993. // `options.pretty` pretty prints the result
  3994. // `options.indent` indentation string
  3995. // `options.newline` newline sequence
  3996. // `options.offset` a fixed number of indentations to add to every line
  3997. // `options.width` maximum column width
  3998. // `options.allowEmpty` do not self close empty element tags
  3999. // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
  4000. // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
  4001. constructor(options) {
  4002. var key, ref, value;
  4003. options || (options = {});
  4004. this.options = options;
  4005. ref = options.writer || {};
  4006. for (key in ref) {
  4007. if (!hasProp.call(ref, key)) continue;
  4008. value = ref[key];
  4009. this["_" + key] = this[key];
  4010. this[key] = value;
  4011. }
  4012. }
  4013. // Filters writer options and provides defaults
  4014. // `options` writer options
  4015. filterOptions(options) {
  4016. var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
  4017. options || (options = {});
  4018. options = assign({}, this.options, options);
  4019. filteredOptions = {
  4020. writer: this
  4021. };
  4022. filteredOptions.pretty = options.pretty || false;
  4023. filteredOptions.allowEmpty = options.allowEmpty || false;
  4024. filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
  4025. filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
  4026. filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
  4027. filteredOptions.width = (ref3 = options.width) != null ? ref3 : 0;
  4028. filteredOptions.dontPrettyTextNodes = (ref4 = (ref5 = options.dontPrettyTextNodes) != null ? ref5 : options.dontprettytextnodes) != null ? ref4 : 0;
  4029. filteredOptions.spaceBeforeSlash = (ref6 = (ref7 = options.spaceBeforeSlash) != null ? ref7 : options.spacebeforeslash) != null ? ref6 : '';
  4030. if (filteredOptions.spaceBeforeSlash === true) {
  4031. filteredOptions.spaceBeforeSlash = ' ';
  4032. }
  4033. filteredOptions.suppressPrettyCount = 0;
  4034. filteredOptions.user = {};
  4035. filteredOptions.state = WriterState.None;
  4036. return filteredOptions;
  4037. }
  4038. // Returns the indentation string for the current level
  4039. // `node` current node
  4040. // `options` writer options
  4041. // `level` current indentation level
  4042. indent(node, options, level) {
  4043. var indentLevel;
  4044. if (!options.pretty || options.suppressPrettyCount) {
  4045. return '';
  4046. } else if (options.pretty) {
  4047. indentLevel = (level || 0) + options.offset + 1;
  4048. if (indentLevel > 0) {
  4049. return new Array(indentLevel).join(options.indent);
  4050. }
  4051. }
  4052. return '';
  4053. }
  4054. // Returns the newline string
  4055. // `node` current node
  4056. // `options` writer options
  4057. // `level` current indentation level
  4058. endline(node, options, level) {
  4059. if (!options.pretty || options.suppressPrettyCount) {
  4060. return '';
  4061. } else {
  4062. return options.newline;
  4063. }
  4064. }
  4065. attribute(att, options, level) {
  4066. var r;
  4067. this.openAttribute(att, options, level);
  4068. if (options.pretty && options.width > 0) {
  4069. r = att.name + '="' + att.value + '"';
  4070. } else {
  4071. r = ' ' + att.name + '="' + att.value + '"';
  4072. }
  4073. this.closeAttribute(att, options, level);
  4074. return r;
  4075. }
  4076. cdata(node, options, level) {
  4077. var r;
  4078. this.openNode(node, options, level);
  4079. options.state = WriterState.OpenTag;
  4080. r = this.indent(node, options, level) + '<![CDATA[';
  4081. options.state = WriterState.InsideTag;
  4082. r += node.value;
  4083. options.state = WriterState.CloseTag;
  4084. r += ']]>' + this.endline(node, options, level);
  4085. options.state = WriterState.None;
  4086. this.closeNode(node, options, level);
  4087. return r;
  4088. }
  4089. comment(node, options, level) {
  4090. var r;
  4091. this.openNode(node, options, level);
  4092. options.state = WriterState.OpenTag;
  4093. r = this.indent(node, options, level) + '<!-- ';
  4094. options.state = WriterState.InsideTag;
  4095. r += node.value;
  4096. options.state = WriterState.CloseTag;
  4097. r += ' -->' + this.endline(node, options, level);
  4098. options.state = WriterState.None;
  4099. this.closeNode(node, options, level);
  4100. return r;
  4101. }
  4102. declaration(node, options, level) {
  4103. var r;
  4104. this.openNode(node, options, level);
  4105. options.state = WriterState.OpenTag;
  4106. r = this.indent(node, options, level) + '<?xml';
  4107. options.state = WriterState.InsideTag;
  4108. r += ' version="' + node.version + '"';
  4109. if (node.encoding != null) {
  4110. r += ' encoding="' + node.encoding + '"';
  4111. }
  4112. if (node.standalone != null) {
  4113. r += ' standalone="' + node.standalone + '"';
  4114. }
  4115. options.state = WriterState.CloseTag;
  4116. r += options.spaceBeforeSlash + '?>';
  4117. r += this.endline(node, options, level);
  4118. options.state = WriterState.None;
  4119. this.closeNode(node, options, level);
  4120. return r;
  4121. }
  4122. docType(node, options, level) {
  4123. var child, i, len1, r, ref;
  4124. level || (level = 0);
  4125. this.openNode(node, options, level);
  4126. options.state = WriterState.OpenTag;
  4127. r = this.indent(node, options, level);
  4128. r += '<!DOCTYPE ' + node.root().name;
  4129. // external identifier
  4130. if (node.pubID && node.sysID) {
  4131. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  4132. } else if (node.sysID) {
  4133. r += ' SYSTEM "' + node.sysID + '"';
  4134. }
  4135. // internal subset
  4136. if (node.children.length > 0) {
  4137. r += ' [';
  4138. r += this.endline(node, options, level);
  4139. options.state = WriterState.InsideTag;
  4140. ref = node.children;
  4141. for (i = 0, len1 = ref.length; i < len1; i++) {
  4142. child = ref[i];
  4143. r += this.writeChildNode(child, options, level + 1);
  4144. }
  4145. options.state = WriterState.CloseTag;
  4146. r += ']';
  4147. }
  4148. // close tag
  4149. options.state = WriterState.CloseTag;
  4150. r += options.spaceBeforeSlash + '>';
  4151. r += this.endline(node, options, level);
  4152. options.state = WriterState.None;
  4153. this.closeNode(node, options, level);
  4154. return r;
  4155. }
  4156. element(node, options, level) {
  4157. var att, attLen, child, childNodeCount, firstChildNode, i, j, len, len1, len2, name, prettySuppressed, r, ratt, ref, ref1, ref2, ref3, rline;
  4158. level || (level = 0);
  4159. prettySuppressed = false;
  4160. // open tag
  4161. this.openNode(node, options, level);
  4162. options.state = WriterState.OpenTag;
  4163. r = this.indent(node, options, level) + '<' + node.name;
  4164. // attributes
  4165. if (options.pretty && options.width > 0) {
  4166. len = r.length;
  4167. ref = node.attribs;
  4168. for (name in ref) {
  4169. if (!hasProp.call(ref, name)) continue;
  4170. att = ref[name];
  4171. ratt = this.attribute(att, options, level);
  4172. attLen = ratt.length;
  4173. if (len + attLen > options.width) {
  4174. rline = this.indent(node, options, level + 1) + ratt;
  4175. r += this.endline(node, options, level) + rline;
  4176. len = rline.length;
  4177. } else {
  4178. rline = ' ' + ratt;
  4179. r += rline;
  4180. len += rline.length;
  4181. }
  4182. }
  4183. } else {
  4184. ref1 = node.attribs;
  4185. for (name in ref1) {
  4186. if (!hasProp.call(ref1, name)) continue;
  4187. att = ref1[name];
  4188. r += this.attribute(att, options, level);
  4189. }
  4190. }
  4191. childNodeCount = node.children.length;
  4192. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  4193. if (childNodeCount === 0 || node.children.every(function(e) {
  4194. return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
  4195. })) {
  4196. // empty element
  4197. if (options.allowEmpty) {
  4198. r += '>';
  4199. options.state = WriterState.CloseTag;
  4200. r += '</' + node.name + '>' + this.endline(node, options, level);
  4201. } else {
  4202. options.state = WriterState.CloseTag;
  4203. r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
  4204. }
  4205. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
  4206. // do not indent text-only nodes
  4207. r += '>';
  4208. options.state = WriterState.InsideTag;
  4209. options.suppressPrettyCount++;
  4210. prettySuppressed = true;
  4211. r += this.writeChildNode(firstChildNode, options, level + 1);
  4212. options.suppressPrettyCount--;
  4213. prettySuppressed = false;
  4214. options.state = WriterState.CloseTag;
  4215. r += '</' + node.name + '>' + this.endline(node, options, level);
  4216. } else {
  4217. // if ANY are a text node, then suppress pretty now
  4218. if (options.dontPrettyTextNodes) {
  4219. ref2 = node.children;
  4220. for (i = 0, len1 = ref2.length; i < len1; i++) {
  4221. child = ref2[i];
  4222. if ((child.type === NodeType.Text || child.type === NodeType.Raw || child.type === NodeType.CData) && (child.value != null)) {
  4223. options.suppressPrettyCount++;
  4224. prettySuppressed = true;
  4225. break;
  4226. }
  4227. }
  4228. }
  4229. // close the opening tag, after dealing with newline
  4230. r += '>' + this.endline(node, options, level);
  4231. options.state = WriterState.InsideTag;
  4232. ref3 = node.children;
  4233. // inner tags
  4234. for (j = 0, len2 = ref3.length; j < len2; j++) {
  4235. child = ref3[j];
  4236. r += this.writeChildNode(child, options, level + 1);
  4237. }
  4238. // close tag
  4239. options.state = WriterState.CloseTag;
  4240. r += this.indent(node, options, level) + '</' + node.name + '>';
  4241. if (prettySuppressed) {
  4242. options.suppressPrettyCount--;
  4243. }
  4244. r += this.endline(node, options, level);
  4245. options.state = WriterState.None;
  4246. }
  4247. this.closeNode(node, options, level);
  4248. return r;
  4249. }
  4250. writeChildNode(node, options, level) {
  4251. switch (node.type) {
  4252. case NodeType.CData:
  4253. return this.cdata(node, options, level);
  4254. case NodeType.Comment:
  4255. return this.comment(node, options, level);
  4256. case NodeType.Element:
  4257. return this.element(node, options, level);
  4258. case NodeType.Raw:
  4259. return this.raw(node, options, level);
  4260. case NodeType.Text:
  4261. return this.text(node, options, level);
  4262. case NodeType.ProcessingInstruction:
  4263. return this.processingInstruction(node, options, level);
  4264. case NodeType.Dummy:
  4265. return '';
  4266. case NodeType.Declaration:
  4267. return this.declaration(node, options, level);
  4268. case NodeType.DocType:
  4269. return this.docType(node, options, level);
  4270. case NodeType.AttributeDeclaration:
  4271. return this.dtdAttList(node, options, level);
  4272. case NodeType.ElementDeclaration:
  4273. return this.dtdElement(node, options, level);
  4274. case NodeType.EntityDeclaration:
  4275. return this.dtdEntity(node, options, level);
  4276. case NodeType.NotationDeclaration:
  4277. return this.dtdNotation(node, options, level);
  4278. default:
  4279. throw new Error("Unknown XML node type: " + node.constructor.name);
  4280. }
  4281. }
  4282. processingInstruction(node, options, level) {
  4283. var r;
  4284. this.openNode(node, options, level);
  4285. options.state = WriterState.OpenTag;
  4286. r = this.indent(node, options, level) + '<?';
  4287. options.state = WriterState.InsideTag;
  4288. r += node.target;
  4289. if (node.value) {
  4290. r += ' ' + node.value;
  4291. }
  4292. options.state = WriterState.CloseTag;
  4293. r += options.spaceBeforeSlash + '?>';
  4294. r += this.endline(node, options, level);
  4295. options.state = WriterState.None;
  4296. this.closeNode(node, options, level);
  4297. return r;
  4298. }
  4299. raw(node, options, level) {
  4300. var r;
  4301. this.openNode(node, options, level);
  4302. options.state = WriterState.OpenTag;
  4303. r = this.indent(node, options, level);
  4304. options.state = WriterState.InsideTag;
  4305. r += node.value;
  4306. options.state = WriterState.CloseTag;
  4307. r += this.endline(node, options, level);
  4308. options.state = WriterState.None;
  4309. this.closeNode(node, options, level);
  4310. return r;
  4311. }
  4312. text(node, options, level) {
  4313. var r;
  4314. this.openNode(node, options, level);
  4315. options.state = WriterState.OpenTag;
  4316. r = this.indent(node, options, level);
  4317. options.state = WriterState.InsideTag;
  4318. r += node.value;
  4319. options.state = WriterState.CloseTag;
  4320. r += this.endline(node, options, level);
  4321. options.state = WriterState.None;
  4322. this.closeNode(node, options, level);
  4323. return r;
  4324. }
  4325. dtdAttList(node, options, level) {
  4326. var r;
  4327. this.openNode(node, options, level);
  4328. options.state = WriterState.OpenTag;
  4329. r = this.indent(node, options, level) + '<!ATTLIST';
  4330. options.state = WriterState.InsideTag;
  4331. r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
  4332. if (node.defaultValueType !== '#DEFAULT') {
  4333. r += ' ' + node.defaultValueType;
  4334. }
  4335. if (node.defaultValue) {
  4336. r += ' "' + node.defaultValue + '"';
  4337. }
  4338. options.state = WriterState.CloseTag;
  4339. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  4340. options.state = WriterState.None;
  4341. this.closeNode(node, options, level);
  4342. return r;
  4343. }
  4344. dtdElement(node, options, level) {
  4345. var r;
  4346. this.openNode(node, options, level);
  4347. options.state = WriterState.OpenTag;
  4348. r = this.indent(node, options, level) + '<!ELEMENT';
  4349. options.state = WriterState.InsideTag;
  4350. r += ' ' + node.name + ' ' + node.value;
  4351. options.state = WriterState.CloseTag;
  4352. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  4353. options.state = WriterState.None;
  4354. this.closeNode(node, options, level);
  4355. return r;
  4356. }
  4357. dtdEntity(node, options, level) {
  4358. var r;
  4359. this.openNode(node, options, level);
  4360. options.state = WriterState.OpenTag;
  4361. r = this.indent(node, options, level) + '<!ENTITY';
  4362. options.state = WriterState.InsideTag;
  4363. if (node.pe) {
  4364. r += ' %';
  4365. }
  4366. r += ' ' + node.name;
  4367. if (node.value) {
  4368. r += ' "' + node.value + '"';
  4369. } else {
  4370. if (node.pubID && node.sysID) {
  4371. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  4372. } else if (node.sysID) {
  4373. r += ' SYSTEM "' + node.sysID + '"';
  4374. }
  4375. if (node.nData) {
  4376. r += ' NDATA ' + node.nData;
  4377. }
  4378. }
  4379. options.state = WriterState.CloseTag;
  4380. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  4381. options.state = WriterState.None;
  4382. this.closeNode(node, options, level);
  4383. return r;
  4384. }
  4385. dtdNotation(node, options, level) {
  4386. var r;
  4387. this.openNode(node, options, level);
  4388. options.state = WriterState.OpenTag;
  4389. r = this.indent(node, options, level) + '<!NOTATION';
  4390. options.state = WriterState.InsideTag;
  4391. r += ' ' + node.name;
  4392. if (node.pubID && node.sysID) {
  4393. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  4394. } else if (node.pubID) {
  4395. r += ' PUBLIC "' + node.pubID + '"';
  4396. } else if (node.sysID) {
  4397. r += ' SYSTEM "' + node.sysID + '"';
  4398. }
  4399. options.state = WriterState.CloseTag;
  4400. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  4401. options.state = WriterState.None;
  4402. this.closeNode(node, options, level);
  4403. return r;
  4404. }
  4405. openNode(node, options, level) {}
  4406. closeNode(node, options, level) {}
  4407. openAttribute(att, options, level) {}
  4408. closeAttribute(att, options, level) {}
  4409. };
  4410. }).call(this);
  4411. },{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLCData":9,"./XMLComment":11,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLDeclaration":20,"./XMLDocType":21,"./XMLDummy":24,"./XMLElement":25,"./XMLProcessingInstruction":29,"./XMLRaw":30,"./XMLText":34}],36:[function(require,module,exports){
  4412. // Generated by CoffeeScript 2.4.1
  4413. (function() {
  4414. var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction;
  4415. ({assign, isFunction} = require('./Utility'));
  4416. XMLDOMImplementation = require('./XMLDOMImplementation');
  4417. XMLDocument = require('./XMLDocument');
  4418. XMLDocumentCB = require('./XMLDocumentCB');
  4419. XMLStringWriter = require('./XMLStringWriter');
  4420. XMLStreamWriter = require('./XMLStreamWriter');
  4421. NodeType = require('./NodeType');
  4422. WriterState = require('./WriterState');
  4423. // Creates a new document and returns the root node for
  4424. // chain-building the document tree
  4425. // `name` name of the root element
  4426. // `xmldec.version` A version number string, e.g. 1.0
  4427. // `xmldec.encoding` Encoding declaration, e.g. UTF-8
  4428. // `xmldec.standalone` standalone document declaration: true or false
  4429. // `doctype.pubID` public identifier of the external subset
  4430. // `doctype.sysID` system identifier of the external subset
  4431. // `options.headless` whether XML declaration and doctype will be included:
  4432. // true or false
  4433. // `options.keepNullNodes` whether nodes with null values will be kept
  4434. // or ignored: true or false
  4435. // `options.keepNullAttributes` whether attributes with null values will be
  4436. // kept or ignored: true or false
  4437. // `options.ignoreDecorators` whether decorator strings will be ignored when
  4438. // converting JS objects: true or false
  4439. // `options.separateArrayItems` whether array items are created as separate
  4440. // nodes when passed as an object value: true or false
  4441. // `options.noDoubleEncoding` whether existing html entities are encoded:
  4442. // true or false
  4443. // `options.stringify` a set of functions to use for converting values to
  4444. // strings
  4445. // `options.writer` the default XML writer to use for converting nodes to
  4446. // string. If the default writer is not set, the built-in XMLStringWriter
  4447. // will be used instead.
  4448. module.exports.create = function(name, xmldec, doctype, options) {
  4449. var doc, root;
  4450. if (name == null) {
  4451. throw new Error("Root element needs a name.");
  4452. }
  4453. options = assign({}, xmldec, doctype, options);
  4454. // create the document node
  4455. doc = new XMLDocument(options);
  4456. // add the root node
  4457. root = doc.element(name);
  4458. // prolog
  4459. if (!options.headless) {
  4460. doc.declaration(options);
  4461. if ((options.pubID != null) || (options.sysID != null)) {
  4462. doc.dtd(options);
  4463. }
  4464. }
  4465. return root;
  4466. };
  4467. // Creates a new document and returns the document node for
  4468. // chain-building the document tree
  4469. // `options.keepNullNodes` whether nodes with null values will be kept
  4470. // or ignored: true or false
  4471. // `options.keepNullAttributes` whether attributes with null values will be
  4472. // kept or ignored: true or false
  4473. // `options.ignoreDecorators` whether decorator strings will be ignored when
  4474. // converting JS objects: true or false
  4475. // `options.separateArrayItems` whether array items are created as separate
  4476. // nodes when passed as an object value: true or false
  4477. // `options.noDoubleEncoding` whether existing html entities are encoded:
  4478. // true or false
  4479. // `options.stringify` a set of functions to use for converting values to
  4480. // strings
  4481. // `options.writer` the default XML writer to use for converting nodes to
  4482. // string. If the default writer is not set, the built-in XMLStringWriter
  4483. // will be used instead.
  4484. // `onData` the function to be called when a new chunk of XML is output. The
  4485. // string containing the XML chunk is passed to `onData` as its single
  4486. // argument.
  4487. // `onEnd` the function to be called when the XML document is completed with
  4488. // `end`. `onEnd` does not receive any arguments.
  4489. module.exports.begin = function(options, onData, onEnd) {
  4490. if (isFunction(options)) {
  4491. [onData, onEnd] = [options, onData];
  4492. options = {};
  4493. }
  4494. if (onData) {
  4495. return new XMLDocumentCB(options, onData, onEnd);
  4496. } else {
  4497. return new XMLDocument(options);
  4498. }
  4499. };
  4500. module.exports.stringWriter = function(options) {
  4501. return new XMLStringWriter(options);
  4502. };
  4503. module.exports.streamWriter = function(stream, options) {
  4504. return new XMLStreamWriter(stream, options);
  4505. };
  4506. module.exports.implementation = new XMLDOMImplementation();
  4507. module.exports.nodeType = NodeType;
  4508. module.exports.writerState = WriterState;
  4509. }).call(this);
  4510. },{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLDOMImplementation":14,"./XMLDocument":22,"./XMLDocumentCB":23,"./XMLStreamWriter":31,"./XMLStringWriter":32}]},{},[1])(1)
  4511. });