12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348 |
- (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){
- (function (Buffer){(function (){
- /**
- * Module dependencies.
- */
-
- var base64 = require('base64-js');
- var xmlbuilder = require('xmlbuilder');
-
- /**
- * Module exports.
- */
-
- exports.build = build;
-
- /**
- * Accepts a `Date` instance and returns an ISO date string.
- *
- * @param {Date} d - Date instance to serialize
- * @returns {String} ISO date string representation of `d`
- * @api private
- */
-
- function ISODateString(d){
- function pad(n){
- return n < 10 ? '0' + n : n;
- }
- return d.getUTCFullYear()+'-'
- + pad(d.getUTCMonth()+1)+'-'
- + pad(d.getUTCDate())+'T'
- + pad(d.getUTCHours())+':'
- + pad(d.getUTCMinutes())+':'
- + pad(d.getUTCSeconds())+'Z';
- }
-
- /**
- * Returns the internal "type" of `obj` via the
- * `Object.prototype.toString()` trick.
- *
- * @param {Mixed} obj - any value
- * @returns {String} the internal "type" name
- * @api private
- */
-
- var toString = Object.prototype.toString;
- function type (obj) {
- var m = toString.call(obj).match(/\[object (.*)\]/);
- return m ? m[1] : m;
- }
-
- /**
- * Generate an XML plist string from the input object `obj`.
- *
- * @param {Object} obj - the object to convert
- * @param {Object} [opts] - optional options object
- * @returns {String} converted plist XML string
- * @api public
- */
-
- function build (obj, opts) {
- var XMLHDR = {
- version: '1.0',
- encoding: 'UTF-8'
- };
-
- var XMLDTD = {
- pubid: '-//Apple//DTD PLIST 1.0//EN',
- sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
- };
-
- var doc = xmlbuilder.create('plist');
-
- doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
- doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
- doc.att('version', '1.0');
-
- walk_obj(obj, doc);
-
- if (!opts) opts = {};
- // default `pretty` to `true`
- opts.pretty = opts.pretty !== false;
- return doc.end(opts);
- }
-
- /**
- * depth first, recursive traversal of a javascript object. when complete,
- * next_child contains a reference to the build XML object.
- *
- * @api private
- */
-
- function walk_obj(next, next_child) {
- var tag_type, i, prop;
- var name = type(next);
-
- if ('Undefined' == name) {
- return;
- } else if (Array.isArray(next)) {
- next_child = next_child.ele('array');
- for (i = 0; i < next.length; i++) {
- walk_obj(next[i], next_child);
- }
-
- } else if (Buffer.isBuffer(next)) {
- next_child.ele('data').raw(next.toString('base64'));
-
- } else if ('Object' == name) {
- next_child = next_child.ele('dict');
- for (prop in next) {
- if (next.hasOwnProperty(prop)) {
- next_child.ele('key').txt(prop);
- walk_obj(next[prop], next_child);
- }
- }
-
- } else if ('Number' == name) {
- // detect if this is an integer or real
- // TODO: add an ability to force one way or another via a "cast"
- tag_type = (next % 1 === 0) ? 'integer' : 'real';
- next_child.ele(tag_type).txt(next.toString());
-
- } else if ('BigInt' == name) {
- next_child.ele('integer').txt(next);
-
- } else if ('Date' == name) {
- next_child.ele('date').txt(ISODateString(new Date(next)));
-
- } else if ('Boolean' == name) {
- next_child.ele(next ? 'true' : 'false');
-
- } else if ('String' == name) {
- next_child.ele('string').txt(next);
-
- } else if ('ArrayBuffer' == name) {
- next_child.ele('data').raw(base64.fromByteArray(next));
-
- } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
- // a typed array
- next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
-
- } else if ('Null' === name) {
- next_child.ele('null').txt('');
-
- }
- }
-
- }).call(this)}).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
- },{"../node_modules/is-buffer/index.js":3,"base64-js":2,"xmlbuilder":36}],2:[function(require,module,exports){
- 'use strict'
-
- exports.byteLength = byteLength
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
-
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
-
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
-
- // Support decoding URL-safe base64 strings, as Node.js does.
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
-
- function getLens (b64) {
- var len = b64.length
-
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
-
- // Trim off extra bytes after placeholder bytes are found
- // See: https://github.com/beatgammit/base64-js/issues/42
- var validLen = b64.indexOf('=')
- if (validLen === -1) validLen = len
-
- var placeHoldersLen = validLen === len
- ? 0
- : 4 - (validLen % 4)
-
- return [validLen, placeHoldersLen]
- }
-
- // base64 is 4/3 + up to two characters of the original data
- function byteLength (b64) {
- var lens = getLens(b64)
- var validLen = lens[0]
- var placeHoldersLen = lens[1]
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
- }
-
- function _byteLength (b64, validLen, placeHoldersLen) {
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
- }
-
- function toByteArray (b64) {
- var tmp
- var lens = getLens(b64)
- var validLen = lens[0]
- var placeHoldersLen = lens[1]
-
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
-
- var curByte = 0
-
- // if there are placeholders, only get up to the last complete 4 chars
- var len = placeHoldersLen > 0
- ? validLen - 4
- : validLen
-
- var i
- for (i = 0; i < len; i += 4) {
- tmp =
- (revLookup[b64.charCodeAt(i)] << 18) |
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
- revLookup[b64.charCodeAt(i + 3)]
- arr[curByte++] = (tmp >> 16) & 0xFF
- arr[curByte++] = (tmp >> 8) & 0xFF
- arr[curByte++] = tmp & 0xFF
- }
-
- if (placeHoldersLen === 2) {
- tmp =
- (revLookup[b64.charCodeAt(i)] << 2) |
- (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[curByte++] = tmp & 0xFF
- }
-
- if (placeHoldersLen === 1) {
- tmp =
- (revLookup[b64.charCodeAt(i)] << 10) |
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
- (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[curByte++] = (tmp >> 8) & 0xFF
- arr[curByte++] = tmp & 0xFF
- }
-
- return arr
- }
-
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] +
- lookup[num >> 12 & 0x3F] +
- lookup[num >> 6 & 0x3F] +
- lookup[num & 0x3F]
- }
-
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp =
- ((uint8[i] << 16) & 0xFF0000) +
- ((uint8[i + 1] << 8) & 0xFF00) +
- (uint8[i + 2] & 0xFF)
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
-
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
-
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
-
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- parts.push(
- lookup[tmp >> 2] +
- lookup[(tmp << 4) & 0x3F] +
- '=='
- )
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + uint8[len - 1]
- parts.push(
- lookup[tmp >> 10] +
- lookup[(tmp >> 4) & 0x3F] +
- lookup[(tmp << 2) & 0x3F] +
- '='
- )
- }
-
- return parts.join('')
- }
-
- },{}],3:[function(require,module,exports){
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */
-
- // The _isBuffer check is for Safari 5-7 support, because it's missing
- // Object.prototype.constructor. Remove this eventually
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
-
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
-
- // For Node v0.10 support. Remove this eventually.
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
-
- },{}],4:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- module.exports = {
- Disconnected: 1,
- Preceding: 2,
- Following: 4,
- Contains: 8,
- ContainedBy: 16,
- ImplementationSpecific: 32
- };
-
- }).call(this);
-
- },{}],5:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- module.exports = {
- Element: 1,
- Attribute: 2,
- Text: 3,
- CData: 4,
- EntityReference: 5,
- EntityDeclaration: 6,
- ProcessingInstruction: 7,
- Comment: 8,
- Document: 9,
- DocType: 10,
- DocumentFragment: 11,
- NotationDeclaration: 12,
- // Numeric codes up to 200 are reserved to W3C for possible future use.
- // Following are types internal to this library:
- Declaration: 201,
- Raw: 202,
- AttributeDeclaration: 203,
- ElementDeclaration: 204,
- Dummy: 205
- };
-
- }).call(this);
-
- },{}],6:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Copies all enumerable own properties from `sources` to `target`
- var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
- hasProp = {}.hasOwnProperty;
-
- assign = function(target, ...sources) {
- var i, key, len, source;
- if (isFunction(Object.assign)) {
- Object.assign.apply(null, arguments);
- } else {
- for (i = 0, len = sources.length; i < len; i++) {
- source = sources[i];
- if (source != null) {
- for (key in source) {
- if (!hasProp.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- }
- }
- return target;
- };
-
- // Determines if `val` is a Function object
- isFunction = function(val) {
- return !!val && Object.prototype.toString.call(val) === '[object Function]';
- };
-
- // Determines if `val` is an Object
- isObject = function(val) {
- var ref;
- return !!val && ((ref = typeof val) === 'function' || ref === 'object');
- };
-
- // Determines if `val` is an Array
- isArray = function(val) {
- if (isFunction(Array.isArray)) {
- return Array.isArray(val);
- } else {
- return Object.prototype.toString.call(val) === '[object Array]';
- }
- };
-
- // Determines if `val` is an empty Array or an Object with no own properties
- isEmpty = function(val) {
- var key;
- if (isArray(val)) {
- return !val.length;
- } else {
- for (key in val) {
- if (!hasProp.call(val, key)) continue;
- return false;
- }
- return true;
- }
- };
-
- // Determines if `val` is a plain Object
- isPlainObject = function(val) {
- var ctor, proto;
- return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
- };
-
- // Gets the primitive value of an object
- getValue = function(obj) {
- if (isFunction(obj.valueOf)) {
- return obj.valueOf();
- } else {
- return obj;
- }
- };
-
- module.exports.assign = assign;
-
- module.exports.isFunction = isFunction;
-
- module.exports.isObject = isObject;
-
- module.exports.isArray = isArray;
-
- module.exports.isEmpty = isEmpty;
-
- module.exports.isPlainObject = isPlainObject;
-
- module.exports.getValue = getValue;
-
- }).call(this);
-
- },{}],7:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- module.exports = {
- None: 0,
- OpenTag: 1,
- InsideTag: 2,
- CloseTag: 3
- };
-
- }).call(this);
-
- },{}],8:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLAttribute, XMLNode;
-
- NodeType = require('./NodeType');
-
- XMLNode = require('./XMLNode');
-
- // Represents an attribute
- module.exports = XMLAttribute = (function() {
- class XMLAttribute {
- // Initializes a new instance of `XMLAttribute`
-
- // `parent` the parent node
- // `name` attribute target
- // `value` attribute value
- constructor(parent, name, value) {
- this.parent = parent;
- if (this.parent) {
- this.options = this.parent.options;
- this.stringify = this.parent.stringify;
- }
- if (name == null) {
- throw new Error("Missing attribute name. " + this.debugInfo(name));
- }
- this.name = this.stringify.name(name);
- this.value = this.stringify.attValue(value);
- this.type = NodeType.Attribute;
- // DOM level 3
- this.isId = false;
- this.schemaTypeInfo = null;
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
- }
-
-
- // Returns debug string for this node
- debugInfo(name) {
- name = name || this.name;
- if (name == null) {
- return "parent: <" + this.parent.name + ">";
- } else {
- return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
- }
- }
-
- isEqualNode(node) {
- if (node.namespaceURI !== this.namespaceURI) {
- return false;
- }
- if (node.prefix !== this.prefix) {
- return false;
- }
- if (node.localName !== this.localName) {
- return false;
- }
- if (node.value !== this.value) {
- return false;
- }
- return true;
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
- get: function() {
- return this.type;
- }
- });
-
- Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
- get: function() {
- return this.parent;
- }
- });
-
- // DOM level 3
- Object.defineProperty(XMLAttribute.prototype, 'textContent', {
- get: function() {
- return this.value;
- },
- set: function(value) {
- return this.value = value || '';
- }
- });
-
- // DOM level 4
- Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
- get: function() {
- return '';
- }
- });
-
- Object.defineProperty(XMLAttribute.prototype, 'prefix', {
- get: function() {
- return '';
- }
- });
-
- Object.defineProperty(XMLAttribute.prototype, 'localName', {
- get: function() {
- return this.name;
- }
- });
-
- Object.defineProperty(XMLAttribute.prototype, 'specified', {
- get: function() {
- return true;
- }
- });
-
- return XMLAttribute;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],9:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLCData, XMLCharacterData;
-
- NodeType = require('./NodeType');
-
- XMLCharacterData = require('./XMLCharacterData');
-
- // Represents a CDATA node
- module.exports = XMLCData = class XMLCData extends XMLCharacterData {
- // Initializes a new instance of `XMLCData`
-
- // `text` CDATA text
- constructor(parent, text) {
- super(parent);
- if (text == null) {
- throw new Error("Missing CDATA text. " + this.debugInfo());
- }
- this.name = "#cdata-section";
- this.type = NodeType.CData;
- this.value = this.stringify.cdata(text);
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLCharacterData":10}],10:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var XMLCharacterData, XMLNode;
-
- XMLNode = require('./XMLNode');
-
- // Represents a character data node
- module.exports = XMLCharacterData = (function() {
- class XMLCharacterData extends XMLNode {
- // Initializes a new instance of `XMLCharacterData`
-
- constructor(parent) {
- super(parent);
- this.value = '';
- }
-
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // DOM level 1 functions to be implemented later
- substringData(offset, count) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- appendData(arg) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- insertData(offset, arg) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- deleteData(offset, count) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- replaceData(offset, count, arg) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- isEqualNode(node) {
- if (!super.isEqualNode(node)) {
- return false;
- }
- if (node.data !== this.data) {
- return false;
- }
- return true;
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLCharacterData.prototype, 'data', {
- get: function() {
- return this.value;
- },
- set: function(value) {
- return this.value = value || '';
- }
- });
-
- Object.defineProperty(XMLCharacterData.prototype, 'length', {
- get: function() {
- return this.value.length;
- }
- });
-
- // DOM level 3
- Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
- get: function() {
- return this.value;
- },
- set: function(value) {
- return this.value = value || '';
- }
- });
-
- return XMLCharacterData;
-
- }).call(this);
-
- }).call(this);
-
- },{"./XMLNode":27}],11:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLCharacterData, XMLComment;
-
- NodeType = require('./NodeType');
-
- XMLCharacterData = require('./XMLCharacterData');
-
- // Represents a comment node
- module.exports = XMLComment = class XMLComment extends XMLCharacterData {
- // Initializes a new instance of `XMLComment`
-
- // `text` comment text
- constructor(parent, text) {
- super(parent);
- if (text == null) {
- throw new Error("Missing comment text. " + this.debugInfo());
- }
- this.name = "#comment";
- this.type = NodeType.Comment;
- this.value = this.stringify.comment(text);
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.comment(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLCharacterData":10}],12:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
-
- XMLDOMErrorHandler = require('./XMLDOMErrorHandler');
-
- XMLDOMStringList = require('./XMLDOMStringList');
-
- // Implements the DOMConfiguration interface
- module.exports = XMLDOMConfiguration = (function() {
- class XMLDOMConfiguration {
- constructor() {
- var clonedSelf;
- this.defaultParams = {
- "canonical-form": false,
- "cdata-sections": false,
- "comments": false,
- "datatype-normalization": false,
- "element-content-whitespace": true,
- "entities": true,
- "error-handler": new XMLDOMErrorHandler(),
- "infoset": true,
- "validate-if-schema": false,
- "namespaces": true,
- "namespace-declarations": true,
- "normalize-characters": false,
- "schema-location": '',
- "schema-type": '',
- "split-cdata-sections": true,
- "validate": false,
- "well-formed": true
- };
- this.params = clonedSelf = Object.create(this.defaultParams);
- }
-
- // Gets the value of a parameter.
-
- // `name` name of the parameter
- getParameter(name) {
- if (this.params.hasOwnProperty(name)) {
- return this.params[name];
- } else {
- return null;
- }
- }
-
- // Checks if setting a parameter to a specific value is supported.
-
- // `name` name of the parameter
- // `value` parameter value
- canSetParameter(name, value) {
- return true;
- }
-
- // Sets the value of a parameter.
-
- // `name` name of the parameter
- // `value` new value or null if the user wishes to unset the parameter
- setParameter(name, value) {
- if (value != null) {
- return this.params[name] = value;
- } else {
- return delete this.params[name];
- }
- }
-
- };
-
- // Returns the list of parameter names
- Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
- get: function() {
- return new XMLDOMStringList(Object.keys(this.defaultParams));
- }
- });
-
- return XMLDOMConfiguration;
-
- }).call(this);
-
- }).call(this);
-
- },{"./XMLDOMErrorHandler":13,"./XMLDOMStringList":15}],13:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Represents the error handler for DOM operations
- var XMLDOMErrorHandler;
-
- module.exports = XMLDOMErrorHandler = class XMLDOMErrorHandler {
- // Initializes a new instance of `XMLDOMErrorHandler`
-
- constructor() {}
-
- // Called on the error handler when an error occurs.
-
- // `error` the error message as a string
- handleError(error) {
- throw new Error(error);
- }
-
- };
-
- }).call(this);
-
- },{}],14:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Implements the DOMImplementation interface
- var XMLDOMImplementation;
-
- module.exports = XMLDOMImplementation = class XMLDOMImplementation {
- // Tests if the DOM implementation implements a specific feature.
-
- // `feature` package name of the feature to test. In Level 1, the
- // legal values are "HTML" and "XML" (case-insensitive).
- // `version` version number of the package name to test.
- // In Level 1, this is the string "1.0". If the version is
- // not specified, supporting any version of the feature will
- // cause the method to return true.
- hasFeature(feature, version) {
- return true;
- }
-
- // Creates a new document type declaration.
-
- // `qualifiedName` qualified name of the document type to be created
- // `publicId` public identifier of the external subset
- // `systemId` system identifier of the external subset
- createDocumentType(qualifiedName, publicId, systemId) {
- throw new Error("This DOM method is not implemented.");
- }
-
- // Creates a new document.
-
- // `namespaceURI` namespace URI of the document element to create
- // `qualifiedName` the qualified name of the document to be created
- // `doctype` the type of document to be created or null
- createDocument(namespaceURI, qualifiedName, doctype) {
- throw new Error("This DOM method is not implemented.");
- }
-
- // Creates a new HTML document.
-
- // `title` document title
- createHTMLDocument(title) {
- throw new Error("This DOM method is not implemented.");
- }
-
- // Returns a specialized object which implements the specialized APIs
- // of the specified feature and version.
-
- // `feature` name of the feature requested.
- // `version` version number of the feature to test
- getFeature(feature, version) {
- throw new Error("This DOM method is not implemented.");
- }
-
- };
-
- }).call(this);
-
- },{}],15:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Represents a list of string entries
- var XMLDOMStringList;
-
- module.exports = XMLDOMStringList = (function() {
- class XMLDOMStringList {
- // Initializes a new instance of `XMLDOMStringList`
- // This is just a wrapper around an ordinary
- // JS array.
-
- // `arr` the array of string values
- constructor(arr) {
- this.arr = arr || [];
- }
-
- // Returns the indexth item in the collection.
-
- // `index` index into the collection
- item(index) {
- return this.arr[index] || null;
- }
-
- // Test if a string is part of this DOMStringList.
-
- // `str` the string to look for
- contains(str) {
- return this.arr.indexOf(str) !== -1;
- }
-
- };
-
- // Returns the number of strings in the list.
- Object.defineProperty(XMLDOMStringList.prototype, 'length', {
- get: function() {
- return this.arr.length;
- }
- });
-
- return XMLDOMStringList;
-
- }).call(this);
-
- }).call(this);
-
- },{}],16:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDTDAttList, XMLNode;
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents an attribute list
- module.exports = XMLDTDAttList = class XMLDTDAttList extends XMLNode {
- // Initializes a new instance of `XMLDTDAttList`
-
- // `parent` the parent `XMLDocType` element
- // `elementName` the name of the element containing this attribute
- // `attributeName` attribute name
- // `attributeType` type of the attribute
- // `defaultValueType` default value type (either #REQUIRED, #IMPLIED,
- // #FIXED or #DEFAULT)
- // `defaultValue` default value of the attribute
- // (only used for #FIXED or #DEFAULT)
- constructor(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- super(parent);
- if (elementName == null) {
- throw new Error("Missing DTD element name. " + this.debugInfo());
- }
- if (attributeName == null) {
- throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
- }
- if (!attributeType) {
- throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
- }
- if (!defaultValueType) {
- throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
- }
- if (defaultValueType.indexOf('#') !== 0) {
- defaultValueType = '#' + defaultValueType;
- }
- if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
- throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
- }
- if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
- throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
- }
- this.elementName = this.stringify.name(elementName);
- this.type = NodeType.AttributeDeclaration;
- this.attributeName = this.stringify.name(attributeName);
- this.attributeType = this.stringify.dtdAttType(attributeType);
- if (defaultValue) {
- this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
- }
- this.defaultValueType = defaultValueType;
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],17:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDTDElement, XMLNode;
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents an attribute
- module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode {
- // Initializes a new instance of `XMLDTDElement`
-
- // `parent` the parent `XMLDocType` element
- // `name` element name
- // `value` element content (defaults to #PCDATA)
- constructor(parent, name, value) {
- super(parent);
- if (name == null) {
- throw new Error("Missing DTD element name. " + this.debugInfo());
- }
- if (!value) {
- value = '(#PCDATA)';
- }
- if (Array.isArray(value)) {
- value = '(' + value.join(',') + ')';
- }
- this.name = this.stringify.name(name);
- this.type = NodeType.ElementDeclaration;
- this.value = this.stringify.dtdElementValue(value);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],18:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDTDEntity, XMLNode, isObject;
-
- ({isObject} = require('./Utility'));
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents an entity declaration in the DTD
- module.exports = XMLDTDEntity = (function() {
- class XMLDTDEntity extends XMLNode {
- // Initializes a new instance of `XMLDTDEntity`
-
- // `parent` the parent `XMLDocType` element
- // `pe` whether this is a parameter entity or a general entity
- // defaults to `false` (general entity)
- // `name` the name of the entity
- // `value` internal entity value or an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- // `value.nData` notation declaration
- constructor(parent, pe, name, value) {
- super(parent);
- if (name == null) {
- throw new Error("Missing DTD entity name. " + this.debugInfo(name));
- }
- if (value == null) {
- throw new Error("Missing DTD entity value. " + this.debugInfo(name));
- }
- this.pe = !!pe;
- this.name = this.stringify.name(name);
- this.type = NodeType.EntityDeclaration;
- if (!isObject(value)) {
- this.value = this.stringify.dtdEntityValue(value);
- this.internal = true;
- } else {
- if (!value.pubID && !value.sysID) {
- throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
- }
- if (value.pubID && !value.sysID) {
- throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
- }
- this.internal = false;
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- if (value.nData != null) {
- this.nData = this.stringify.dtdNData(value.nData);
- }
- if (this.pe && this.nData) {
- throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
- }
- }
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
- get: function() {
- return this.pubID;
- }
- });
-
- Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
- get: function() {
- return this.sysID;
- }
- });
-
- Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
- get: function() {
- return this.nData || null;
- }
- });
-
- // DOM level 3
- Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
- get: function() {
- return null;
- }
- });
-
- return XMLDTDEntity;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./XMLNode":27}],19:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDTDNotation, XMLNode;
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents a NOTATION entry in the DTD
- module.exports = XMLDTDNotation = (function() {
- class XMLDTDNotation extends XMLNode {
- // Initializes a new instance of `XMLDTDNotation`
-
- // `parent` the parent `XMLDocType` element
- // `name` the name of the notation
- // `value` an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- constructor(parent, name, value) {
- super(parent);
- if (name == null) {
- throw new Error("Missing DTD notation name. " + this.debugInfo(name));
- }
- if (!value.pubID && !value.sysID) {
- throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
- }
- this.name = this.stringify.name(name);
- this.type = NodeType.NotationDeclaration;
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
- get: function() {
- return this.pubID;
- }
- });
-
- Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
- get: function() {
- return this.sysID;
- }
- });
-
- return XMLDTDNotation;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],20:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDeclaration, XMLNode, isObject;
-
- ({isObject} = require('./Utility'));
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents the XML declaration
- module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode {
- // Initializes a new instance of `XMLDeclaration`
-
- // `parent` the document object
-
- // `version` A version number string, e.g. 1.0
- // `encoding` Encoding declaration, e.g. UTF-8
- // `standalone` standalone document declaration: true or false
- constructor(parent, version, encoding, standalone) {
- super(parent);
- // arguments may also be passed as an object
- if (isObject(version)) {
- ({version, encoding, standalone} = version);
- }
- if (!version) {
- version = '1.0';
- }
- this.type = NodeType.Declaration;
- this.version = this.stringify.xmlVersion(version);
- if (encoding != null) {
- this.encoding = this.stringify.xmlEncoding(encoding);
- }
- if (standalone != null) {
- this.standalone = this.stringify.xmlStandalone(standalone);
- }
- }
-
- // Converts to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./XMLNode":27}],21:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject;
-
- ({isObject} = require('./Utility'));
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLNamedNodeMap = require('./XMLNamedNodeMap');
-
- // Represents doctype declaration
- module.exports = XMLDocType = (function() {
- class XMLDocType extends XMLNode {
- // Initializes a new instance of `XMLDocType`
-
- // `parent` the document object
-
- // `pubID` public identifier of the external subset
- // `sysID` system identifier of the external subset
- constructor(parent, pubID, sysID) {
- var child, i, len, ref;
- super(parent);
- this.type = NodeType.DocType;
- // set DTD name to the name of the root node
- if (parent.children) {
- ref = parent.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- if (child.type === NodeType.Element) {
- this.name = child.name;
- break;
- }
- }
- }
- this.documentObject = parent;
- // arguments may also be passed as an object
- if (isObject(pubID)) {
- ({pubID, sysID} = pubID);
- }
- if (sysID == null) {
- [sysID, pubID] = [pubID, sysID];
- }
- if (pubID != null) {
- this.pubID = this.stringify.dtdPubID(pubID);
- }
- if (sysID != null) {
- this.sysID = this.stringify.dtdSysID(sysID);
- }
- }
-
- // Creates an element type declaration
-
- // `name` element name
- // `value` element content (defaults to #PCDATA)
- element(name, value) {
- var child;
- child = new XMLDTDElement(this, name, value);
- this.children.push(child);
- return this;
- }
-
- // Creates an attribute declaration
-
- // `elementName` the name of the element containing this attribute
- // `attributeName` attribute name
- // `attributeType` type of the attribute (defaults to CDATA)
- // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
- // #DEFAULT) (defaults to #IMPLIED)
- // `defaultValue` default value of the attribute
- // (only used for #FIXED or #DEFAULT)
- attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var child;
- child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.children.push(child);
- return this;
- }
-
- // Creates a general entity declaration
-
- // `name` the name of the entity
- // `value` internal entity value or an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- // `value.nData` notation declaration
- entity(name, value) {
- var child;
- child = new XMLDTDEntity(this, false, name, value);
- this.children.push(child);
- return this;
- }
-
- // Creates a parameter entity declaration
-
- // `name` the name of the entity
- // `value` internal entity value or an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- pEntity(name, value) {
- var child;
- child = new XMLDTDEntity(this, true, name, value);
- this.children.push(child);
- return this;
- }
-
- // Creates a NOTATION declaration
-
- // `name` the name of the notation
- // `value` an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- notation(name, value) {
- var child;
- child = new XMLDTDNotation(this, name, value);
- this.children.push(child);
- return this;
- }
-
- // Converts to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.docType(this, this.options.writer.filterOptions(options));
- }
-
- // Aliases
- ele(name, value) {
- return this.element(name, value);
- }
-
- att(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
- }
-
- ent(name, value) {
- return this.entity(name, value);
- }
-
- pent(name, value) {
- return this.pEntity(name, value);
- }
-
- not(name, value) {
- return this.notation(name, value);
- }
-
- up() {
- return this.root() || this.documentObject;
- }
-
- isEqualNode(node) {
- if (!super.isEqualNode(node)) {
- return false;
- }
- if (node.name !== this.name) {
- return false;
- }
- if (node.publicId !== this.publicId) {
- return false;
- }
- if (node.systemId !== this.systemId) {
- return false;
- }
- return true;
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLDocType.prototype, 'entities', {
- get: function() {
- var child, i, len, nodes, ref;
- nodes = {};
- ref = this.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
- nodes[child.name] = child;
- }
- }
- return new XMLNamedNodeMap(nodes);
- }
- });
-
- Object.defineProperty(XMLDocType.prototype, 'notations', {
- get: function() {
- var child, i, len, nodes, ref;
- nodes = {};
- ref = this.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- if (child.type === NodeType.NotationDeclaration) {
- nodes[child.name] = child;
- }
- }
- return new XMLNamedNodeMap(nodes);
- }
- });
-
- // DOM level 2
- Object.defineProperty(XMLDocType.prototype, 'publicId', {
- get: function() {
- return this.pubID;
- }
- });
-
- Object.defineProperty(XMLDocType.prototype, 'systemId', {
- get: function() {
- return this.sysID;
- }
- });
-
- Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
- get: function() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- return XMLDocType;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./XMLDTDAttList":16,"./XMLDTDElement":17,"./XMLDTDEntity":18,"./XMLDTDNotation":19,"./XMLNamedNodeMap":26,"./XMLNode":27}],22:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject;
-
- ({isPlainObject} = require('./Utility'));
-
- XMLDOMImplementation = require('./XMLDOMImplementation');
-
- XMLDOMConfiguration = require('./XMLDOMConfiguration');
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- // Represents an XML builder
- module.exports = XMLDocument = (function() {
- class XMLDocument extends XMLNode {
- // Initializes a new instance of `XMLDocument`
-
- // `options.keepNullNodes` whether nodes with null values will be kept
- // or ignored: true or false
- // `options.keepNullAttributes` whether attributes with null values will be
- // kept or ignored: true or false
- // `options.ignoreDecorators` whether decorator strings will be ignored when
- // converting JS objects: true or false
- // `options.separateArrayItems` whether array items are created as separate
- // nodes when passed as an object value: true or false
- // `options.noDoubleEncoding` whether existing html entities are encoded:
- // true or false
- // `options.stringify` a set of functions to use for converting values to
- // strings
- // `options.writer` the default XML writer to use for converting nodes to
- // string. If the default writer is not set, the built-in XMLStringWriter
- // will be used instead.
- constructor(options) {
- super(null);
- this.name = "#document";
- this.type = NodeType.Document;
- this.documentURI = null;
- this.domConfig = new XMLDOMConfiguration();
- options || (options = {});
- if (!options.writer) {
- options.writer = new XMLStringWriter();
- }
- this.options = options;
- this.stringify = new XMLStringifier(options);
- }
-
- // Ends the document and passes it to the given XML writer
-
- // `writer` is either an XML writer or a plain object to pass to the
- // constructor of the default XML writer. The default writer is assigned when
- // creating the XML document. Following flags are recognized by the
- // built-in XMLStringWriter:
- // `writer.pretty` pretty prints the result
- // `writer.indent` indentation for pretty print
- // `writer.offset` how many indentations to add to every line for pretty print
- // `writer.newline` newline sequence for pretty print
- end(writer) {
- var writerOptions;
- writerOptions = {};
- if (!writer) {
- writer = this.options.writer;
- } else if (isPlainObject(writer)) {
- writerOptions = writer;
- writer = this.options.writer;
- }
- return writer.document(this, writer.filterOptions(writerOptions));
- }
-
- // Converts the XML document to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.document(this, this.options.writer.filterOptions(options));
- }
-
- // DOM level 1 functions to be implemented later
- createElement(tagName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createDocumentFragment() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createTextNode(data) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createComment(data) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createCDATASection(data) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createProcessingInstruction(target, data) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createAttribute(name) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createEntityReference(name) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByTagName(tagname) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM level 2 functions to be implemented later
- importNode(importedNode, deep) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createElementNS(namespaceURI, qualifiedName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createAttributeNS(namespaceURI, qualifiedName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByTagNameNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementById(elementId) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM level 3 functions to be implemented later
- adoptNode(source) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- normalizeDocument() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- renameNode(node, namespaceURI, qualifiedName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM level 4 functions to be implemented later
- getElementsByClassName(classNames) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createEvent(eventInterface) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createRange() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createNodeIterator(root, whatToShow, filter) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- createTreeWalker(root, whatToShow, filter) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLDocument.prototype, 'implementation', {
- value: new XMLDOMImplementation()
- });
-
- Object.defineProperty(XMLDocument.prototype, 'doctype', {
- get: function() {
- var child, i, len, ref;
- ref = this.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- if (child.type === NodeType.DocType) {
- return child;
- }
- }
- return null;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'documentElement', {
- get: function() {
- return this.rootObject || null;
- }
- });
-
- // DOM level 3
- Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
- get: function() {
- return false;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
- get: function() {
- if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
- return this.children[0].encoding;
- } else {
- return null;
- }
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
- get: function() {
- if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
- return this.children[0].standalone === 'yes';
- } else {
- return false;
- }
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
- get: function() {
- if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
- return this.children[0].version;
- } else {
- return "1.0";
- }
- }
- });
-
- // DOM level 4
- Object.defineProperty(XMLDocument.prototype, 'URL', {
- get: function() {
- return this.documentURI;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'origin', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'compatMode', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'characterSet', {
- get: function() {
- return null;
- }
- });
-
- Object.defineProperty(XMLDocument.prototype, 'contentType', {
- get: function() {
- return null;
- }
- });
-
- return XMLDocument;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./XMLDOMConfiguration":12,"./XMLDOMImplementation":14,"./XMLNode":27,"./XMLStringWriter":32,"./XMLStringifier":33}],23:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject,
- hasProp = {}.hasOwnProperty;
-
- ({isObject, isFunction, isPlainObject, getValue} = require('./Utility'));
-
- NodeType = require('./NodeType');
-
- XMLDocument = require('./XMLDocument');
-
- XMLElement = require('./XMLElement');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLAttribute = require('./XMLAttribute');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- WriterState = require('./WriterState');
-
- // Represents an XML builder
- module.exports = XMLDocumentCB = class XMLDocumentCB {
- // Initializes a new instance of `XMLDocumentCB`
-
- // `options.keepNullNodes` whether nodes with null values will be kept
- // or ignored: true or false
- // `options.keepNullAttributes` whether attributes with null values will be
- // kept or ignored: true or false
- // `options.ignoreDecorators` whether decorator strings will be ignored when
- // converting JS objects: true or false
- // `options.separateArrayItems` whether array items are created as separate
- // nodes when passed as an object value: true or false
- // `options.noDoubleEncoding` whether existing html entities are encoded:
- // true or false
- // `options.stringify` a set of functions to use for converting values to
- // strings
- // `options.writer` the default XML writer to use for converting nodes to
- // string. If the default writer is not set, the built-in XMLStringWriter
- // will be used instead.
-
- // `onData` the function to be called when a new chunk of XML is output. The
- // string containing the XML chunk is passed to `onData` as its first
- // argument, and the current indentation level as its second argument.
- // `onEnd` the function to be called when the XML document is completed with
- // `end`. `onEnd` does not receive any arguments.
- constructor(options, onData, onEnd) {
- var writerOptions;
- this.name = "?xml";
- this.type = NodeType.Document;
- options || (options = {});
- writerOptions = {};
- if (!options.writer) {
- options.writer = new XMLStringWriter();
- } else if (isPlainObject(options.writer)) {
- writerOptions = options.writer;
- options.writer = new XMLStringWriter();
- }
- this.options = options;
- this.writer = options.writer;
- this.writerOptions = this.writer.filterOptions(writerOptions);
- this.stringify = new XMLStringifier(options);
- this.onDataCallback = onData || function() {};
- this.onEndCallback = onEnd || function() {};
- this.currentNode = null;
- this.currentLevel = -1;
- this.openTags = {};
- this.documentStarted = false;
- this.documentCompleted = false;
- this.root = null;
- }
-
- // Creates a child element node from the given XMLNode
-
- // `node` the child node
- createChildNode(node) {
- var att, attName, attributes, child, i, len, ref, ref1;
- switch (node.type) {
- case NodeType.CData:
- this.cdata(node.value);
- break;
- case NodeType.Comment:
- this.comment(node.value);
- break;
- case NodeType.Element:
- attributes = {};
- ref = node.attribs;
- for (attName in ref) {
- if (!hasProp.call(ref, attName)) continue;
- att = ref[attName];
- attributes[attName] = att.value;
- }
- this.node(node.name, attributes);
- break;
- case NodeType.Dummy:
- this.dummy();
- break;
- case NodeType.Raw:
- this.raw(node.value);
- break;
- case NodeType.Text:
- this.text(node.value);
- break;
- case NodeType.ProcessingInstruction:
- this.instruction(node.target, node.value);
- break;
- default:
- throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
- }
- ref1 = node.children;
- // write child nodes recursively
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- this.createChildNode(child);
- if (child.type === NodeType.Element) {
- this.up();
- }
- }
- return this;
- }
-
- // Creates a dummy node
-
- dummy() {
- // no-op, just return this
- return this;
- }
-
- // Creates a node
-
- // `name` name of the node
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- node(name, attributes, text) {
- if (name == null) {
- throw new Error("Missing node name.");
- }
- if (this.root && this.currentLevel === -1) {
- throw new Error("Document can only have one root node. " + this.debugInfo(name));
- }
- this.openCurrent();
- name = getValue(name);
- if (attributes == null) {
- attributes = {};
- }
- attributes = getValue(attributes);
- // swap argument order: text <-> attributes
- if (!isObject(attributes)) {
- [text, attributes] = [attributes, text];
- }
- this.currentNode = new XMLElement(this, name, attributes);
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- if (text != null) {
- this.text(text);
- }
- return this;
- }
-
- // Creates a child element node or an element type declaration when called
- // inside the DTD
-
- // `name` name of the node
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- element(name, attributes, text) {
- var child, i, len, oldValidationFlag, ref, root;
- if (this.currentNode && this.currentNode.type === NodeType.DocType) {
- this.dtdElement(...arguments);
- } else {
- if (Array.isArray(name) || isObject(name) || isFunction(name)) {
- oldValidationFlag = this.options.noValidation;
- this.options.noValidation = true;
- root = new XMLDocument(this.options).element('TEMP_ROOT');
- root.element(name);
- this.options.noValidation = oldValidationFlag;
- ref = root.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- this.createChildNode(child);
- if (child.type === NodeType.Element) {
- this.up();
- }
- }
- } else {
- this.node(name, attributes, text);
- }
- }
- return this;
- }
-
- // Adds or modifies an attribute
-
- // `name` attribute name
- // `value` attribute value
- attribute(name, value) {
- var attName, attValue;
- if (!this.currentNode || this.currentNode.children) {
- throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
- }
- if (name != null) {
- name = getValue(name);
- }
- if (isObject(name)) { // expand if object
- for (attName in name) {
- if (!hasProp.call(name, attName)) continue;
- attValue = name[attName];
- this.attribute(attName, attValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- if (this.options.keepNullAttributes && (value == null)) {
- this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
- } else if (value != null) {
- this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
- }
- }
- return this;
- }
-
- // Creates a text node
-
- // `value` element text
- text(value) {
- var node;
- this.openCurrent();
- node = new XMLText(this, value);
- this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates a CDATA node
-
- // `value` element text without CDATA delimiters
- cdata(value) {
- var node;
- this.openCurrent();
- node = new XMLCData(this, value);
- this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates a comment node
-
- // `value` comment text
- comment(value) {
- var node;
- this.openCurrent();
- node = new XMLComment(this, value);
- this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Adds unescaped raw text
-
- // `value` text
- raw(value) {
- var node;
- this.openCurrent();
- node = new XMLRaw(this, value);
- this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Adds a processing instruction
-
- // `target` instruction target
- // `value` instruction value
- instruction(target, value) {
- var i, insTarget, insValue, len, node;
- this.openCurrent();
- if (target != null) {
- target = getValue(target);
- }
- if (value != null) {
- value = getValue(value);
- }
- if (Array.isArray(target)) { // expand if array
- for (i = 0, len = target.length; i < len; i++) {
- insTarget = target[i];
- this.instruction(insTarget);
- }
- } else if (isObject(target)) { // expand if object
- for (insTarget in target) {
- if (!hasProp.call(target, insTarget)) continue;
- insValue = target[insTarget];
- this.instruction(insTarget, insValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- node = new XMLProcessingInstruction(this, target, value);
- this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- }
- return this;
- }
-
- // Creates the xml declaration
-
- // `version` A version number string, e.g. 1.0
- // `encoding` Encoding declaration, e.g. UTF-8
- // `standalone` standalone document declaration: true or false
- declaration(version, encoding, standalone) {
- var node;
- this.openCurrent();
- if (this.documentStarted) {
- throw new Error("declaration() must be the first node.");
- }
- node = new XMLDeclaration(this, version, encoding, standalone);
- this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates the document type declaration
-
- // `root` the name of the root node
- // `pubID` the public identifier of the external subset
- // `sysID` the system identifier of the external subset
- doctype(root, pubID, sysID) {
- this.openCurrent();
- if (root == null) {
- throw new Error("Missing root node name.");
- }
- if (this.root) {
- throw new Error("dtd() must come before the root node.");
- }
- this.currentNode = new XMLDocType(this, pubID, sysID);
- this.currentNode.rootNodeName = root;
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- return this;
- }
-
- // Creates an element type declaration
-
- // `name` element name
- // `value` element content (defaults to #PCDATA)
- dtdElement(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDElement(this, name, value);
- this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates an attribute declaration
-
- // `elementName` the name of the element containing this attribute
- // `attributeName` attribute name
- // `attributeType` type of the attribute (defaults to CDATA)
- // `defaultValueType` default value type (either #REQUIRED, #IMPLIED, #FIXED or
- // #DEFAULT) (defaults to #IMPLIED)
- // `defaultValue` default value of the attribute
- // (only used for #FIXED or #DEFAULT)
- attList(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var node;
- this.openCurrent();
- node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates a general entity declaration
-
- // `name` the name of the entity
- // `value` internal entity value or an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- // `value.nData` notation declaration
- entity(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, false, name, value);
- this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates a parameter entity declaration
-
- // `name` the name of the entity
- // `value` internal entity value or an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- pEntity(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, true, name, value);
- this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Creates a NOTATION declaration
-
- // `name` the name of the notation
- // `value` an object with external entity details
- // `value.pubID` public identifier
- // `value.sysID` system identifier
- notation(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDNotation(this, name, value);
- this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
- return this;
- }
-
- // Gets the parent node
- up() {
- if (this.currentLevel < 0) {
- throw new Error("The document node has no parent.");
- }
- if (this.currentNode) {
- if (this.currentNode.children) {
- this.closeNode(this.currentNode);
- } else {
- this.openNode(this.currentNode);
- }
- this.currentNode = null;
- } else {
- this.closeNode(this.openTags[this.currentLevel]);
- }
- delete this.openTags[this.currentLevel];
- this.currentLevel--;
- return this;
- }
-
- // Ends the document
- end() {
- while (this.currentLevel >= 0) {
- this.up();
- }
- return this.onEnd();
- }
-
- // Opens the current parent node
- openCurrent() {
- if (this.currentNode) {
- this.currentNode.children = true;
- return this.openNode(this.currentNode);
- }
- }
-
- // Writes the opening tag of the current node or the entire node if it has
- // no child nodes
- openNode(node) {
- var att, chunk, name, ref;
- if (!node.isOpen) {
- if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
- this.root = node;
- }
- chunk = '';
- if (node.type === NodeType.Element) {
- this.writerOptions.state = WriterState.OpenTag;
- chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
- ref = node.attribs;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
- }
- chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
- this.writerOptions.state = WriterState.InsideTag; // if node.type is NodeType.DocType
- } else {
- this.writerOptions.state = WriterState.OpenTag;
- chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
-
- // external identifier
- if (node.pubID && node.sysID) {
- chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- chunk += ' SYSTEM "' + node.sysID + '"';
- }
-
- // internal subset
- if (node.children) {
- chunk += ' [';
- this.writerOptions.state = WriterState.InsideTag;
- } else {
- this.writerOptions.state = WriterState.CloseTag;
- chunk += '>';
- }
- chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
- }
- this.onData(chunk, this.currentLevel);
- return node.isOpen = true;
- }
- }
-
- // Writes the closing tag of the current node
- closeNode(node) {
- var chunk;
- if (!node.isClosed) {
- chunk = '';
- this.writerOptions.state = WriterState.CloseTag;
- if (node.type === NodeType.Element) {
- 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
- } else {
- chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
- }
- this.writerOptions.state = WriterState.None;
- this.onData(chunk, this.currentLevel);
- return node.isClosed = true;
- }
- }
-
- // Called when a new chunk of XML is output
-
- // `chunk` a string containing the XML chunk
- // `level` current indentation level
- onData(chunk, level) {
- this.documentStarted = true;
- return this.onDataCallback(chunk, level + 1);
- }
-
- // Called when the XML document is completed
- onEnd() {
- this.documentCompleted = true;
- return this.onEndCallback();
- }
-
- // Returns debug string
- debugInfo(name) {
- if (name == null) {
- return "";
- } else {
- return "node: <" + name + ">";
- }
- }
-
- // Node aliases
- ele() {
- return this.element(...arguments);
- }
-
- nod(name, attributes, text) {
- return this.node(name, attributes, text);
- }
-
- txt(value) {
- return this.text(value);
- }
-
- dat(value) {
- return this.cdata(value);
- }
-
- com(value) {
- return this.comment(value);
- }
-
- ins(target, value) {
- return this.instruction(target, value);
- }
-
- dec(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- }
-
- dtd(root, pubID, sysID) {
- return this.doctype(root, pubID, sysID);
- }
-
- e(name, attributes, text) {
- return this.element(name, attributes, text);
- }
-
- n(name, attributes, text) {
- return this.node(name, attributes, text);
- }
-
- t(value) {
- return this.text(value);
- }
-
- d(value) {
- return this.cdata(value);
- }
-
- c(value) {
- return this.comment(value);
- }
-
- r(value) {
- return this.raw(value);
- }
-
- i(target, value) {
- return this.instruction(target, value);
- }
-
- // Attribute aliases
- att() {
- if (this.currentNode && this.currentNode.type === NodeType.DocType) {
- return this.attList(...arguments);
- } else {
- return this.attribute(...arguments);
- }
- }
-
- a() {
- if (this.currentNode && this.currentNode.type === NodeType.DocType) {
- return this.attList(...arguments);
- } else {
- return this.attribute(...arguments);
- }
- }
-
- // DTD aliases
- // att() and ele() are defined above
- ent(name, value) {
- return this.entity(name, value);
- }
-
- pent(name, value) {
- return this.pEntity(name, value);
- }
-
- not(name, value) {
- return this.notation(name, value);
- }
-
- };
-
- }).call(this);
-
- },{"./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){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLDummy, XMLNode;
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- // Represents a raw node
- module.exports = XMLDummy = class XMLDummy extends XMLNode {
- // Initializes a new instance of `XMLDummy`
-
- // `XMLDummy` is a special node representing a node with
- // a null value. Dummy nodes are created while recursively
- // building the XML tree. Simply skipping null values doesn't
- // work because that would break the recursive chain.
- constructor(parent) {
- super(parent);
- this.type = NodeType.Dummy;
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return '';
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],25:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject,
- hasProp = {}.hasOwnProperty;
-
- ({isObject, isFunction, getValue} = require('./Utility'));
-
- XMLNode = require('./XMLNode');
-
- NodeType = require('./NodeType');
-
- XMLAttribute = require('./XMLAttribute');
-
- XMLNamedNodeMap = require('./XMLNamedNodeMap');
-
- // Represents an element of the XML document
- module.exports = XMLElement = (function() {
- class XMLElement extends XMLNode {
- // Initializes a new instance of `XMLElement`
-
- // `parent` the parent node
- // `name` element name
- // `attributes` an object containing name/value pairs of attributes
- constructor(parent, name, attributes) {
- var child, j, len, ref;
- super(parent);
- if (name == null) {
- throw new Error("Missing element name. " + this.debugInfo());
- }
- this.name = this.stringify.name(name);
- this.type = NodeType.Element;
- this.attribs = {};
- this.schemaTypeInfo = null;
- if (attributes != null) {
- this.attribute(attributes);
- }
- // set properties if this is the root node
- if (parent.type === NodeType.Document) {
- this.isRoot = true;
- this.documentObject = parent;
- parent.rootObject = this;
- // set dtd name
- if (parent.children) {
- ref = parent.children;
- for (j = 0, len = ref.length; j < len; j++) {
- child = ref[j];
- if (child.type === NodeType.DocType) {
- child.name = this.name;
- break;
- }
- }
- }
- }
- }
-
- // Creates and returns a deep clone of `this`
-
- clone() {
- var att, attName, clonedSelf, ref;
- clonedSelf = Object.create(this);
- // remove document element
- if (clonedSelf.isRoot) {
- clonedSelf.documentObject = null;
- }
- // clone attributes
- clonedSelf.attribs = {};
- ref = this.attribs;
- for (attName in ref) {
- if (!hasProp.call(ref, attName)) continue;
- att = ref[attName];
- clonedSelf.attribs[attName] = att.clone();
- }
- // clone child nodes
- clonedSelf.children = [];
- this.children.forEach(function(child) {
- var clonedChild;
- clonedChild = child.clone();
- clonedChild.parent = clonedSelf;
- return clonedSelf.children.push(clonedChild);
- });
- return clonedSelf;
- }
-
- // Adds or modifies an attribute
-
- // `name` attribute name
- // `value` attribute value
- attribute(name, value) {
- var attName, attValue;
- if (name != null) {
- name = getValue(name);
- }
- if (isObject(name)) { // expand if object
- for (attName in name) {
- if (!hasProp.call(name, attName)) continue;
- attValue = name[attName];
- this.attribute(attName, attValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- if (this.options.keepNullAttributes && (value == null)) {
- this.attribs[name] = new XMLAttribute(this, name, "");
- } else if (value != null) {
- this.attribs[name] = new XMLAttribute(this, name, value);
- }
- }
- return this;
- }
-
- // Removes an attribute
-
- // `name` attribute name
- removeAttribute(name) {
- var attName, j, len;
- // Also defined in DOM level 1
- // removeAttribute(name) removes an attribute by name.
- if (name == null) {
- throw new Error("Missing attribute name. " + this.debugInfo());
- }
- name = getValue(name);
- if (Array.isArray(name)) { // expand if array
- for (j = 0, len = name.length; j < len; j++) {
- attName = name[j];
- delete this.attribs[attName];
- }
- } else {
- delete this.attribs[name];
- }
- return this;
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- // `options.allowEmpty` do not self close empty element tags
- toString(options) {
- return this.options.writer.element(this, this.options.writer.filterOptions(options));
- }
-
- // Aliases
- att(name, value) {
- return this.attribute(name, value);
- }
-
- a(name, value) {
- return this.attribute(name, value);
- }
-
- // DOM Level 1
- getAttribute(name) {
- if (this.attribs.hasOwnProperty(name)) {
- return this.attribs[name].value;
- } else {
- return null;
- }
- }
-
- setAttribute(name, value) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getAttributeNode(name) {
- if (this.attribs.hasOwnProperty(name)) {
- return this.attribs[name];
- } else {
- return null;
- }
- }
-
- setAttributeNode(newAttr) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- removeAttributeNode(oldAttr) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByTagName(name) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM Level 2
- getAttributeNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- setAttributeNS(namespaceURI, qualifiedName, value) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- removeAttributeNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getAttributeNodeNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- setAttributeNodeNS(newAttr) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByTagNameNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- hasAttribute(name) {
- return this.attribs.hasOwnProperty(name);
- }
-
- hasAttributeNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM Level 3
- setIdAttribute(name, isId) {
- if (this.attribs.hasOwnProperty(name)) {
- return this.attribs[name].isId;
- } else {
- return isId;
- }
- }
-
- setIdAttributeNS(namespaceURI, localName, isId) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- setIdAttributeNode(idAttr, isId) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM Level 4
- getElementsByTagName(tagname) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByTagNameNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getElementsByClassName(classNames) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- isEqualNode(node) {
- var i, j, ref;
- if (!super.isEqualNode(node)) {
- return false;
- }
- if (node.namespaceURI !== this.namespaceURI) {
- return false;
- }
- if (node.prefix !== this.prefix) {
- return false;
- }
- if (node.localName !== this.localName) {
- return false;
- }
- if (node.attribs.length !== this.attribs.length) {
- return false;
- }
- for (i = j = 0, ref = this.attribs.length - 1; (0 <= ref ? j <= ref : j >= ref); i = 0 <= ref ? ++j : --j) {
- if (!this.attribs[i].isEqualNode(node.attribs[i])) {
- return false;
- }
- }
- return true;
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLElement.prototype, 'tagName', {
- get: function() {
- return this.name;
- }
- });
-
- // DOM level 4
- Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
- get: function() {
- return '';
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'prefix', {
- get: function() {
- return '';
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'localName', {
- get: function() {
- return this.name;
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'id', {
- get: function() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'className', {
- get: function() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'classList', {
- get: function() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- Object.defineProperty(XMLElement.prototype, 'attributes', {
- get: function() {
- if (!this.attributeMap || !this.attributeMap.nodes) {
- this.attributeMap = new XMLNamedNodeMap(this.attribs);
- }
- return this.attributeMap;
- }
- });
-
- return XMLElement;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./XMLAttribute":8,"./XMLNamedNodeMap":26,"./XMLNode":27}],26:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Represents a map of nodes accessed by a string key
- var XMLNamedNodeMap;
-
- module.exports = XMLNamedNodeMap = (function() {
- class XMLNamedNodeMap {
- // Initializes a new instance of `XMLNamedNodeMap`
- // This is just a wrapper around an ordinary
- // JS object.
-
- // `nodes` the object containing nodes.
- constructor(nodes) {
- this.nodes = nodes;
- }
-
- // Creates and returns a deep clone of `this`
-
- clone() {
- // this class should not be cloned since it wraps
- // around a given object. The calling function should check
- // whether the wrapped object is null and supply a new object
- // (from the clone).
- return this.nodes = null;
- }
-
- // DOM Level 1
- getNamedItem(name) {
- return this.nodes[name];
- }
-
- setNamedItem(node) {
- var oldNode;
- oldNode = this.nodes[node.nodeName];
- this.nodes[node.nodeName] = node;
- return oldNode || null;
- }
-
- removeNamedItem(name) {
- var oldNode;
- oldNode = this.nodes[name];
- delete this.nodes[name];
- return oldNode || null;
- }
-
- item(index) {
- return this.nodes[Object.keys(this.nodes)[index]] || null;
- }
-
- // DOM level 2 functions to be implemented later
- getNamedItemNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented.");
- }
-
- setNamedItemNS(node) {
- throw new Error("This DOM method is not implemented.");
- }
-
- removeNamedItemNS(namespaceURI, localName) {
- throw new Error("This DOM method is not implemented.");
- }
-
- };
-
-
- // DOM level 1
- Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
- get: function() {
- return Object.keys(this.nodes).length || 0;
- }
- });
-
- return XMLNamedNodeMap;
-
- }).call(this);
-
- }).call(this);
-
- },{}],27:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject,
- hasProp = {}.hasOwnProperty,
- splice = [].splice;
-
- ({isObject, isFunction, isEmpty, getValue} = require('./Utility'));
-
- XMLElement = null;
-
- XMLCData = null;
-
- XMLComment = null;
-
- XMLDeclaration = null;
-
- XMLDocType = null;
-
- XMLRaw = null;
-
- XMLText = null;
-
- XMLProcessingInstruction = null;
-
- XMLDummy = null;
-
- NodeType = null;
-
- XMLNodeList = null;
-
- XMLNamedNodeMap = null;
-
- DocumentPosition = null;
-
- // Represents a generic XMl element
- module.exports = XMLNode = (function() {
- class XMLNode {
- // Initializes a new instance of `XMLNode`
-
- // `parent` the parent node
- constructor(parent1) {
- this.parent = parent1;
- if (this.parent) {
- this.options = this.parent.options;
- this.stringify = this.parent.stringify;
- }
- this.value = null;
- this.children = [];
- this.baseURI = null;
- // first execution, load dependencies that are otherwise
- // circular (so we can't load them at the top)
- if (!XMLElement) {
- XMLElement = require('./XMLElement');
- XMLCData = require('./XMLCData');
- XMLComment = require('./XMLComment');
- XMLDeclaration = require('./XMLDeclaration');
- XMLDocType = require('./XMLDocType');
- XMLRaw = require('./XMLRaw');
- XMLText = require('./XMLText');
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
- XMLDummy = require('./XMLDummy');
- NodeType = require('./NodeType');
- XMLNodeList = require('./XMLNodeList');
- XMLNamedNodeMap = require('./XMLNamedNodeMap');
- DocumentPosition = require('./DocumentPosition');
- }
- }
-
-
- // Sets the parent node of this node and its children recursively
-
- // `parent` the parent node
- setParent(parent) {
- var child, j, len, ref1, results;
- this.parent = parent;
- if (parent) {
- this.options = parent.options;
- this.stringify = parent.stringify;
- }
- ref1 = this.children;
- results = [];
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- results.push(child.setParent(this));
- }
- return results;
- }
-
- // Creates a child element node
-
- // `name` node name or an object describing the XML tree
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- element(name, attributes, text) {
- var childNode, item, j, k, key, lastChild, len, len1, val;
- lastChild = null;
- if (attributes === null && (text == null)) {
- [attributes, text] = [{}, null];
- }
- if (attributes == null) {
- attributes = {};
- }
- attributes = getValue(attributes);
- // swap argument order: text <-> attributes
- if (!isObject(attributes)) {
- [text, attributes] = [attributes, text];
- }
- if (name != null) {
- name = getValue(name);
- }
- // expand if array
- if (Array.isArray(name)) {
- for (j = 0, len = name.length; j < len; j++) {
- item = name[j];
- lastChild = this.element(item);
- }
- // evaluate if function
- } else if (isFunction(name)) {
- lastChild = this.element(name.apply());
- // expand if object
- } else if (isObject(name)) {
- for (key in name) {
- if (!hasProp.call(name, key)) continue;
- val = name[key];
- if (isFunction(val)) {
- // evaluate if function
- val = val.apply();
- }
- // assign attributes
- if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
- lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
- // skip empty arrays
- } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
- lastChild = this.dummy();
- // empty objects produce one node
- } else if (isObject(val) && isEmpty(val)) {
- lastChild = this.element(key);
- // skip null and undefined nodes
- } else if (!this.options.keepNullNodes && (val == null)) {
- lastChild = this.dummy();
-
- // expand list by creating child nodes
- } else if (!this.options.separateArrayItems && Array.isArray(val)) {
- for (k = 0, len1 = val.length; k < len1; k++) {
- item = val[k];
- childNode = {};
- childNode[key] = item;
- lastChild = this.element(childNode);
- }
-
- // expand child nodes under parent
- } else if (isObject(val)) {
- // if the key is #text expand child nodes under this node to support mixed content
- if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
- lastChild = this.element(val);
- } else {
- lastChild = this.element(key);
- lastChild.element(val);
- }
- } else {
-
- // text node
- lastChild = this.element(key, val);
- }
- }
- // skip null nodes
- } else if (!this.options.keepNullNodes && text === null) {
- lastChild = this.dummy();
- } else {
- // text node
- if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
- lastChild = this.text(text);
- // cdata node
- } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
- lastChild = this.cdata(text);
- // comment node
- } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
- lastChild = this.comment(text);
- // raw text node
- } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
- lastChild = this.raw(text);
- // processing instruction
- } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
- lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
- } else {
- // element node
- lastChild = this.node(name, attributes, text);
- }
- }
- if (lastChild == null) {
- throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
- }
- return lastChild;
- }
-
- // Creates a child element node before the current node
-
- // `name` node name or an object describing the XML tree
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- insertBefore(name, attributes, text) {
- var child, i, newChild, refChild, removed;
- // DOM level 1
- // insertBefore(newChild, refChild) inserts the child node newChild before refChild
- if (name != null ? name.type : void 0) {
- newChild = name;
- refChild = attributes;
- newChild.setParent(this);
- if (refChild) {
- // temporarily remove children starting *with* refChild
- i = children.indexOf(refChild);
- removed = children.splice(i);
-
- // add the new child
- children.push(newChild);
-
- // add back removed children after new child
- Array.prototype.push.apply(children, removed);
- } else {
- children.push(newChild);
- }
- return newChild;
- } else {
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
- }
-
- // temporarily remove children starting *with* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
-
- // add the new child
- child = this.parent.element(name, attributes, text);
-
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- }
- }
-
- // Creates a child element node after the current node
-
- // `name` node name or an object describing the XML tree
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- insertAfter(name, attributes, text) {
- var child, i, removed;
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
- }
-
- // temporarily remove children starting *after* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
-
- // add the new child
- child = this.parent.element(name, attributes, text);
-
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- }
-
- // Deletes a child element node
-
- remove() {
- var i, ref1;
- if (this.isRoot) {
- throw new Error("Cannot remove the root element. " + this.debugInfo());
- }
- i = this.parent.children.indexOf(this);
- splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
- return this.parent;
- }
-
- // Creates a node
-
- // `name` name of the node
- // `attributes` an object containing name/value pairs of attributes
- // `text` element text
- node(name, attributes, text) {
- var child;
- if (name != null) {
- name = getValue(name);
- }
- attributes || (attributes = {});
- attributes = getValue(attributes);
- // swap argument order: text <-> attributes
- if (!isObject(attributes)) {
- [text, attributes] = [attributes, text];
- }
- child = new XMLElement(this, name, attributes);
- if (text != null) {
- child.text(text);
- }
- this.children.push(child);
- return child;
- }
-
- // Creates a text node
-
- // `value` element text
- text(value) {
- var child;
- if (isObject(value)) {
- this.element(value);
- }
- child = new XMLText(this, value);
- this.children.push(child);
- return this;
- }
-
- // Creates a CDATA node
-
- // `value` element text without CDATA delimiters
- cdata(value) {
- var child;
- child = new XMLCData(this, value);
- this.children.push(child);
- return this;
- }
-
- // Creates a comment node
-
- // `value` comment text
- comment(value) {
- var child;
- child = new XMLComment(this, value);
- this.children.push(child);
- return this;
- }
-
- // Creates a comment node before the current node
-
- // `value` comment text
- commentBefore(value) {
- var child, i, removed;
- // temporarily remove children starting *with* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- // add the new child
- child = this.parent.comment(value);
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- }
-
- // Creates a comment node after the current node
-
- // `value` comment text
- commentAfter(value) {
- var child, i, removed;
- // temporarily remove children starting *after* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- // add the new child
- child = this.parent.comment(value);
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- }
-
- // Adds unescaped raw text
-
- // `value` text
- raw(value) {
- var child;
- child = new XMLRaw(this, value);
- this.children.push(child);
- return this;
- }
-
- // Adds a dummy node
- dummy() {
- var child;
- child = new XMLDummy(this);
- // Normally when a new node is created it is added to the child node collection.
- // However, dummy nodes are never added to the XML tree. They are created while
- // converting JS objects to XML nodes in order not to break the recursive function
- // chain. They can be thought of as invisible nodes. They can be traversed through
- // by using prev(), next(), up(), etc. functions but they do not exists in the tree.
-
- // @children.push child
- return child;
- }
-
- // Adds a processing instruction
-
- // `target` instruction target
- // `value` instruction value
- instruction(target, value) {
- var insTarget, insValue, instruction, j, len;
- if (target != null) {
- target = getValue(target);
- }
- if (value != null) {
- value = getValue(value);
- }
- if (Array.isArray(target)) { // expand if array
- for (j = 0, len = target.length; j < len; j++) {
- insTarget = target[j];
- this.instruction(insTarget);
- }
- } else if (isObject(target)) { // expand if object
- for (insTarget in target) {
- if (!hasProp.call(target, insTarget)) continue;
- insValue = target[insTarget];
- this.instruction(insTarget, insValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- instruction = new XMLProcessingInstruction(this, target, value);
- this.children.push(instruction);
- }
- return this;
- }
-
- // Creates a processing instruction node before the current node
-
- // `target` instruction target
- // `value` instruction value
- instructionBefore(target, value) {
- var child, i, removed;
- // temporarily remove children starting *with* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- // add the new child
- child = this.parent.instruction(target, value);
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- }
-
- // Creates a processing instruction node after the current node
-
- // `target` instruction target
- // `value` instruction value
- instructionAfter(target, value) {
- var child, i, removed;
- // temporarily remove children starting *after* this
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- // add the new child
- child = this.parent.instruction(target, value);
- // add back removed children after new child
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- }
-
- // Creates the xml declaration
-
- // `version` A version number string, e.g. 1.0
- // `encoding` Encoding declaration, e.g. UTF-8
- // `standalone` standalone document declaration: true or false
- declaration(version, encoding, standalone) {
- var doc, xmldec;
- doc = this.document();
- xmldec = new XMLDeclaration(doc, version, encoding, standalone);
- // Replace XML declaration if exists, otherwise insert at top
- if (doc.children.length === 0) {
- doc.children.unshift(xmldec);
- } else if (doc.children[0].type === NodeType.Declaration) {
- doc.children[0] = xmldec;
- } else {
- doc.children.unshift(xmldec);
- }
- return doc.root() || doc;
- }
-
- // Creates the document type declaration
-
- // `pubID` the public identifier of the external subset
- // `sysID` the system identifier of the external subset
- dtd(pubID, sysID) {
- var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
- doc = this.document();
- doctype = new XMLDocType(doc, pubID, sysID);
- ref1 = doc.children;
- // Replace DTD if exists
- for (i = j = 0, len = ref1.length; j < len; i = ++j) {
- child = ref1[i];
- if (child.type === NodeType.DocType) {
- doc.children[i] = doctype;
- return doctype;
- }
- }
- ref2 = doc.children;
- // insert before root node if the root node exists
- for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
- child = ref2[i];
- if (child.isRoot) {
- doc.children.splice(i, 0, doctype);
- return doctype;
- }
- }
- // otherwise append to end
- doc.children.push(doctype);
- return doctype;
- }
-
- // Gets the parent node
- up() {
- if (this.isRoot) {
- throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
- }
- return this.parent;
- }
-
- // Gets the root node
- root() {
- var node;
- node = this;
- while (node) {
- if (node.type === NodeType.Document) {
- return node.rootObject;
- } else if (node.isRoot) {
- return node;
- } else {
- node = node.parent;
- }
- }
- }
-
- // Gets the node representing the XML document
- document() {
- var node;
- node = this;
- while (node) {
- if (node.type === NodeType.Document) {
- return node;
- } else {
- node = node.parent;
- }
- }
- }
-
- // Ends the document and converts string
- end(options) {
- return this.document().end(options);
- }
-
- // Gets the previous node
- prev() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i < 1) {
- throw new Error("Already at the first node. " + this.debugInfo());
- }
- return this.parent.children[i - 1];
- }
-
- // Gets the next node
- next() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i === -1 || i === this.parent.children.length - 1) {
- throw new Error("Already at the last node. " + this.debugInfo());
- }
- return this.parent.children[i + 1];
- }
-
- // Imports cloned root from another XML document
-
- // `doc` the XML document to insert nodes from
- importDocument(doc) {
- var child, clonedRoot, j, len, ref1;
- clonedRoot = doc.root().clone();
- clonedRoot.parent = this;
- clonedRoot.isRoot = false;
- this.children.push(clonedRoot);
- // set properties if imported element becomes the root node
- if (this.type === NodeType.Document) {
- clonedRoot.isRoot = true;
- clonedRoot.documentObject = this;
- this.rootObject = clonedRoot;
- // set dtd name
- if (this.children) {
- ref1 = this.children;
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- if (child.type === NodeType.DocType) {
- child.name = clonedRoot.name;
- break;
- }
- }
- }
- }
- return this;
- }
-
-
- // Returns debug string for this node
- debugInfo(name) {
- var ref1, ref2;
- name = name || this.name;
- if ((name == null) && !((ref1 = this.parent) != null ? ref1.name : void 0)) {
- return "";
- } else if (name == null) {
- return "parent: <" + this.parent.name + ">";
- } else if (!((ref2 = this.parent) != null ? ref2.name : void 0)) {
- return "node: <" + name + ">";
- } else {
- return "node: <" + name + ">, parent: <" + this.parent.name + ">";
- }
- }
-
- // Aliases
- ele(name, attributes, text) {
- return this.element(name, attributes, text);
- }
-
- nod(name, attributes, text) {
- return this.node(name, attributes, text);
- }
-
- txt(value) {
- return this.text(value);
- }
-
- dat(value) {
- return this.cdata(value);
- }
-
- com(value) {
- return this.comment(value);
- }
-
- ins(target, value) {
- return this.instruction(target, value);
- }
-
- doc() {
- return this.document();
- }
-
- dec(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- }
-
- e(name, attributes, text) {
- return this.element(name, attributes, text);
- }
-
- n(name, attributes, text) {
- return this.node(name, attributes, text);
- }
-
- t(value) {
- return this.text(value);
- }
-
- d(value) {
- return this.cdata(value);
- }
-
- c(value) {
- return this.comment(value);
- }
-
- r(value) {
- return this.raw(value);
- }
-
- i(target, value) {
- return this.instruction(target, value);
- }
-
- u() {
- return this.up();
- }
-
- // can be deprecated in a future release
- importXMLBuilder(doc) {
- return this.importDocument(doc);
- }
-
- // Adds or modifies an attribute.
-
- // `name` attribute name
- // `value` attribute value
- attribute(name, value) {
- throw new Error("attribute() applies to element nodes only.");
- }
-
- att(name, value) {
- return this.attribute(name, value);
- }
-
- a(name, value) {
- return this.attribute(name, value);
- }
-
- // Removes an attribute
-
- // `name` attribute name
- removeAttribute(name) {
- throw new Error("attribute() applies to element nodes only.");
- }
-
- // DOM level 1 functions to be implemented later
- replaceChild(newChild, oldChild) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- removeChild(oldChild) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- appendChild(newChild) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- hasChildNodes() {
- return this.children.length !== 0;
- }
-
- cloneNode(deep) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- normalize() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM level 2
- isSupported(feature, version) {
- return true;
- }
-
- hasAttributes() {
- return this.attribs.length !== 0;
- }
-
- // DOM level 3 functions to be implemented later
- compareDocumentPosition(other) {
- var ref, res;
- ref = this;
- if (ref === other) {
- return 0;
- } else if (this.document() !== other.document()) {
- res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
- if (Math.random() < 0.5) {
- res |= DocumentPosition.Preceding;
- } else {
- res |= DocumentPosition.Following;
- }
- return res;
- } else if (ref.isAncestor(other)) {
- return DocumentPosition.Contains | DocumentPosition.Preceding;
- } else if (ref.isDescendant(other)) {
- return DocumentPosition.Contains | DocumentPosition.Following;
- } else if (ref.isPreceding(other)) {
- return DocumentPosition.Preceding;
- } else {
- return DocumentPosition.Following;
- }
- }
-
- isSameNode(other) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- lookupPrefix(namespaceURI) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- isDefaultNamespace(namespaceURI) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- lookupNamespaceURI(prefix) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- isEqualNode(node) {
- var i, j, ref1;
- if (node.nodeType !== this.nodeType) {
- return false;
- }
- if (node.children.length !== this.children.length) {
- return false;
- }
- for (i = j = 0, ref1 = this.children.length - 1; (0 <= ref1 ? j <= ref1 : j >= ref1); i = 0 <= ref1 ? ++j : --j) {
- if (!this.children[i].isEqualNode(node.children[i])) {
- return false;
- }
- }
- return true;
- }
-
- getFeature(feature, version) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- setUserData(key, data, handler) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- getUserData(key) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // Returns true if other is an inclusive descendant of node,
- // and false otherwise.
- contains(other) {
- if (!other) {
- return false;
- }
- return other === this || this.isDescendant(other);
- }
-
- // An object A is called a descendant of an object B, if either A is
- // a child of B or A is a child of an object C that is a descendant of B.
- isDescendant(node) {
- var child, isDescendantChild, j, len, ref1;
- ref1 = this.children;
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- if (node === child) {
- return true;
- }
- isDescendantChild = child.isDescendant(node);
- if (isDescendantChild) {
- return true;
- }
- }
- return false;
- }
-
- // An object A is called an ancestor of an object B if and only if
- // B is a descendant of A.
- isAncestor(node) {
- return node.isDescendant(this);
- }
-
- // An object A is preceding an object B if A and B are in the
- // same tree and A comes before B in tree order.
- isPreceding(node) {
- var nodePos, thisPos;
- nodePos = this.treePosition(node);
- thisPos = this.treePosition(this);
- if (nodePos === -1 || thisPos === -1) {
- return false;
- } else {
- return nodePos < thisPos;
- }
- }
-
- // An object A is folllowing an object B if A and B are in the
- // same tree and A comes after B in tree order.
- isFollowing(node) {
- var nodePos, thisPos;
- nodePos = this.treePosition(node);
- thisPos = this.treePosition(this);
- if (nodePos === -1 || thisPos === -1) {
- return false;
- } else {
- return nodePos > thisPos;
- }
- }
-
- // Returns the preorder position of the given node in the tree, or -1
- // if the node is not in the tree.
- treePosition(node) {
- var found, pos;
- pos = 0;
- found = false;
- this.foreachTreeNode(this.document(), function(childNode) {
- pos++;
- if (!found && childNode === node) {
- return found = true;
- }
- });
- if (found) {
- return pos;
- } else {
- return -1;
- }
- }
-
-
- // Depth-first preorder traversal through the XML tree
- foreachTreeNode(node, func) {
- var child, j, len, ref1, res;
- node || (node = this.document());
- ref1 = node.children;
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- if (res = func(child)) {
- return res;
- } else {
- res = this.foreachTreeNode(child, func);
- if (res) {
- return res;
- }
- }
- }
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLNode.prototype, 'nodeName', {
- get: function() {
- return this.name;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'nodeType', {
- get: function() {
- return this.type;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'nodeValue', {
- get: function() {
- return this.value;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'parentNode', {
- get: function() {
- return this.parent;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'childNodes', {
- get: function() {
- if (!this.childNodeList || !this.childNodeList.nodes) {
- this.childNodeList = new XMLNodeList(this.children);
- }
- return this.childNodeList;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'firstChild', {
- get: function() {
- return this.children[0] || null;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'lastChild', {
- get: function() {
- return this.children[this.children.length - 1] || null;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'previousSibling', {
- get: function() {
- var i;
- i = this.parent.children.indexOf(this);
- return this.parent.children[i - 1] || null;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'nextSibling', {
- get: function() {
- var i;
- i = this.parent.children.indexOf(this);
- return this.parent.children[i + 1] || null;
- }
- });
-
- Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
- get: function() {
- return this.document() || null;
- }
- });
-
- // DOM level 3
- Object.defineProperty(XMLNode.prototype, 'textContent', {
- get: function() {
- var child, j, len, ref1, str;
- if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
- str = '';
- ref1 = this.children;
- for (j = 0, len = ref1.length; j < len; j++) {
- child = ref1[j];
- if (child.textContent) {
- str += child.textContent;
- }
- }
- return str;
- } else {
- return null;
- }
- },
- set: function(value) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- return XMLNode;
-
- }).call(this);
-
- }).call(this);
-
- },{"./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){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Represents a list of nodes
- var XMLNodeList;
-
- module.exports = XMLNodeList = (function() {
- class XMLNodeList {
- // Initializes a new instance of `XMLNodeList`
- // This is just a wrapper around an ordinary
- // JS array.
-
- // `nodes` the array containing nodes.
- constructor(nodes) {
- this.nodes = nodes;
- }
-
- // Creates and returns a deep clone of `this`
-
- clone() {
- // this class should not be cloned since it wraps
- // around a given array. The calling function should check
- // whether the wrapped array is null and supply a new array
- // (from the clone).
- return this.nodes = null;
- }
-
- // DOM Level 1
- item(index) {
- return this.nodes[index] || null;
- }
-
- };
-
- // DOM level 1
- Object.defineProperty(XMLNodeList.prototype, 'length', {
- get: function() {
- return this.nodes.length || 0;
- }
- });
-
- return XMLNodeList;
-
- }).call(this);
-
- }).call(this);
-
- },{}],29:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLCharacterData, XMLProcessingInstruction;
-
- NodeType = require('./NodeType');
-
- XMLCharacterData = require('./XMLCharacterData');
-
- // Represents a processing instruction
- module.exports = XMLProcessingInstruction = class XMLProcessingInstruction extends XMLCharacterData {
- // Initializes a new instance of `XMLProcessingInstruction`
-
- // `parent` the parent node
- // `target` instruction target
- // `value` instruction value
- constructor(parent, target, value) {
- super(parent);
- if (target == null) {
- throw new Error("Missing instruction target. " + this.debugInfo());
- }
- this.type = NodeType.ProcessingInstruction;
- this.target = this.stringify.insTarget(target);
- this.name = this.target;
- if (value) {
- this.value = this.stringify.insValue(value);
- }
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
- }
-
- isEqualNode(node) {
- if (!super.isEqualNode(node)) {
- return false;
- }
- if (node.target !== this.target) {
- return false;
- }
- return true;
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLCharacterData":10}],30:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLNode, XMLRaw;
-
- NodeType = require('./NodeType');
-
- XMLNode = require('./XMLNode');
-
- // Represents a raw node
- module.exports = XMLRaw = class XMLRaw extends XMLNode {
- // Initializes a new instance of `XMLRaw`
-
- // `text` raw text
- constructor(parent, text) {
- super(parent);
- if (text == null) {
- throw new Error("Missing raw text. " + this.debugInfo());
- }
- this.type = NodeType.Raw;
- this.value = this.stringify.raw(text);
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.raw(this, this.options.writer.filterOptions(options));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLNode":27}],31:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
- hasProp = {}.hasOwnProperty;
-
- NodeType = require('./NodeType');
-
- XMLWriterBase = require('./XMLWriterBase');
-
- WriterState = require('./WriterState');
-
- // Prints XML nodes to a stream
- module.exports = XMLStreamWriter = class XMLStreamWriter extends XMLWriterBase {
- // Initializes a new instance of `XMLStreamWriter`
-
- // `stream` output stream
- // `options.pretty` pretty prints the result
- // `options.indent` indentation string
- // `options.newline` newline sequence
- // `options.offset` a fixed number of indentations to add to every line
- // `options.allowEmpty` do not self close empty element tags
- // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
- // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
- constructor(stream, options) {
- super(options);
- this.stream = stream;
- }
-
- endline(node, options, level) {
- if (node.isLastRootNode && options.state === WriterState.CloseTag) {
- return '';
- } else {
- return super.endline(node, options, level);
- }
- }
-
- document(doc, options) {
- var child, i, j, k, len1, len2, ref, ref1, results;
- ref = doc.children;
- // set a flag so that we don't insert a newline after the last root level node
- for (i = j = 0, len1 = ref.length; j < len1; i = ++j) {
- child = ref[i];
- child.isLastRootNode = i === doc.children.length - 1;
- }
- options = this.filterOptions(options);
- ref1 = doc.children;
- results = [];
- for (k = 0, len2 = ref1.length; k < len2; k++) {
- child = ref1[k];
- results.push(this.writeChildNode(child, options, 0));
- }
- return results;
- }
-
- cdata(node, options, level) {
- return this.stream.write(super.cdata(node, options, level));
- }
-
- comment(node, options, level) {
- return this.stream.write(super.comment(node, options, level));
- }
-
- declaration(node, options, level) {
- return this.stream.write(super.declaration(node, options, level));
- }
-
- docType(node, options, level) {
- var child, j, len1, ref;
- level || (level = 0);
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- this.stream.write(this.indent(node, options, level));
- this.stream.write('<!DOCTYPE ' + node.root().name);
- // external identifier
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- // internal subset
- if (node.children.length > 0) {
- this.stream.write(' [');
- this.stream.write(this.endline(node, options, level));
- options.state = WriterState.InsideTag;
- ref = node.children;
- for (j = 0, len1 = ref.length; j < len1; j++) {
- child = ref[j];
- this.writeChildNode(child, options, level + 1);
- }
- options.state = WriterState.CloseTag;
- this.stream.write(']');
- }
- // close tag
- options.state = WriterState.CloseTag;
- this.stream.write(options.spaceBeforeSlash + '>');
- this.stream.write(this.endline(node, options, level));
- options.state = WriterState.None;
- return this.closeNode(node, options, level);
- }
-
- element(node, options, level) {
- var att, attLen, child, childNodeCount, firstChildNode, j, len, len1, name, prettySuppressed, r, ratt, ref, ref1, ref2, rline;
- level || (level = 0);
- // open tag
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<' + node.name;
- // attributes
- if (options.pretty && options.width > 0) {
- len = r.length;
- ref = node.attribs;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- ratt = this.attribute(att, options, level);
- attLen = ratt.length;
- if (len + attLen > options.width) {
- rline = this.indent(node, options, level + 1) + ratt;
- r += this.endline(node, options, level) + rline;
- len = rline.length;
- } else {
- rline = ' ' + ratt;
- r += rline;
- len += rline.length;
- }
- }
- } else {
- ref1 = node.attribs;
- for (name in ref1) {
- if (!hasProp.call(ref1, name)) continue;
- att = ref1[name];
- r += this.attribute(att, options, level);
- }
- }
- this.stream.write(r);
- childNodeCount = node.children.length;
- firstChildNode = childNodeCount === 0 ? null : node.children[0];
- if (childNodeCount === 0 || node.children.every(function(e) {
- return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
- })) {
- // empty element
- if (options.allowEmpty) {
- this.stream.write('>');
- options.state = WriterState.CloseTag;
- this.stream.write('</' + node.name + '>');
- } else {
- options.state = WriterState.CloseTag;
- this.stream.write(options.spaceBeforeSlash + '/>');
- }
- } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
- // do not indent text-only nodes
- this.stream.write('>');
- options.state = WriterState.InsideTag;
- options.suppressPrettyCount++;
- prettySuppressed = true;
- this.writeChildNode(firstChildNode, options, level + 1);
- options.suppressPrettyCount--;
- prettySuppressed = false;
- options.state = WriterState.CloseTag;
- this.stream.write('</' + node.name + '>');
- } else {
- this.stream.write('>' + this.endline(node, options, level));
- options.state = WriterState.InsideTag;
- ref2 = node.children;
- // inner tags
- for (j = 0, len1 = ref2.length; j < len1; j++) {
- child = ref2[j];
- this.writeChildNode(child, options, level + 1);
- }
- // close tag
- options.state = WriterState.CloseTag;
- this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
- }
- this.stream.write(this.endline(node, options, level));
- options.state = WriterState.None;
- return this.closeNode(node, options, level);
- }
-
- processingInstruction(node, options, level) {
- return this.stream.write(super.processingInstruction(node, options, level));
- }
-
- raw(node, options, level) {
- return this.stream.write(super.raw(node, options, level));
- }
-
- text(node, options, level) {
- return this.stream.write(super.text(node, options, level));
- }
-
- dtdAttList(node, options, level) {
- return this.stream.write(super.dtdAttList(node, options, level));
- }
-
- dtdElement(node, options, level) {
- return this.stream.write(super.dtdElement(node, options, level));
- }
-
- dtdEntity(node, options, level) {
- return this.stream.write(super.dtdEntity(node, options, level));
- }
-
- dtdNotation(node, options, level) {
- return this.stream.write(super.dtdNotation(node, options, level));
- }
-
- };
-
- }).call(this);
-
- },{"./NodeType":5,"./WriterState":7,"./XMLWriterBase":35}],32:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var XMLStringWriter, XMLWriterBase;
-
- XMLWriterBase = require('./XMLWriterBase');
-
- // Prints XML nodes as plain text
- module.exports = XMLStringWriter = class XMLStringWriter extends XMLWriterBase {
- // Initializes a new instance of `XMLStringWriter`
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation string
- // `options.newline` newline sequence
- // `options.offset` a fixed number of indentations to add to every line
- // `options.allowEmpty` do not self close empty element tags
- // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
- // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
- constructor(options) {
- super(options);
- }
-
- document(doc, options) {
- var child, i, len, r, ref;
- options = this.filterOptions(options);
- r = '';
- ref = doc.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- r += this.writeChildNode(child, options, 0);
- }
- // remove trailing newline
- if (options.pretty && r.slice(-options.newline.length) === options.newline) {
- r = r.slice(0, -options.newline.length);
- }
- return r;
- }
-
- };
-
- }).call(this);
-
- },{"./XMLWriterBase":35}],33:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- // Converts values to strings
- var XMLStringifier,
- hasProp = {}.hasOwnProperty;
-
- module.exports = XMLStringifier = (function() {
- class XMLStringifier {
- // Initializes a new instance of `XMLStringifier`
-
- // `options.version` The version number string of the XML spec to validate against, e.g. 1.0
- // `options.noDoubleEncoding` whether existing html entities are encoded: true or false
- // `options.stringify` a set of functions to use for converting values to strings
- // `options.noValidation` whether values will be validated and escaped or returned as is
- // `options.invalidCharReplacement` a character to replace invalid characters and disable character validation
- constructor(options) {
- var key, ref, value;
- // Checks whether the given string contains legal characters
- // Fails with an exception on error
-
- // `str` the string to check
- this.assertLegalChar = this.assertLegalChar.bind(this);
- // Checks whether the given string contains legal characters for a name
- // Fails with an exception on error
-
- // `str` the string to check
- this.assertLegalName = this.assertLegalName.bind(this);
- options || (options = {});
- this.options = options;
- if (!this.options.version) {
- this.options.version = '1.0';
- }
- ref = options.stringify || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this[key] = value;
- }
- }
-
- // Defaults
- name(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalName('' + val || '');
- }
-
- text(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar(this.textEscape('' + val || ''));
- }
-
- cdata(val) {
- if (this.options.noValidation) {
- return val;
- }
- val = '' + val || '';
- val = val.replace(']]>', ']]]]><![CDATA[>');
- return this.assertLegalChar(val);
- }
-
- comment(val) {
- if (this.options.noValidation) {
- return val;
- }
- val = '' + val || '';
- if (val.match(/--/)) {
- throw new Error("Comment text cannot contain double-hypen: " + val);
- }
- return this.assertLegalChar(val);
- }
-
- raw(val) {
- if (this.options.noValidation) {
- return val;
- }
- return '' + val || '';
- }
-
- attValue(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar(this.attEscape(val = '' + val || ''));
- }
-
- insTarget(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- insValue(val) {
- if (this.options.noValidation) {
- return val;
- }
- val = '' + val || '';
- if (val.match(/\?>/)) {
- throw new Error("Invalid processing instruction value: " + val);
- }
- return this.assertLegalChar(val);
- }
-
- xmlVersion(val) {
- if (this.options.noValidation) {
- return val;
- }
- val = '' + val || '';
- if (!val.match(/1\.[0-9]+/)) {
- throw new Error("Invalid version number: " + val);
- }
- return val;
- }
-
- xmlEncoding(val) {
- if (this.options.noValidation) {
- return val;
- }
- val = '' + val || '';
- if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
- throw new Error("Invalid encoding: " + val);
- }
- return this.assertLegalChar(val);
- }
-
- xmlStandalone(val) {
- if (this.options.noValidation) {
- return val;
- }
- if (val) {
- return "yes";
- } else {
- return "no";
- }
- }
-
- dtdPubID(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdSysID(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdElementValue(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdAttType(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdAttDefault(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdEntityValue(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- dtdNData(val) {
- if (this.options.noValidation) {
- return val;
- }
- return this.assertLegalChar('' + val || '');
- }
-
- assertLegalChar(str) {
- var regex, res;
- if (this.options.noValidation) {
- return str;
- }
- if (this.options.version === '1.0') {
- // Valid characters from https://www.w3.org/TR/xml/#charsets
- // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
- // let xml_10_InvalidChars = regenerate()
- // .addRange(0x0000, 0x0008)
- // .add(0x000B, 0x000C)
- // .addRange(0x000E, 0x001F)
- // .addRange(0xD800, 0xDFFF)
- // .addRange(0xFFFE, 0xFFFF)
- regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
- if (this.options.invalidCharReplacement !== void 0) {
- str = str.replace(regex, this.options.invalidCharReplacement);
- } else if (res = str.match(regex)) {
- throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
- }
- } else if (this.options.version === '1.1') {
- // Valid characters from https://www.w3.org/TR/xml11/#charsets
- // any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- // [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- // This ES5 compatible Regexp has been generated using the "regenerate" NPM module:
- // let xml_11_InvalidChars = regenerate()
- // .add(0x0000)
- // .addRange(0xD800, 0xDFFF)
- // .addRange(0xFFFE, 0xFFFF)
- regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
- if (this.options.invalidCharReplacement !== void 0) {
- str = str.replace(regex, this.options.invalidCharReplacement);
- } else if (res = str.match(regex)) {
- throw new Error(`Invalid character in string: ${str} at index ${res.index}`);
- }
- }
- return str;
- }
-
- assertLegalName(str) {
- var regex;
- if (this.options.noValidation) {
- return str;
- }
- str = this.assertLegalChar(str);
- 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])*$/;
- if (!str.match(regex)) {
- throw new Error(`Invalid character in name: ${str}`);
- }
- return str;
- }
-
- // Escapes special characters in text
-
- // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
-
- // `str` the string to escape
- textEscape(str) {
- var ampregex;
- if (this.options.noValidation) {
- return str;
- }
- ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r/g, '
');
- }
-
- // Escapes special characters in attribute values
-
- // See http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping
-
- // `str` the string to escape
- attEscape(str) {
- var ampregex;
- if (this.options.noValidation) {
- return str;
- }
- ampregex = this.options.noDoubleEncoding ? /(?!&(lt|gt|amp|apos|quot);)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
');
- }
-
- };
-
- // strings to match while converting from JS objects
- XMLStringifier.prototype.convertAttKey = '@';
-
- XMLStringifier.prototype.convertPIKey = '?';
-
- XMLStringifier.prototype.convertTextKey = '#text';
-
- XMLStringifier.prototype.convertCDataKey = '#cdata';
-
- XMLStringifier.prototype.convertCommentKey = '#comment';
-
- XMLStringifier.prototype.convertRawKey = '#raw';
-
- return XMLStringifier;
-
- }).call(this);
-
- }).call(this);
-
- },{}],34:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, XMLCharacterData, XMLText;
-
- NodeType = require('./NodeType');
-
- XMLCharacterData = require('./XMLCharacterData');
-
- // Represents a text node
- module.exports = XMLText = (function() {
- class XMLText extends XMLCharacterData {
- // Initializes a new instance of `XMLText`
-
- // `text` element text
- constructor(parent, text) {
- super(parent);
- if (text == null) {
- throw new Error("Missing element text. " + this.debugInfo());
- }
- this.name = "#text";
- this.type = NodeType.Text;
- this.value = this.stringify.text(text);
- }
-
- // Creates and returns a deep clone of `this`
- clone() {
- return Object.create(this);
- }
-
- // Converts the XML fragment to string
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation for pretty print
- // `options.offset` how many indentations to add to every line for pretty print
- // `options.newline` newline sequence for pretty print
- toString(options) {
- return this.options.writer.text(this, this.options.writer.filterOptions(options));
- }
-
- // DOM level 1 functions to be implemented later
- splitText(offset) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- // DOM level 3 functions to be implemented later
- replaceWholeText(content) {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
-
- };
-
- // DOM level 3
- Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
- get: function() {
- throw new Error("This DOM method is not implemented." + this.debugInfo());
- }
- });
-
- Object.defineProperty(XMLText.prototype, 'wholeText', {
- get: function() {
- var next, prev, str;
- str = '';
- prev = this.previousSibling;
- while (prev) {
- str = prev.data + str;
- prev = prev.previousSibling;
- }
- str += this.data;
- next = this.nextSibling;
- while (next) {
- str = str + next.data;
- next = next.nextSibling;
- }
- return str;
- }
- });
-
- return XMLText;
-
- }).call(this);
-
- }).call(this);
-
- },{"./NodeType":5,"./XMLCharacterData":10}],35:[function(require,module,exports){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
- hasProp = {}.hasOwnProperty;
-
- ({assign} = require('./Utility'));
-
- NodeType = require('./NodeType');
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLElement = require('./XMLElement');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDummy = require('./XMLDummy');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- WriterState = require('./WriterState');
-
- // Base class for XML writers
- module.exports = XMLWriterBase = class XMLWriterBase {
- // Initializes a new instance of `XMLWriterBase`
-
- // `options.pretty` pretty prints the result
- // `options.indent` indentation string
- // `options.newline` newline sequence
- // `options.offset` a fixed number of indentations to add to every line
- // `options.width` maximum column width
- // `options.allowEmpty` do not self close empty element tags
- // 'options.dontPrettyTextNodes' if any text is present in node, don't indent or LF
- // `options.spaceBeforeSlash` add a space before the closing slash of empty elements
- constructor(options) {
- var key, ref, value;
- options || (options = {});
- this.options = options;
- ref = options.writer || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this["_" + key] = this[key];
- this[key] = value;
- }
- }
-
- // Filters writer options and provides defaults
-
- // `options` writer options
- filterOptions(options) {
- var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
- options || (options = {});
- options = assign({}, this.options, options);
- filteredOptions = {
- writer: this
- };
- filteredOptions.pretty = options.pretty || false;
- filteredOptions.allowEmpty = options.allowEmpty || false;
- filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
- filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
- filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
- filteredOptions.width = (ref3 = options.width) != null ? ref3 : 0;
- filteredOptions.dontPrettyTextNodes = (ref4 = (ref5 = options.dontPrettyTextNodes) != null ? ref5 : options.dontprettytextnodes) != null ? ref4 : 0;
- filteredOptions.spaceBeforeSlash = (ref6 = (ref7 = options.spaceBeforeSlash) != null ? ref7 : options.spacebeforeslash) != null ? ref6 : '';
- if (filteredOptions.spaceBeforeSlash === true) {
- filteredOptions.spaceBeforeSlash = ' ';
- }
- filteredOptions.suppressPrettyCount = 0;
- filteredOptions.user = {};
- filteredOptions.state = WriterState.None;
- return filteredOptions;
- }
-
- // Returns the indentation string for the current level
-
- // `node` current node
- // `options` writer options
- // `level` current indentation level
- indent(node, options, level) {
- var indentLevel;
- if (!options.pretty || options.suppressPrettyCount) {
- return '';
- } else if (options.pretty) {
- indentLevel = (level || 0) + options.offset + 1;
- if (indentLevel > 0) {
- return new Array(indentLevel).join(options.indent);
- }
- }
- return '';
- }
-
- // Returns the newline string
-
- // `node` current node
- // `options` writer options
- // `level` current indentation level
- endline(node, options, level) {
- if (!options.pretty || options.suppressPrettyCount) {
- return '';
- } else {
- return options.newline;
- }
- }
-
- attribute(att, options, level) {
- var r;
- this.openAttribute(att, options, level);
- if (options.pretty && options.width > 0) {
- r = att.name + '="' + att.value + '"';
- } else {
- r = ' ' + att.name + '="' + att.value + '"';
- }
- this.closeAttribute(att, options, level);
- return r;
- }
-
- cdata(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<![CDATA[';
- options.state = WriterState.InsideTag;
- r += node.value;
- options.state = WriterState.CloseTag;
- r += ']]>' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- comment(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<!-- ';
- options.state = WriterState.InsideTag;
- r += node.value;
- options.state = WriterState.CloseTag;
- r += ' -->' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- declaration(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<?xml';
- options.state = WriterState.InsideTag;
- r += ' version="' + node.version + '"';
- if (node.encoding != null) {
- r += ' encoding="' + node.encoding + '"';
- }
- if (node.standalone != null) {
- r += ' standalone="' + node.standalone + '"';
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '?>';
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- docType(node, options, level) {
- var child, i, len1, r, ref;
- level || (level = 0);
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level);
- r += '<!DOCTYPE ' + node.root().name;
- // external identifier
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- // internal subset
- if (node.children.length > 0) {
- r += ' [';
- r += this.endline(node, options, level);
- options.state = WriterState.InsideTag;
- ref = node.children;
- for (i = 0, len1 = ref.length; i < len1; i++) {
- child = ref[i];
- r += this.writeChildNode(child, options, level + 1);
- }
- options.state = WriterState.CloseTag;
- r += ']';
- }
- // close tag
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '>';
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- element(node, options, level) {
- var att, attLen, child, childNodeCount, firstChildNode, i, j, len, len1, len2, name, prettySuppressed, r, ratt, ref, ref1, ref2, ref3, rline;
- level || (level = 0);
- prettySuppressed = false;
- // open tag
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<' + node.name;
- // attributes
- if (options.pretty && options.width > 0) {
- len = r.length;
- ref = node.attribs;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- ratt = this.attribute(att, options, level);
- attLen = ratt.length;
- if (len + attLen > options.width) {
- rline = this.indent(node, options, level + 1) + ratt;
- r += this.endline(node, options, level) + rline;
- len = rline.length;
- } else {
- rline = ' ' + ratt;
- r += rline;
- len += rline.length;
- }
- }
- } else {
- ref1 = node.attribs;
- for (name in ref1) {
- if (!hasProp.call(ref1, name)) continue;
- att = ref1[name];
- r += this.attribute(att, options, level);
- }
- }
- childNodeCount = node.children.length;
- firstChildNode = childNodeCount === 0 ? null : node.children[0];
- if (childNodeCount === 0 || node.children.every(function(e) {
- return (e.type === NodeType.Text || e.type === NodeType.Raw || e.type === NodeType.CData) && e.value === '';
- })) {
- // empty element
- if (options.allowEmpty) {
- r += '>';
- options.state = WriterState.CloseTag;
- r += '</' + node.name + '>' + this.endline(node, options, level);
- } else {
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
- }
- } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw || firstChildNode.type === NodeType.CData) && (firstChildNode.value != null)) {
- // do not indent text-only nodes
- r += '>';
- options.state = WriterState.InsideTag;
- options.suppressPrettyCount++;
- prettySuppressed = true;
- r += this.writeChildNode(firstChildNode, options, level + 1);
- options.suppressPrettyCount--;
- prettySuppressed = false;
- options.state = WriterState.CloseTag;
- r += '</' + node.name + '>' + this.endline(node, options, level);
- } else {
- // if ANY are a text node, then suppress pretty now
- if (options.dontPrettyTextNodes) {
- ref2 = node.children;
- for (i = 0, len1 = ref2.length; i < len1; i++) {
- child = ref2[i];
- if ((child.type === NodeType.Text || child.type === NodeType.Raw || child.type === NodeType.CData) && (child.value != null)) {
- options.suppressPrettyCount++;
- prettySuppressed = true;
- break;
- }
- }
- }
- // close the opening tag, after dealing with newline
- r += '>' + this.endline(node, options, level);
- options.state = WriterState.InsideTag;
- ref3 = node.children;
- // inner tags
- for (j = 0, len2 = ref3.length; j < len2; j++) {
- child = ref3[j];
- r += this.writeChildNode(child, options, level + 1);
- }
- // close tag
- options.state = WriterState.CloseTag;
- r += this.indent(node, options, level) + '</' + node.name + '>';
- if (prettySuppressed) {
- options.suppressPrettyCount--;
- }
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- }
- this.closeNode(node, options, level);
- return r;
- }
-
- writeChildNode(node, options, level) {
- switch (node.type) {
- case NodeType.CData:
- return this.cdata(node, options, level);
- case NodeType.Comment:
- return this.comment(node, options, level);
- case NodeType.Element:
- return this.element(node, options, level);
- case NodeType.Raw:
- return this.raw(node, options, level);
- case NodeType.Text:
- return this.text(node, options, level);
- case NodeType.ProcessingInstruction:
- return this.processingInstruction(node, options, level);
- case NodeType.Dummy:
- return '';
- case NodeType.Declaration:
- return this.declaration(node, options, level);
- case NodeType.DocType:
- return this.docType(node, options, level);
- case NodeType.AttributeDeclaration:
- return this.dtdAttList(node, options, level);
- case NodeType.ElementDeclaration:
- return this.dtdElement(node, options, level);
- case NodeType.EntityDeclaration:
- return this.dtdEntity(node, options, level);
- case NodeType.NotationDeclaration:
- return this.dtdNotation(node, options, level);
- default:
- throw new Error("Unknown XML node type: " + node.constructor.name);
- }
- }
-
- processingInstruction(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<?';
- options.state = WriterState.InsideTag;
- r += node.target;
- if (node.value) {
- r += ' ' + node.value;
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '?>';
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- raw(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level);
- options.state = WriterState.InsideTag;
- r += node.value;
- options.state = WriterState.CloseTag;
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- text(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level);
- options.state = WriterState.InsideTag;
- r += node.value;
- options.state = WriterState.CloseTag;
- r += this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- dtdAttList(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<!ATTLIST';
- options.state = WriterState.InsideTag;
- r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
- if (node.defaultValueType !== '#DEFAULT') {
- r += ' ' + node.defaultValueType;
- }
- if (node.defaultValue) {
- r += ' "' + node.defaultValue + '"';
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- dtdElement(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<!ELEMENT';
- options.state = WriterState.InsideTag;
- r += ' ' + node.name + ' ' + node.value;
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- dtdEntity(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<!ENTITY';
- options.state = WriterState.InsideTag;
- if (node.pe) {
- r += ' %';
- }
- r += ' ' + node.name;
- if (node.value) {
- r += ' "' + node.value + '"';
- } else {
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- if (node.nData) {
- r += ' NDATA ' + node.nData;
- }
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- dtdNotation(node, options, level) {
- var r;
- this.openNode(node, options, level);
- options.state = WriterState.OpenTag;
- r = this.indent(node, options, level) + '<!NOTATION';
- options.state = WriterState.InsideTag;
- r += ' ' + node.name;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.pubID) {
- r += ' PUBLIC "' + node.pubID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- options.state = WriterState.CloseTag;
- r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
- options.state = WriterState.None;
- this.closeNode(node, options, level);
- return r;
- }
-
- openNode(node, options, level) {}
-
- closeNode(node, options, level) {}
-
- openAttribute(att, options, level) {}
-
- closeAttribute(att, options, level) {}
-
- };
-
- }).call(this);
-
- },{"./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){
- // Generated by CoffeeScript 2.4.1
- (function() {
- var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction;
-
- ({assign, isFunction} = require('./Utility'));
-
- XMLDOMImplementation = require('./XMLDOMImplementation');
-
- XMLDocument = require('./XMLDocument');
-
- XMLDocumentCB = require('./XMLDocumentCB');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- XMLStreamWriter = require('./XMLStreamWriter');
-
- NodeType = require('./NodeType');
-
- WriterState = require('./WriterState');
-
- // Creates a new document and returns the root node for
- // chain-building the document tree
-
- // `name` name of the root element
-
- // `xmldec.version` A version number string, e.g. 1.0
- // `xmldec.encoding` Encoding declaration, e.g. UTF-8
- // `xmldec.standalone` standalone document declaration: true or false
-
- // `doctype.pubID` public identifier of the external subset
- // `doctype.sysID` system identifier of the external subset
-
- // `options.headless` whether XML declaration and doctype will be included:
- // true or false
- // `options.keepNullNodes` whether nodes with null values will be kept
- // or ignored: true or false
- // `options.keepNullAttributes` whether attributes with null values will be
- // kept or ignored: true or false
- // `options.ignoreDecorators` whether decorator strings will be ignored when
- // converting JS objects: true or false
- // `options.separateArrayItems` whether array items are created as separate
- // nodes when passed as an object value: true or false
- // `options.noDoubleEncoding` whether existing html entities are encoded:
- // true or false
- // `options.stringify` a set of functions to use for converting values to
- // strings
- // `options.writer` the default XML writer to use for converting nodes to
- // string. If the default writer is not set, the built-in XMLStringWriter
- // will be used instead.
- module.exports.create = function(name, xmldec, doctype, options) {
- var doc, root;
- if (name == null) {
- throw new Error("Root element needs a name.");
- }
- options = assign({}, xmldec, doctype, options);
- // create the document node
- doc = new XMLDocument(options);
- // add the root node
- root = doc.element(name);
- // prolog
- if (!options.headless) {
- doc.declaration(options);
- if ((options.pubID != null) || (options.sysID != null)) {
- doc.dtd(options);
- }
- }
- return root;
- };
-
- // Creates a new document and returns the document node for
- // chain-building the document tree
-
- // `options.keepNullNodes` whether nodes with null values will be kept
- // or ignored: true or false
- // `options.keepNullAttributes` whether attributes with null values will be
- // kept or ignored: true or false
- // `options.ignoreDecorators` whether decorator strings will be ignored when
- // converting JS objects: true or false
- // `options.separateArrayItems` whether array items are created as separate
- // nodes when passed as an object value: true or false
- // `options.noDoubleEncoding` whether existing html entities are encoded:
- // true or false
- // `options.stringify` a set of functions to use for converting values to
- // strings
- // `options.writer` the default XML writer to use for converting nodes to
- // string. If the default writer is not set, the built-in XMLStringWriter
- // will be used instead.
-
- // `onData` the function to be called when a new chunk of XML is output. The
- // string containing the XML chunk is passed to `onData` as its single
- // argument.
- // `onEnd` the function to be called when the XML document is completed with
- // `end`. `onEnd` does not receive any arguments.
- module.exports.begin = function(options, onData, onEnd) {
- if (isFunction(options)) {
- [onData, onEnd] = [options, onData];
- options = {};
- }
- if (onData) {
- return new XMLDocumentCB(options, onData, onEnd);
- } else {
- return new XMLDocument(options);
- }
- };
-
- module.exports.stringWriter = function(options) {
- return new XMLStringWriter(options);
- };
-
- module.exports.streamWriter = function(stream, options) {
- return new XMLStreamWriter(stream, options);
- };
-
- module.exports.implementation = new XMLDOMImplementation();
-
- module.exports.nodeType = NodeType;
-
- module.exports.writerState = WriterState;
-
- }).call(this);
-
- },{"./NodeType":5,"./Utility":6,"./WriterState":7,"./XMLDOMImplementation":14,"./XMLDocument":22,"./XMLDocumentCB":23,"./XMLStreamWriter":31,"./XMLStringWriter":32}]},{},[1])(1)
- });
|