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

index.d.ts 51KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771
  1. import { Writable } from 'stream';
  2. export = xmlbuilder;
  3. /**
  4. * Type definitions for [xmlbuilder](https://github.com/oozcitak/xmlbuilder-js)
  5. *
  6. * Original definitions on [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) by:
  7. * - Wallymathieu <https://github.com/wallymathieu>
  8. * - GaikwadPratik <https://github.com/GaikwadPratik>
  9. */
  10. declare namespace xmlbuilder {
  11. /**
  12. * Creates a new XML document and returns the root element node.
  13. *
  14. * @param nameOrObject - name of the root element or a JS object to be
  15. * converted to an XML tree
  16. * @param xmldecOrOptions - XML declaration or create options
  17. * @param doctypeOrOptions - Doctype declaration or create options
  18. * @param options - create options
  19. */
  20. function create(nameOrObject: string | { [name: string]: Object },
  21. xmldecOrOptions?: CreateOptions, doctypeOrOptions?: CreateOptions,
  22. options?: CreateOptions): XMLElement;
  23. /**
  24. * Defines the options used while creating an XML document with the `create`
  25. * function.
  26. */
  27. interface CreateOptions {
  28. /**
  29. * A version number string, e.g. `1.0`
  30. */
  31. version?: string;
  32. /**
  33. * Encoding declaration, e.g. `UTF-8`
  34. */
  35. encoding?: string;
  36. /**
  37. * Standalone document declaration: `true` or `false`
  38. */
  39. standalone?: boolean;
  40. /**
  41. * Public identifier of the DTD
  42. */
  43. pubID?: string;
  44. /**
  45. * System identifier of the DTD
  46. */
  47. sysID?: string;
  48. /**
  49. * Whether XML declaration and doctype will be included
  50. */
  51. headless?: boolean;
  52. /**
  53. * Whether nodes with `null` values will be kept or ignored
  54. */
  55. keepNullNodes?: boolean;
  56. /**
  57. * Whether attributes with `null` values will be kept or ignored
  58. */
  59. keepNullAttributes?: boolean;
  60. /**
  61. * Whether decorator strings will be ignored when converting JS
  62. * objects
  63. */
  64. ignoreDecorators?: boolean;
  65. /**
  66. * Whether array items are created as separate nodes when passed
  67. * as an object value
  68. */
  69. separateArrayItems?: boolean;
  70. /**
  71. * Whether existing html entities are encoded
  72. */
  73. noDoubleEncoding?: boolean;
  74. /**
  75. * Whether values will be validated and escaped or returned as is
  76. */
  77. noValidation?: boolean;
  78. /**
  79. * A character to replace invalid characters in all values. This also
  80. * disables character validation.
  81. */
  82. invalidCharReplacement?: string;
  83. /**
  84. * A set of functions to use for converting values to strings
  85. */
  86. stringify?: XMLStringifier;
  87. /**
  88. * The default XML writer to use for converting nodes to string.
  89. * If the default writer is not set, the built-in `XMLStringWriter`
  90. * will be used instead.
  91. */
  92. writer?: XMLWriter;
  93. }
  94. /**
  95. * Defines the functions used for converting values to strings.
  96. */
  97. interface XMLStringifier {
  98. /**
  99. * Converts an element or attribute name to string
  100. */
  101. name?: (v: any) => string;
  102. /**
  103. * Converts the contents of a text node to string
  104. */
  105. text?: (v: any) => string;
  106. /**
  107. * Converts the contents of a CDATA node to string
  108. */
  109. cdata?: (v: any) => string;
  110. /**
  111. * Converts the contents of a comment node to string
  112. */
  113. comment?: (v: any) => string;
  114. /**
  115. * Converts the contents of a raw text node to string
  116. */
  117. raw?: (v: any) => string;
  118. /**
  119. * Converts attribute value to string
  120. */
  121. attValue?: (v: any) => string;
  122. /**
  123. * Converts processing instruction target to string
  124. */
  125. insTarget?: (v: any) => string;
  126. /**
  127. * Converts processing instruction value to string
  128. */
  129. insValue?: (v: any) => string;
  130. /**
  131. * Converts XML version to string
  132. */
  133. xmlVersion?: (v: any) => string;
  134. /**
  135. * Converts XML encoding to string
  136. */
  137. xmlEncoding?: (v: any) => string;
  138. /**
  139. * Converts standalone document declaration to string
  140. */
  141. xmlStandalone?: (v: any) => string;
  142. /**
  143. * Converts DocType public identifier to string
  144. */
  145. dtdPubID?: (v: any) => string;
  146. /**
  147. * Converts DocType system identifier to string
  148. */
  149. dtdSysID?: (v: any) => string;
  150. /**
  151. * Converts `!ELEMENT` node content inside Doctype to string
  152. */
  153. dtdElementValue?: (v: any) => string;
  154. /**
  155. * Converts `!ATTLIST` node type inside DocType to string
  156. */
  157. dtdAttType?: (v: any) => string;
  158. /**
  159. * Converts `!ATTLIST` node default value inside DocType to string
  160. */
  161. dtdAttDefault?: (v: any) => string;
  162. /**
  163. * Converts `!ENTITY` node content inside Doctype to string
  164. */
  165. dtdEntityValue?: (v: any) => string;
  166. /**
  167. * Converts `!NOTATION` node content inside Doctype to string
  168. */
  169. dtdNData?: (v: any) => string;
  170. /**
  171. * When prepended to a JS object key, converts the key-value pair
  172. * to an attribute.
  173. */
  174. convertAttKey?: string;
  175. /**
  176. * When prepended to a JS object key, converts the key-value pair
  177. * to a processing instruction node.
  178. */
  179. convertPIKey?: string;
  180. /**
  181. * When prepended to a JS object key, converts its value to a text node.
  182. *
  183. * _Note:_ Since JS objects cannot contain duplicate keys, multiple text
  184. * nodes can be created by adding some unique text after each object
  185. * key. For example: `{ '#text1': 'some text', '#text2': 'more text' };`
  186. */
  187. convertTextKey?: string;
  188. /**
  189. * When prepended to a JS object key, converts its value to a CDATA
  190. * node.
  191. */
  192. convertCDataKey?: string;
  193. /**
  194. * When prepended to a JS object key, converts its value to a
  195. * comment node.
  196. */
  197. convertCommentKey?: string;
  198. /**
  199. * When prepended to a JS object key, converts its value to a raw
  200. * text node.
  201. */
  202. convertRawKey?: string;
  203. /**
  204. * Escapes special characters in text.
  205. */
  206. textEscape?: (v: string) => string;
  207. /**
  208. * Escapes special characters in attribute values.
  209. */
  210. attEscape?: (v: string) => string;
  211. }
  212. /**
  213. * Represents a writer which outputs an XML document.
  214. */
  215. interface XMLWriter {
  216. /**
  217. * Writes the indentation string for the given level.
  218. *
  219. * @param node - current node
  220. * @param options - writer options and state information
  221. * @param level - current depth of the XML tree
  222. */
  223. indent?: (node: XMLNode, options: WriterOptions, level: number) => any
  224. /**
  225. * Writes the newline string.
  226. *
  227. * @param node - current node
  228. * @param options - writer options and state information
  229. * @param level - current depth of the XML tree
  230. */
  231. endline?: (node: XMLNode, options: WriterOptions, level: number) => any
  232. /**
  233. * Writes an attribute.
  234. *
  235. * @param att - current attribute
  236. * @param options - writer options and state information
  237. * @param level - current depth of the XML tree
  238. */
  239. attribute?: (att: XMLAttribute, options: WriterOptions,
  240. level: number) => any
  241. /**
  242. * Writes a CDATA node.
  243. *
  244. * @param node - current node
  245. * @param options - writer options and state information
  246. * @param level - current depth of the XML tree
  247. */
  248. cdata?: (node: XMLCData, options: WriterOptions, level: number) => any
  249. /**
  250. * Writes a comment node.
  251. *
  252. * @param node - current node
  253. * @param options - writer options and state information
  254. * @param level - current depth of the XML tree
  255. */
  256. comment?: (node: XMLComment, options: WriterOptions,
  257. level: number) => any
  258. /**
  259. * Writes the XML declaration (e.g. `<?xml version="1.0"?>`).
  260. *
  261. * @param node - XML declaration node
  262. * @param options - writer options and state information
  263. * @param level - current depth of the XML tree
  264. */
  265. declaration?: (node: XMLDeclaration, options: WriterOptions,
  266. level: number) => any
  267. /**
  268. * Writes the DocType node and its children.
  269. *
  270. * _Note:_ Be careful when overriding this function as this function
  271. * is also responsible for writing the internal subset of the DTD.
  272. *
  273. * @param node - DOCTYPE node
  274. * @param options - writer options and state information
  275. * @param level - current depth of the XML tree
  276. */
  277. docType?: (node: XMLDocType, options: WriterOptions,
  278. level: number) => any
  279. /**
  280. * Writes an element node.
  281. *
  282. * _Note:_ Be careful when overriding this function as this function
  283. * is also responsible for writing the element attributes and child
  284. * nodes.
  285. *
  286. *
  287. * @param node - current node
  288. * @param options - writer options and state information
  289. * @param level - current depth of the XML tree
  290. */
  291. element?: (node: XMLElement, options: WriterOptions,
  292. level: number) => any
  293. /**
  294. * Writes a processing instruction node.
  295. *
  296. * @param node - current node
  297. * @param options - writer options and state information
  298. * @param level - current depth of the XML tree
  299. */
  300. processingInstruction?: (node: XMLProcessingInstruction,
  301. options: WriterOptions, level: number) => any
  302. /**
  303. * Writes a raw text node.
  304. *
  305. * @param node - current node
  306. * @param options - writer options and state information
  307. * @param level - current depth of the XML tree
  308. */
  309. raw?: (node: XMLRaw, options: WriterOptions, level: number) => any
  310. /**
  311. * Writes a text node.
  312. *
  313. * @param node - current node
  314. * @param options - writer options and state information
  315. * @param level - current depth of the XML tree
  316. */
  317. text?: (node: XMLText, options: WriterOptions, level: number) => any
  318. /**
  319. * Writes an attribute node (`!ATTLIST`) inside the DTD.
  320. *
  321. * @param node - current node
  322. * @param options - writer options and state information
  323. * @param level - current depth of the XML tree
  324. */
  325. dtdAttList?: (node: XMLDTDAttList, options: WriterOptions,
  326. level: number) => any
  327. /**
  328. * Writes an element node (`!ELEMENT`) inside the DTD.
  329. *
  330. * @param node - current node
  331. * @param options - writer options and state information
  332. * @param level - current depth of the XML tree
  333. */
  334. dtdElement?: (node: XMLDTDElement, options: WriterOptions,
  335. level: number) => any
  336. /**
  337. * Writes an entity node (`!ENTITY`) inside the DTD.
  338. *
  339. * @param node - current node
  340. * @param options - writer options and state information
  341. * @param level - current depth of the XML tree
  342. */
  343. dtdEntity?: (node: XMLDTDEntity, options: WriterOptions,
  344. level: number) => any
  345. /**
  346. * Writes a notation node (`!NOTATION`) inside the DTD.
  347. *
  348. * @param node - current node
  349. * @param options - writer options and state information
  350. * @param level - current depth of the XML tree
  351. */
  352. dtdNotation?: (node: XMLDTDNotation, options: WriterOptions,
  353. level: number) => any
  354. /**
  355. * Called right after starting writing a node. This function does not
  356. * produce any output, but can be used to alter the state of the writer.
  357. *
  358. * @param node - current node
  359. * @param options - writer options and state information
  360. * @param level - current depth of the XML tree
  361. */
  362. openNode?: (node: XMLNode, options: WriterOptions,
  363. level: number) => void
  364. /**
  365. * Called right before completing writing a node. This function does not
  366. * produce any output, but can be used to alter the state of the writer.
  367. *
  368. * @param node - current node
  369. * @param options - writer options and state information
  370. * @param level - current depth of the XML tree
  371. */
  372. closeNode?: (node: XMLNode, options: WriterOptions,
  373. level: number) => void
  374. /**
  375. * Called right after starting writing an attribute. This function does
  376. * not produce any output, but can be used to alter the state of the
  377. * writer.
  378. *
  379. * @param node - current attribute
  380. * @param options - writer options and state information
  381. * @param level - current depth of the XML tree
  382. */
  383. openAttribute?: (att: XMLAttribute, options: WriterOptions,
  384. level: number) => void
  385. /**
  386. * Called right before completing writing an attribute. This function
  387. * does not produce any output, but can be used to alter the state of
  388. * the writer.
  389. *
  390. * @param node - current attribute
  391. * @param options - writer options and state information
  392. * @param level - current depth of the XML tree
  393. */
  394. closeAttribute?: (att: XMLAttribute, options: WriterOptions,
  395. level: number) => void
  396. }
  397. /**
  398. * Defines the options passed to the XML writer.
  399. */
  400. interface WriterOptions {
  401. /**
  402. * Pretty print the XML tree
  403. */
  404. pretty?: boolean;
  405. /**
  406. * Indentation string for pretty printing
  407. */
  408. indent?: string;
  409. /**
  410. * Newline string for pretty printing
  411. */
  412. newline?: string;
  413. /**
  414. * A fixed number of indents to offset strings
  415. */
  416. offset?: number;
  417. /**
  418. * Maximum column width
  419. */
  420. width?: number;
  421. /**
  422. * Whether to output closing tags for empty element nodes
  423. */
  424. allowEmpty?: boolean;
  425. /**
  426. * Whether to pretty print text nodes
  427. */
  428. dontPrettyTextNodes?: boolean;
  429. /**
  430. * A string to insert before closing slash character
  431. */
  432. spaceBeforeSlash?: string | boolean;
  433. /**
  434. * User state object that is saved between writer functions
  435. */
  436. user?: any;
  437. /**
  438. * The current state of the writer
  439. */
  440. state?: WriterState;
  441. /**
  442. * Writer function overrides
  443. */
  444. writer?: XMLWriter;
  445. }
  446. /**
  447. * Defines the state of the writer.
  448. */
  449. enum WriterState {
  450. /**
  451. * Writer state is unknown
  452. */
  453. None = 0,
  454. /**
  455. * Writer is at an opening tag, e.g. `<node>`
  456. */
  457. OpenTag = 1,
  458. /**
  459. * Writer is inside an element
  460. */
  461. InsideTag = 2,
  462. /**
  463. * Writer is at a closing tag, e.g. `</node>`
  464. */
  465. CloseTag = 3
  466. }
  467. /**
  468. * Creates a new XML document and returns the document node.
  469. * This function creates an empty document without the XML prolog or
  470. * a root element.
  471. *
  472. * @param options - create options
  473. */
  474. function begin(options?: BeginOptions): XMLDocument;
  475. /**
  476. * Defines the options used while creating an XML document with the `begin`
  477. * function.
  478. */
  479. interface BeginOptions {
  480. /**
  481. * Whether nodes with null values will be kept or ignored
  482. */
  483. keepNullNodes?: boolean;
  484. /**
  485. * Whether attributes with null values will be kept or ignored
  486. */
  487. keepNullAttributes?: boolean;
  488. /**
  489. * Whether decorator strings will be ignored when converting JS
  490. * objects
  491. */
  492. ignoreDecorators?: boolean;
  493. /**
  494. * Whether array items are created as separate nodes when passed
  495. * as an object value
  496. */
  497. separateArrayItems?: boolean;
  498. /**
  499. * Whether existing html entities are encoded
  500. */
  501. noDoubleEncoding?: boolean;
  502. /**
  503. * Whether values will be validated and escaped or returned as is
  504. */
  505. noValidation?: boolean;
  506. /**
  507. * A character to replace invalid characters in all values. This also
  508. * disables character validation.
  509. */
  510. invalidCharReplacement?: string;
  511. /**
  512. * A set of functions to use for converting values to strings
  513. */
  514. stringify?: XMLStringifier;
  515. /**
  516. * The default XML writer to use for converting nodes to string.
  517. * If the default writer is not set, the built-in XMLStringWriter
  518. * will be used instead.
  519. */
  520. writer?: XMLWriter | WriterOptions;
  521. }
  522. /**
  523. * A function to be called when a chunk of XML is written.
  524. *
  525. * @param chunk - a chunk of string that was written
  526. * @param level - current depth of the XML tree
  527. */
  528. type OnDataCallback = (chunk: string, level: number) => void;
  529. /**
  530. * A function to be called when the XML doucment is completed.
  531. */
  532. type OnEndCallback = () => void;
  533. /**
  534. * Creates a new XML document in callback mode and returns the document
  535. * node.
  536. *
  537. * @param options - create options
  538. * @param onData - the function to be called when a new chunk of XML is
  539. * output. The string containing the XML chunk is passed to `onData` as
  540. * its first argument and the current depth of the tree is passed as its
  541. * second argument.
  542. * @param onEnd - the function to be called when the XML document is
  543. * completed with `end`. `onEnd` does not receive any arguments.
  544. */
  545. function begin(options?: BeginOptions | OnDataCallback,
  546. onData?: OnDataCallback | OnEndCallback,
  547. onEnd?: OnEndCallback): XMLDocumentCB;
  548. /**
  549. * Creates and returns a default string writer.
  550. *
  551. * @param options - writer options
  552. */
  553. function stringWriter(options?: WriterOptions): XMLWriter
  554. /**
  555. * Creates and returns a default stream writer.
  556. *
  557. * @param stream - a writeable stream
  558. * @param options - writer options
  559. */
  560. function streamWriter(stream: Writable, options?: WriterOptions): XMLWriter
  561. /**
  562. * Defines the type of a node in the XML document.
  563. */
  564. enum NodeType {
  565. /**
  566. * An element node
  567. */
  568. Element = 1,
  569. /**
  570. * An attribute node
  571. */
  572. Attribute = 2,
  573. /**
  574. * A text node
  575. */
  576. Text = 3,
  577. /**
  578. * A CDATA node
  579. */
  580. CData = 4,
  581. /**
  582. * An entity reference node inside DocType
  583. */
  584. EntityReference = 5,
  585. /**
  586. * An entity declaration node inside DocType
  587. */
  588. EntityDeclaration = 6,
  589. /**
  590. * A processing instruction node
  591. */
  592. ProcessingInstruction = 7,
  593. /**
  594. * A comment node
  595. */
  596. Comment = 8,
  597. /**
  598. * A document node
  599. */
  600. Document = 9,
  601. /**
  602. * A Doctype node
  603. */
  604. DocType = 10,
  605. /**
  606. * A document fragment node
  607. */
  608. DocumentFragment = 11,
  609. /**
  610. * A notation declaration node inside DocType
  611. */
  612. NotationDeclaration = 12,
  613. /**
  614. * An XML declaration node
  615. */
  616. Declaration = 201,
  617. /**
  618. * A raw text node
  619. */
  620. Raw = 202,
  621. /**
  622. * An attribute declaraiton node inside DocType
  623. */
  624. AttributeDeclaration = 203,
  625. /**
  626. * An element declaration node inside DocType
  627. */
  628. ElementDeclaration = 204
  629. }
  630. /**
  631. * Defines the type of a node in the XML document.
  632. */
  633. export import nodeType = NodeType;
  634. /**
  635. * Defines the state of the writer.
  636. */
  637. export import writerState = WriterState;
  638. /**
  639. * Defines the settings used when converting the XML document to string.
  640. */
  641. interface XMLToStringOptions {
  642. /**
  643. * Pretty print the XML tree
  644. */
  645. pretty?: boolean;
  646. /**
  647. * Indentation string for pretty printing
  648. */
  649. indent?: string;
  650. /**
  651. * Newline string for pretty printing
  652. */
  653. newline?: string;
  654. /**
  655. * A fixed number of indents to offset strings
  656. */
  657. offset?: number;
  658. /**
  659. * Maximum column width
  660. */
  661. width?: number;
  662. /**
  663. * Whether to output closing tags for empty element nodes
  664. */
  665. allowEmpty?: boolean;
  666. /**
  667. * Whether to pretty print text nodes
  668. */
  669. dontPrettyTextNodes?: boolean;
  670. /**
  671. * A string to insert before closing slash character
  672. */
  673. spaceBeforeSlash?: string | boolean;
  674. /**
  675. * The default XML writer to use for converting nodes to string.
  676. * If the default writer is not set, the built-in `XMLStringWriter`
  677. * will be used instead.
  678. */
  679. writer?: XMLWriter;
  680. }
  681. /**
  682. * Represents the XML document.
  683. */
  684. class XMLDocument extends XMLNode {
  685. /**
  686. * Converts the node to string
  687. *
  688. * @param options - conversion options
  689. */
  690. toString(options?: XMLToStringOptions): string;
  691. }
  692. /**
  693. * Represents an XML attribute.
  694. */
  695. class XMLAttribute {
  696. /**
  697. * Type of the node
  698. */
  699. type: NodeType;
  700. /**
  701. * Parent element node
  702. */
  703. parent: XMLElement;
  704. /**
  705. * Attribute name
  706. */
  707. name: string;
  708. /**
  709. * Attribute value
  710. */
  711. value: string;
  712. /**
  713. * Creates a clone of this node
  714. */
  715. clone(): XMLAttribute;
  716. /**
  717. * Converts the node to string
  718. *
  719. * @param options - conversion options
  720. */
  721. toString(options?: XMLToStringOptions): string;
  722. }
  723. /**
  724. * Represents the base class of XML nodes.
  725. */
  726. abstract class XMLNode {
  727. /**
  728. * Type of the node
  729. */
  730. type: NodeType;
  731. /**
  732. * Parent element node
  733. */
  734. parent: XMLElement;
  735. /**
  736. * Child nodes
  737. */
  738. children: XMLNode[]
  739. /**
  740. * Creates a new child node and appends it to the list of child nodes.
  741. *
  742. * _Aliases:_ `ele` and `e`
  743. *
  744. * @param name - node name or a JS object defining the nodes to insert
  745. * @param attributes - node attributes
  746. * @param text - node text
  747. *
  748. * @returns the last top level node created
  749. */
  750. element(name: any, attributes?: Object, text?: any): XMLElement;
  751. ele(name: any, attributes?: Object, text?: any): XMLElement;
  752. e(name: any, attributes?: Object, text?: any): XMLElement;
  753. /**
  754. * Adds or modifies an attribute.
  755. *
  756. * _Aliases:_ `att`, `a`
  757. *
  758. * @param name - attribute name
  759. * @param value - attribute value
  760. *
  761. * @returns the parent element node
  762. */
  763. attribute(name: any, value?: any): XMLElement;
  764. att(name: any, value?: any): XMLElement;
  765. a(name: any, value?: any): XMLElement;
  766. /**
  767. * Creates a new sibling node and inserts it before this node.
  768. *
  769. * @param name - node name or a JS object defining the nodes to insert
  770. * @param attributes - node attributes
  771. * @param text - node text
  772. *
  773. * @returns the new node
  774. */
  775. insertBefore(name: any, attributes?: Object, text?: any): XMLElement;
  776. /**
  777. * Creates a new sibling node and inserts it after this node.
  778. *
  779. * @param name - node name or a JS object defining the nodes to insert
  780. * @param attributes - node attributes
  781. * @param text - node text
  782. *
  783. * @returns the new node
  784. */
  785. insertAfter(name: any, attributes?: Object, text?: any): XMLElement;
  786. /**
  787. * Removes this node from the tree.
  788. *
  789. * @returns the parent node
  790. */
  791. remove(): XMLElement;
  792. /**
  793. * Creates a new element node and appends it to the list of child nodes.
  794. *
  795. * _Aliases:_ `nod` and `n`
  796. *
  797. * @param name - element node name
  798. * @param attributes - node attributes
  799. * @param text - node text
  800. *
  801. * @returns the node created
  802. */
  803. node(name: string, attributes?: Object, text?: any): XMLElement;
  804. nod(name: string, attributes?: Object, text?: any): XMLElement;
  805. n(name: string, attributes?: Object, text?: any): XMLElement;
  806. /**
  807. * Creates a new text node and appends it to the list of child nodes.
  808. *
  809. * _Aliases:_ `txt` and `t`
  810. *
  811. * @param value - node value
  812. *
  813. * @returns the parent node
  814. */
  815. text(value: string): XMLElement;
  816. txt(value: string): XMLElement;
  817. t(value: string): XMLElement;
  818. /**
  819. * Creates a new CDATA node and appends it to the list of child nodes.
  820. *
  821. * _Aliases:_ `dat` and `d`
  822. *
  823. * @param value - node value
  824. *
  825. * @returns the parent node
  826. */
  827. cdata(value: string): XMLElement;
  828. dat(value: string): XMLElement;
  829. d(value: string): XMLElement;
  830. /**
  831. * Creates a new comment node and appends it to the list of child nodes.
  832. *
  833. * _Aliases:_ `com` and `c`
  834. *
  835. * @param value - node value
  836. *
  837. * @returns the parent node
  838. */
  839. comment(value: string): XMLElement;
  840. com(value: string): XMLElement;
  841. c(value: string): XMLElement;
  842. /**
  843. * Creates a comment node before the current node
  844. *
  845. * @param value - node value
  846. *
  847. * @returns the parent node
  848. */
  849. commentBefore(value: string): XMLElement;
  850. /**
  851. * Creates a comment node after the current node
  852. *
  853. * @param value - node value
  854. *
  855. * @returns the parent node
  856. */
  857. commentAfter(value: string): XMLElement;
  858. /**
  859. * Creates a new raw text node and appends it to the list of child
  860. * nodes.
  861. *
  862. * _Alias:_ `r`
  863. *
  864. * @param value - node value
  865. *
  866. * @returns the parent node
  867. */
  868. raw(value: string): XMLElement;
  869. r(value: string): XMLElement;
  870. /**
  871. * Creates a new processing instruction node and appends it to the list
  872. * of child nodes.
  873. *
  874. * _Aliases:_ `ins` and `i`
  875. *
  876. * @param target - node target
  877. * @param value - node value
  878. *
  879. * @returns the parent node
  880. */
  881. instruction(target: string, value: any): XMLElement;
  882. instruction(array: Array<any>): XMLElement;
  883. instruction(obj: Object): XMLElement;
  884. ins(target: string, value: any): XMLElement;
  885. ins(array: Array<any>): XMLElement;
  886. ins(obj: Object): XMLElement;
  887. i(target: string, value: any): XMLElement;
  888. i(array: Array<any>): XMLElement;
  889. i(obj: Object): XMLElement;
  890. /**
  891. * Creates a processing instruction node before the current node.
  892. *
  893. * @param target - node target
  894. * @param value - node value
  895. *
  896. * @returns the parent node
  897. */
  898. instructionBefore(target: string, value: any): XMLElement;
  899. /**
  900. * Creates a processing instruction node after the current node.
  901. *
  902. * @param target - node target
  903. * @param value - node value
  904. *
  905. * @returns the parent node
  906. */
  907. instructionAfter(target: string, value: any): XMLElement;
  908. /**
  909. * Creates the XML declaration.
  910. *
  911. * _Alias:_ `dec`
  912. *
  913. * @param version - version number string, e.g. `1.0`
  914. * @param encoding - encoding declaration, e.g. `UTF-8`
  915. * @param standalone - standalone document declaration: `true` or `false`
  916. *
  917. * @returns the root element node
  918. */
  919. declaration(version?: string |
  920. { version?: string, encoding?: string, standalone?: boolean },
  921. encoding?: string, standalone?: boolean): XMLElement;
  922. dec(version?: string |
  923. { version?: string, encoding?: string, standalone?: boolean },
  924. encoding?: string, standalone?: boolean): XMLElement;
  925. /**
  926. * Creates the document type definition.
  927. *
  928. * _Alias:_ `dtd`
  929. *
  930. * @param pubID - public identifier of the DTD
  931. * @param sysID - system identifier of the DTD
  932. *
  933. * @returns the DOCTYPE node
  934. */
  935. doctype(pubID?: string | { pubID?: string, sysID?: string },
  936. sysID?: string): XMLDocType;
  937. dtd(pubID?: string | { pubID?: string, sysID?: string },
  938. sysID?: string): XMLDocType;
  939. /**
  940. * Takes the root node of the given XML document and appends it
  941. * to child nodes.
  942. *
  943. * @param doc - the document whose root node to import
  944. *
  945. * @returns the current node
  946. */
  947. importDocument(doc: XMLNode): XMLElement;
  948. /**
  949. * Converts the XML document to string.
  950. *
  951. * @param options - conversion options
  952. */
  953. end(options?: XMLWriter | XMLToStringOptions): string;
  954. /**
  955. * Returns the previous sibling node.
  956. */
  957. prev(): XMLNode;
  958. /**
  959. * Returns the next sibling node.
  960. */
  961. next(): XMLNode;
  962. /**
  963. * Returns the parent node.
  964. *
  965. * _Alias:_ `u`
  966. */
  967. up(): XMLElement;
  968. u(): XMLElement;
  969. /**
  970. * Returns the document node.
  971. *
  972. * _Alias:_ `doc`
  973. */
  974. document(): XMLDocument;
  975. doc(): XMLDocument;
  976. /**
  977. * Returns the root element node.
  978. */
  979. root(): XMLElement;
  980. }
  981. /**
  982. * Represents the base class of character data nodes.
  983. */
  984. abstract class XMLCharacterData extends XMLNode {
  985. /**
  986. * Node value
  987. */
  988. value: string;
  989. }
  990. /**
  991. * Represents a CDATA node.
  992. */
  993. class XMLCData extends XMLCharacterData {
  994. /**
  995. * Converts the node to string
  996. *
  997. * @param options - conversion options
  998. */
  999. toString(options?: XMLToStringOptions): string;
  1000. /**
  1001. * Creates a clone of this node
  1002. */
  1003. clone(): XMLCData;
  1004. }
  1005. /**
  1006. * Represents a comment node.
  1007. */
  1008. class XMLComment extends XMLCharacterData {
  1009. /**
  1010. * Converts the node to string
  1011. *
  1012. * @param options - conversion options
  1013. */
  1014. toString(options?: XMLToStringOptions): string;
  1015. /**
  1016. * Creates a clone of this node
  1017. */
  1018. clone(): XMLComment;
  1019. }
  1020. /**
  1021. * Represents a processing instruction node.
  1022. */
  1023. class XMLProcessingInstruction extends XMLCharacterData {
  1024. /** Instruction target
  1025. */
  1026. target: string;
  1027. /**
  1028. * Converts the node to string
  1029. *
  1030. * @param options - conversion options
  1031. */
  1032. toString(options?: XMLToStringOptions): string;
  1033. /**
  1034. * Creates a clone of this node
  1035. */
  1036. clone(): XMLProcessingInstruction;
  1037. }
  1038. /**
  1039. * Represents a raw text node.
  1040. */
  1041. class XMLRaw extends XMLCharacterData {
  1042. /**
  1043. * Converts the node to string
  1044. *
  1045. * @param options - conversion options
  1046. */
  1047. toString(options?: XMLToStringOptions): string;
  1048. /**
  1049. * Creates a clone of this node
  1050. */
  1051. clone(): XMLRaw;
  1052. }
  1053. /**
  1054. * Represents a text node.
  1055. */
  1056. class XMLText extends XMLCharacterData {
  1057. /**
  1058. * Converts the node to string
  1059. *
  1060. * @param options - conversion options
  1061. */
  1062. toString(options?: XMLToStringOptions): string;
  1063. /**
  1064. * Creates a clone of this node
  1065. */
  1066. clone(): XMLText;
  1067. }
  1068. /**
  1069. * Represents the XML declaration.
  1070. */
  1071. class XMLDeclaration {
  1072. /**
  1073. * A version number string, e.g. `1.0`
  1074. */
  1075. version: string;
  1076. /**
  1077. * Encoding declaration, e.g. `UTF-8`
  1078. */
  1079. encoding: string;
  1080. /**
  1081. * Standalone document declaration: `true` or `false`
  1082. */
  1083. standalone: boolean;
  1084. /**
  1085. * Converts the node to string.
  1086. *
  1087. * @param options - conversion options
  1088. */
  1089. toString(options?: XMLToStringOptions): string;
  1090. }
  1091. /**
  1092. * Represents the document type definition.
  1093. */
  1094. class XMLDocType {
  1095. /**
  1096. * Type of the node
  1097. */
  1098. type: NodeType;
  1099. /**
  1100. * Parent element node
  1101. */
  1102. parent: XMLElement;
  1103. /**
  1104. * Child nodes
  1105. */
  1106. children: XMLNode[]
  1107. /**
  1108. * Public identifier of the DTD
  1109. */
  1110. pubID: string;
  1111. /**
  1112. * System identifier of the DTD
  1113. */
  1114. sysID: string;
  1115. /**
  1116. * Creates an element type declaration.
  1117. *
  1118. * _Alias:_ `ele`
  1119. *
  1120. * @param name - element name
  1121. * @param value - element content (defaults to `#PCDATA`)
  1122. *
  1123. * @returns the DOCTYPE node
  1124. */
  1125. element(name: string, value?: Object): XMLDocType;
  1126. ele(name: string, value?: Object): XMLDocType;
  1127. /**
  1128. * Creates an attribute declaration.
  1129. *
  1130. * _Alias:_ `att`
  1131. *
  1132. * @param elementName - the name of the element containing this attribute
  1133. * @param attributeName - attribute name
  1134. * @param attributeType - type of the attribute
  1135. * @param defaultValueType - default value type (either `#REQUIRED`,
  1136. * `#IMPLIED`, `#FIXED` or `#DEFAULT`)
  1137. * @param defaultValue - default value of the attribute (only used
  1138. * for `#FIXED` or `#DEFAULT`)
  1139. *
  1140. * @returns the DOCTYPE node
  1141. */
  1142. attList(elementName: string, attributeName: string, attributeType: string,
  1143. defaultValueType: string, defaultValue?: any): XMLDocType;
  1144. att(elementName: string, attributeName: string, attributeType: string,
  1145. defaultValueType: string, defaultValue?: any): XMLDocType;
  1146. /**
  1147. * Creates a general entity declaration.
  1148. *
  1149. * _Alias:_ `ent`
  1150. *
  1151. * @param name - the name of the entity
  1152. * @param value - entity parameters
  1153. *
  1154. * @returns the DOCTYPE node
  1155. */
  1156. entity(name: string, value: string |
  1157. { pubID?: string, sysID?: string, nData?: string }): XMLDocType;
  1158. ent(name: string, value: string |
  1159. { pubID?: string, sysID?: string, nData?: string }): XMLDocType;
  1160. /**
  1161. * Creates a parameter entity declaration.
  1162. *
  1163. * _Alias:_ `pent`
  1164. *
  1165. * @param name - the name of the entity
  1166. * @param value - entity parameters
  1167. *
  1168. * @returns the DOCTYPE node
  1169. */
  1170. pEntity(name: string, value: string |
  1171. { pubID?: string, sysID?: string }): XMLDocType;
  1172. pent(name: string, value: string |
  1173. { pubID?: string, sysID?: string }): XMLDocType;
  1174. /**
  1175. * Creates a notation declaration.
  1176. *
  1177. * _Alias:_ `not`
  1178. *
  1179. * @param name - the name of the entity
  1180. * @param value - entity parameters
  1181. *
  1182. * @returns the DOCTYPE node
  1183. */
  1184. notation(name: string,
  1185. value: { pubID?: string, sysID?: string }): XMLDocType;
  1186. not(name: string,
  1187. value: { pubID?: string, sysID?: string }): XMLDocType;
  1188. /**
  1189. * Creates a new CDATA node and appends it to the list of child nodes.
  1190. *
  1191. * _Alias:_ `dat`
  1192. *
  1193. * @param value - node value
  1194. *
  1195. * @returns the DOCTYPE node
  1196. */
  1197. cdata(value: string): XMLDocType;
  1198. dat(value: string): XMLDocType;
  1199. /**
  1200. * Creates a new comment child and appends it to the list of child
  1201. * nodes.
  1202. *
  1203. * _Alias:_ `com`
  1204. *
  1205. * @param value - node value
  1206. *
  1207. * @returns the DOCTYPE node
  1208. */
  1209. comment(value: string): XMLDocType;
  1210. com(value: string): XMLDocType;
  1211. /**
  1212. * Creates a new processing instruction node and appends it to the list
  1213. * of child nodes.
  1214. *
  1215. * _Alias:_ `ins`
  1216. *
  1217. * @param target - node target
  1218. * @param value - node value
  1219. *
  1220. * @returns the DOCTYPE node
  1221. */
  1222. instruction(target: string, value: any): XMLDocType;
  1223. instruction(array: Array<any>): XMLDocType;
  1224. instruction(obj: Object): XMLDocType;
  1225. ins(target: string, value: any): XMLDocType;
  1226. ins(array: Array<any>): XMLDocType;
  1227. ins(obj: Object): XMLDocType;
  1228. /**
  1229. * Returns the root element node.
  1230. *
  1231. * _Alias:_ `up`
  1232. */
  1233. root(): XMLElement;
  1234. up(): XMLElement;
  1235. /**
  1236. * Converts the node to string.
  1237. *
  1238. * @param options - conversion options
  1239. */
  1240. toString(options?: XMLToStringOptions): string;
  1241. /**
  1242. * Creates a clone of this node.
  1243. */
  1244. clone(): XMLDocType;
  1245. /**
  1246. * Returns the document node.
  1247. *
  1248. * _Alias:_ `doc`
  1249. */
  1250. document(): XMLDocument;
  1251. doc(): XMLDocument;
  1252. /**
  1253. * Converts the XML document to string.
  1254. *
  1255. * @param options - conversion options
  1256. */
  1257. end(options?: XMLWriter | XMLToStringOptions): string;
  1258. }
  1259. /**
  1260. * Represents an attribute list in the DTD.
  1261. */
  1262. class XMLDTDAttList {
  1263. /**
  1264. * The name of the element containing this attribute
  1265. */
  1266. elementName: string;
  1267. /**
  1268. * Attribute name
  1269. */
  1270. attributeName: string;
  1271. /**
  1272. * Type of the attribute
  1273. */
  1274. attributeType: string;
  1275. /**
  1276. * Default value type (either `#REQUIRED`, `#IMPLIED`, `#FIXED`
  1277. * or `#DEFAULT`)
  1278. */
  1279. defaultValueType: string;
  1280. /**
  1281. * Default value of the attribute (only used for `#FIXED` or
  1282. * `#DEFAULT`)
  1283. */
  1284. defaultValue: string;
  1285. /**
  1286. * Converts the node to string.
  1287. *
  1288. * @param options - conversion options
  1289. */
  1290. toString(options?: XMLToStringOptions): string;
  1291. }
  1292. /**
  1293. * Represents an element in the DTD.
  1294. */
  1295. class XMLDTDElement {
  1296. /**
  1297. * The name of the element
  1298. */
  1299. name: string;
  1300. /**
  1301. * Element content
  1302. */
  1303. value: string;
  1304. /**
  1305. * Converts the node to string.
  1306. *
  1307. * @param options - conversion options
  1308. */
  1309. toString(options?: XMLToStringOptions): string;
  1310. }
  1311. /**
  1312. * Represents an entity in the DTD.
  1313. */
  1314. class XMLDTDEntity {
  1315. /**
  1316. * Determines whether this is a parameter entity (`true`) or a
  1317. * general entity (`false`).
  1318. */
  1319. pe: boolean;
  1320. /**
  1321. * The name of the entity
  1322. */
  1323. name: string;
  1324. /**
  1325. * Public identifier
  1326. */
  1327. pubID: string;
  1328. /**
  1329. * System identifier
  1330. */
  1331. sysID: string;
  1332. /**
  1333. * Notation declaration
  1334. */
  1335. nData: string;
  1336. /**
  1337. * Converts the node to string.
  1338. *
  1339. * @param options - conversion options
  1340. */
  1341. toString(options?: XMLToStringOptions): string;
  1342. }
  1343. /**
  1344. * Represents a notation in the DTD.
  1345. */
  1346. class XMLDTDNotation {
  1347. /**
  1348. * The name of the notation
  1349. */
  1350. name: string;
  1351. /**
  1352. * Public identifier
  1353. */
  1354. pubID: string;
  1355. /**
  1356. * System identifier
  1357. */
  1358. sysID: string;
  1359. /**
  1360. * Converts the node to string.
  1361. *
  1362. * @param options - conversion options
  1363. */
  1364. toString(options?: XMLToStringOptions): string;
  1365. }
  1366. /**
  1367. * Represents an element node.
  1368. */
  1369. class XMLElement extends XMLNode {
  1370. /**
  1371. * Element node name
  1372. */
  1373. name: string;
  1374. /**
  1375. * Element attributes
  1376. */
  1377. attribs: { string: XMLAttribute };
  1378. /**
  1379. * Creates a clone of this node
  1380. */
  1381. clone(): XMLElement;
  1382. /**
  1383. * Adds or modifies an attribute.
  1384. *
  1385. * _Aliases:_ `att`, `a`
  1386. *
  1387. * @param name - attribute name
  1388. * @param value - attribute value
  1389. *
  1390. * @returns the parent element node
  1391. */
  1392. attribute(name: any, value?: any): XMLElement;
  1393. att(name: any, value?: any): XMLElement;
  1394. a(name: any, value?: any): XMLElement;
  1395. /**
  1396. * Removes an attribute.
  1397. *
  1398. * @param name - attribute name
  1399. *
  1400. * @returns the parent element node
  1401. */
  1402. removeAttribute(name: string | string[]): XMLElement;
  1403. /**
  1404. * Converts the node to string.
  1405. *
  1406. * @param options - conversion options
  1407. */
  1408. toString(options?: XMLToStringOptions): string;
  1409. }
  1410. /**
  1411. * Represents an XML document builder used in callback mode with the
  1412. * `begin` function.
  1413. */
  1414. class XMLDocumentCB {
  1415. /**
  1416. * Creates a new child node and appends it to the list of child nodes.
  1417. *
  1418. * _Aliases:_ `nod` and `n`
  1419. *
  1420. * @param name - element node name
  1421. * @param attributes - node attributes
  1422. * @param text - node text
  1423. *
  1424. * @returns the document builder object
  1425. */
  1426. node(name: string, attributes?: Object, text?: any): XMLDocumentCB;
  1427. nod(name: string, attributes?: Object, text?: any): XMLDocumentCB;
  1428. n(name: string, attributes?: Object, text?: any): XMLDocumentCB;
  1429. /**
  1430. * Creates a child element node.
  1431. *
  1432. * _Aliases:_ `ele` and `e`
  1433. *
  1434. * @param name - element node name or a JS object defining the nodes
  1435. * to insert
  1436. * @param attributes - node attributes
  1437. * @param text - node text
  1438. *
  1439. * @returns the document builder object
  1440. */
  1441. element(name: any, attributes?: Object, text?: any): XMLDocumentCB;
  1442. ele(name: any, attributes?: Object, text?: any): XMLDocumentCB;
  1443. e(name: any, attributes?: Object, text?: any): XMLDocumentCB;
  1444. /**
  1445. * Adds or modifies an attribute.
  1446. *
  1447. * _Aliases:_ `att` and `a`
  1448. *
  1449. * @param name - attribute name
  1450. * @param value - attribute value
  1451. *
  1452. * @returns the document builder object
  1453. */
  1454. attribute(name: any, value?: any): XMLDocumentCB;
  1455. att(name: any, value?: any): XMLDocumentCB;
  1456. a(name: any, value?: any): XMLDocumentCB;
  1457. /**
  1458. * Creates a new text node and appends it to the list of child nodes.
  1459. *
  1460. * _Aliases:_ `txt` and `t`
  1461. *
  1462. * @param value - node value
  1463. *
  1464. * @returns the document builder object
  1465. */
  1466. text(value: string): XMLDocumentCB;
  1467. txt(value: string): XMLDocumentCB;
  1468. t(value: string): XMLDocumentCB;
  1469. /**
  1470. * Creates a new CDATA node and appends it to the list of child nodes.
  1471. *
  1472. * _Aliases:_ `dat` and `d`
  1473. *
  1474. * @param value - node value
  1475. *
  1476. * @returns the document builder object
  1477. */
  1478. cdata(value: string): XMLDocumentCB;
  1479. dat(value: string): XMLDocumentCB;
  1480. d(value: string): XMLDocumentCB;
  1481. /**
  1482. * Creates a new comment node and appends it to the list of child nodes.
  1483. *
  1484. * _Aliases:_ `com` and `c`
  1485. *
  1486. * @param value - node value
  1487. *
  1488. * @returns the document builder object
  1489. */
  1490. comment(value: string): XMLDocumentCB;
  1491. com(value: string): XMLDocumentCB;
  1492. c(value: string): XMLDocumentCB;
  1493. /**
  1494. * Creates a new raw text node and appends it to the list of child
  1495. * nodes.
  1496. *
  1497. * _Alias:_ `r`
  1498. *
  1499. * @param value - node value
  1500. *
  1501. * @returns the document builder object
  1502. */
  1503. raw(value: string): XMLDocumentCB;
  1504. r(value: string): XMLDocumentCB;
  1505. /**
  1506. * Creates a new processing instruction node and appends it to the list
  1507. * of child nodes.
  1508. *
  1509. * _Aliases:_ `ins` and `i`
  1510. *
  1511. * @param target - node target
  1512. * @param value - node value
  1513. *
  1514. * @returns the document builder object
  1515. */
  1516. instruction(target: string, value: any): XMLDocumentCB;
  1517. instruction(array: Array<any>): XMLDocumentCB;
  1518. instruction(obj: Object): XMLDocumentCB;
  1519. ins(target: string, value: any): XMLDocumentCB;
  1520. ins(array: Array<any>): XMLDocumentCB;
  1521. ins(obj: Object): XMLDocumentCB;
  1522. i(target: string, value: any): XMLDocumentCB;
  1523. i(array: Array<any>): XMLDocumentCB;
  1524. i(obj: Object): XMLDocumentCB;
  1525. /**
  1526. * Creates the XML declaration.
  1527. *
  1528. * _Alias:_ `dec`
  1529. *
  1530. * @param version - version number string, e.g. `1.0`
  1531. * @param encoding - encoding declaration, e.g. `UTF-8`
  1532. * @param standalone - standalone document declaration: `true` or `false`
  1533. *
  1534. * @returns the document builder object
  1535. */
  1536. declaration(version?: string, encoding?: string,
  1537. standalone?: boolean): XMLDocumentCB;
  1538. dec(version?: string, encoding?: string,
  1539. standalone?: boolean): XMLDocumentCB;
  1540. /**
  1541. * Creates the document type definition.
  1542. *
  1543. * _Alias:_ `dtd`
  1544. *
  1545. * @param root - the name of the root node
  1546. * @param pubID - public identifier of the DTD
  1547. * @param sysID - system identifier of the DTD
  1548. *
  1549. * @returns the document builder object
  1550. */
  1551. doctype(root: string, pubID?: string, sysID?: string): XMLDocumentCB;
  1552. dtd(root: string, pubID?: string, sysID?: string): XMLDocumentCB;
  1553. /**
  1554. * Creates an element type declaration.
  1555. *
  1556. * _Aliases:_ `element` and `ele`
  1557. *
  1558. * @param name - element name
  1559. * @param value - element content (defaults to `#PCDATA`)
  1560. *
  1561. * @returns the document builder object
  1562. */
  1563. dtdElement(name: string, value?: Object): XMLDocumentCB;
  1564. element(name: string, value?: Object): XMLDocumentCB;
  1565. ele(name: string, value?: Object): XMLDocumentCB;
  1566. /**
  1567. * Creates an attribute declaration.
  1568. *
  1569. * _Alias:_ `att`
  1570. *
  1571. * @param elementName - the name of the element containing this attribute
  1572. * @param attributeName - attribute name
  1573. * @param attributeType - type of the attribute (defaults to `CDATA`)
  1574. * @param defaultValueType - default value type (either `#REQUIRED`,
  1575. * `#IMPLIED`, `#FIXED` or `#DEFAULT`) (defaults to `#IMPLIED`)
  1576. * @param defaultValue - default value of the attribute (only used
  1577. * for `#FIXED` or `#DEFAULT`)
  1578. *
  1579. * @returns the document builder object
  1580. */
  1581. attList(elementName: string, attributeName: string,
  1582. attributeType: string, defaultValueType?:
  1583. string, defaultValue?: any): XMLDocumentCB;
  1584. att(elementName: string, attributeName: string, attributeType: string,
  1585. defaultValueType?: string, defaultValue?: any): XMLDocumentCB;
  1586. a(elementName: string, attributeName: string, attributeType: string,
  1587. defaultValueType?: string, defaultValue?: any): XMLDocumentCB;
  1588. /**
  1589. * Creates a general entity declaration.
  1590. *
  1591. * _Alias:_ `ent`
  1592. *
  1593. * @param name - the name of the entity
  1594. * @param value - entity parameters
  1595. *
  1596. * @returns the document builder object
  1597. */
  1598. entity(name: string, value: string |
  1599. { pubID?: string, sysID?: string, nData?: string }): XMLDocumentCB;
  1600. ent(name: string, value: string |
  1601. { pubID?: string, sysID?: string, nData?: string }): XMLDocumentCB;
  1602. /**
  1603. * Creates a parameter entity declaration.
  1604. *
  1605. * _Alias:_ `pent`
  1606. *
  1607. * @param name - the name of the entity
  1608. * @param value - entity parameters
  1609. *
  1610. * @returns the document builder object
  1611. */
  1612. pEntity(name: string, value: string |
  1613. { pubID?: string, sysID?: string }): XMLDocumentCB;
  1614. pent(name: string, value: string |
  1615. { pubID?: string, sysID?: string }): XMLDocumentCB;
  1616. /**
  1617. * Creates a notation declaration.
  1618. *
  1619. * _Alias:_ `not`
  1620. *
  1621. * @param name - the name of the entity
  1622. * @param value - entity parameters
  1623. *
  1624. * @returns the document builder object
  1625. */
  1626. notation(name: string,
  1627. value: { pubID?: string, sysID?: string }): XMLDocumentCB;
  1628. not(name: string,
  1629. value: { pubID?: string, sysID?: string }): XMLDocumentCB;
  1630. /**
  1631. * Ends the document and calls the `onEnd` callback function.
  1632. */
  1633. end(): void;
  1634. /**
  1635. * Moves up to the parent node.
  1636. *
  1637. * _Alias:_ `u`
  1638. *
  1639. * @returns the document builder object
  1640. */
  1641. up(): XMLDocumentCB;
  1642. u(): XMLDocumentCB;
  1643. }
  1644. }