XmlCdata.d.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Copyright (C) 2016-2019 Michael Kourlas
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * The options used to create a CDATA section.
  18. */
  19. export interface IXmlCdataOptions {
  20. /**
  21. * The character data of the CDATA section.
  22. */
  23. charData: string;
  24. /**
  25. * Whether to replace any invalid characters in the character data of the
  26. * CDATA section with the Unicode replacement character. By default, this
  27. * is disabled.
  28. */
  29. replaceInvalidCharsInCharData?: boolean;
  30. }
  31. /**
  32. * Represents a CDATA section.
  33. *
  34. * A CDATA section is structured as follows, where `{data}` is the
  35. * character data of the section:
  36. *
  37. * ```xml
  38. * <![CDATA[{data}]]>
  39. * ```
  40. */
  41. export default class XmlCdata<Parent> {
  42. private readonly _replaceInvalidCharsInCharData;
  43. private readonly _parent;
  44. private readonly _validation;
  45. private _charData;
  46. constructor(parent: Parent, validation: boolean, options: IXmlCdataOptions);
  47. /**
  48. * Gets the character data of this CDATA section.
  49. */
  50. get charData(): string;
  51. /**
  52. * Sets the character data of this CDATA section.
  53. */
  54. set charData(charData: string);
  55. /**
  56. * Returns an XML string representation of this CDATA section.
  57. */
  58. toString(): string;
  59. /**
  60. * Returns the parent of this CDATA section.
  61. */
  62. up(): Parent;
  63. }