index.d.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // Type definitions for xmlbuilder
  2. // Project: https://github.com/oozcitak/xmlbuilder-js
  3. // Definitions by: Wallymathieu <https://github.com/wallymathieu>
  4. // : GaikwadPratik <https://github.com/GaikwadPratik>
  5. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  6. export = xmlbuilder;
  7. declare namespace xmlbuilder {
  8. class XMLDocType {
  9. clone(): XMLDocType;
  10. element(name: string, value?: Object): XMLDocType;
  11. attList(elementName: string, attributeName: string, attributeType: string, defaultValueType?: string, defaultValue?: any): XMLDocType;
  12. entity(name: string, value: any): XMLDocType;
  13. pEntity(name: string, value: any): XMLDocType;
  14. notation(name: string, value: any): XMLDocType;
  15. cdata(value: string): XMLDocType;
  16. comment(value: string): XMLDocType;
  17. instruction(target: string, value: any): XMLDocType;
  18. root(): XMLDocType;
  19. document(): any;
  20. toString(options?: XMLToStringOptions, level?: Number): string;
  21. ele(name: string, value?: Object): XMLDocType;
  22. att(elementName: string, attributeName: string, attributeType: string, defaultValueType?: string, defaultValue?: any): XMLDocType;
  23. ent(name: string, value: any): XMLDocType;
  24. pent(name: string, value: any): XMLDocType;
  25. not(name: string, value: any): XMLDocType;
  26. dat(value: string): XMLDocType;
  27. com(value: string): XMLDocType;
  28. ins(target: string, value: any): XMLDocType;
  29. up(): XMLDocType;
  30. doc(): any;
  31. }
  32. class XMLElementOrXMLNode {
  33. // XMLElement:
  34. clone(): XMLElementOrXMLNode;
  35. attribute(name: any, value?: any): XMLElementOrXMLNode;
  36. att(name: any, value?: any): XMLElementOrXMLNode;
  37. removeAttribute(name: string): XMLElementOrXMLNode;
  38. instruction(target: string, value: any): XMLElementOrXMLNode;
  39. instruction(array: Array<any>): XMLElementOrXMLNode;
  40. instruction(obj: Object): XMLElementOrXMLNode;
  41. ins(target: string, value: any): XMLElementOrXMLNode;
  42. ins(array: Array<any>): XMLElementOrXMLNode;
  43. ins(obj: Object): XMLElementOrXMLNode;
  44. a(name: any, value?: any): XMLElementOrXMLNode;
  45. i(target: string, value: any): XMLElementOrXMLNode;
  46. i(array: Array<any>): XMLElementOrXMLNode;
  47. i(obj: Object): XMLElementOrXMLNode;
  48. toString(options?: XMLToStringOptions, level?: Number): string;
  49. // XMLNode:
  50. element(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  51. ele(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  52. insertBefore(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  53. insertAfter(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  54. remove(): XMLElementOrXMLNode;
  55. node(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  56. text(value: string): XMLElementOrXMLNode;
  57. cdata(value: string): XMLElementOrXMLNode;
  58. comment(value: string): XMLElementOrXMLNode;
  59. raw(value: string): XMLElementOrXMLNode;
  60. declaration(version: string, encoding: string, standalone: boolean): XMLElementOrXMLNode;
  61. doctype(pubID: string, sysID: string): XMLDocType;
  62. up(): XMLElementOrXMLNode;
  63. importDocument(input: XMLElementOrXMLNode): XMLElementOrXMLNode;
  64. root(): XMLElementOrXMLNode;
  65. document(): any;
  66. end(options?: XMLEndOptions): string;
  67. prev(): XMLElementOrXMLNode;
  68. next(): XMLElementOrXMLNode;
  69. nod(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  70. txt(value: string): XMLElementOrXMLNode;
  71. dat(value: string): XMLElementOrXMLNode;
  72. com(value: string): XMLElementOrXMLNode;
  73. doc(): XMLElementOrXMLNode;
  74. dec(version: string, encoding: string, standalone: boolean): XMLElementOrXMLNode;
  75. dtd(pubID: string, sysID: string): XMLDocType;
  76. e(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  77. n(name: any, attributes?: Object, text?: any): XMLElementOrXMLNode;
  78. t(value: string): XMLElementOrXMLNode;
  79. d(value: string): XMLElementOrXMLNode;
  80. c(value: string): XMLElementOrXMLNode;
  81. r(value: string): XMLElementOrXMLNode;
  82. u(): XMLElementOrXMLNode;
  83. }
  84. interface XMLDec {
  85. version?: string;
  86. encoding?: string;
  87. standalone?: boolean;
  88. }
  89. interface XMLDtd {
  90. pubID?: string;
  91. sysID?: string;
  92. }
  93. interface XMLStringifier {
  94. [x: string]: ((v: any) => string) | string;
  95. }
  96. interface XMLWriter {
  97. [x: string]: ((e: XMLElementOrXMLNode, options: WriterOptions, level?: number) => void);
  98. }
  99. interface XMLCreateOptions {
  100. headless?: boolean;
  101. keepNullNodes?: boolean;
  102. keepNullAttributes?: boolean;
  103. ignoreDecorators?: boolean;
  104. separateArrayItems?: boolean;
  105. noDoubleEncoding?: boolean;
  106. stringify?: XMLStringifier;
  107. }
  108. interface XMLToStringOptions {
  109. pretty?: boolean;
  110. indent?: string;
  111. offset?: number;
  112. newline?: string;
  113. allowEmpty?: boolean;
  114. spacebeforeslash?: string;
  115. }
  116. interface XMLEndOptions extends XMLToStringOptions {
  117. writer?: XMLWriter;
  118. }
  119. interface WriterOptions {
  120. pretty?: boolean;
  121. indent?: string;
  122. newline?: string;
  123. offset?: number;
  124. allowEmpty?: boolean;
  125. dontPrettyTextNodes?: boolean;
  126. spaceBeforeSlash?: string | boolean;
  127. user? :any;
  128. state?: WriterState;
  129. }
  130. enum WriterState {
  131. None = 0,
  132. OpenTag = 1,
  133. InsideTag = 2,
  134. CloseTag = 3
  135. }
  136. function create(nameOrObjSpec: string | { [name: string]: Object }, xmldecOrOptions?: XMLDec | XMLCreateOptions, doctypeOrOptions?: XMLDtd | XMLCreateOptions, options?: XMLCreateOptions): XMLElementOrXMLNode;
  137. function begin(): XMLElementOrXMLNode;
  138. }