You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

plist-build.js 164KB

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