saxes.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. declare namespace saxes {
  2. export const EVENTS: ReadonlyArray<string>;
  3. export interface SaxesOptions {
  4. xmlns?: boolean;
  5. position?: boolean;
  6. fragment?: boolean;
  7. fileName?: string;
  8. additionalNamespaces?: Record<string, string>;
  9. }
  10. export interface XMLDecl {
  11. version?: string;
  12. encoding?: string;
  13. standalone?: string;
  14. }
  15. export interface SaxesAttribute {
  16. name: string;
  17. prefix: string;
  18. local: string;
  19. uri: string;
  20. value: string;
  21. }
  22. export interface SaxesTag {
  23. name: string;
  24. prefix: string;
  25. local: string;
  26. uri: string;
  27. attributes: Record<string, SaxesAttribute> | Record<string, string>;
  28. ns: Record<string, string>;
  29. isSelfClosing: boolean;
  30. }
  31. export class SaxesParser {
  32. constructor(opt: SaxesOptions);
  33. readonly opt: SaxesOptions;
  34. readonly closed: boolean;
  35. readonly xmlDecl: XMLDecl;
  36. readonly line: number;
  37. readonly column: number;
  38. readonly position: number;
  39. readonly ENTITIES: Record<string, string>;
  40. ontext(text: string): void;
  41. onprocessinginstruction(pi: { target: string, body: string }): void;
  42. ondoctype(doctype: string): void;
  43. oncomment(comment: string): void;
  44. onopentagstart(tag: SaxesTag): void;
  45. onopentag(tag: SaxesTag): void;
  46. onclosetag(tag: SaxesTag): void;
  47. oncdata(cdata: string): void;
  48. onend(): void;
  49. onready(): void;
  50. onerror(err: Error): void;
  51. fail(er: Error): this;
  52. write(chunk: string | null): this;
  53. close(): this;
  54. resolve(prefix: string): string | undefined;
  55. }
  56. }
  57. export = saxes;