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.

XMLDeclaration.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Generated by CoffeeScript 2.4.1
  2. (function() {
  3. var NodeType, XMLDeclaration, XMLNode, isObject;
  4. ({isObject} = require('./Utility'));
  5. XMLNode = require('./XMLNode');
  6. NodeType = require('./NodeType');
  7. // Represents the XML declaration
  8. module.exports = XMLDeclaration = class XMLDeclaration extends XMLNode {
  9. // Initializes a new instance of `XMLDeclaration`
  10. // `parent` the document object
  11. // `version` A version number string, e.g. 1.0
  12. // `encoding` Encoding declaration, e.g. UTF-8
  13. // `standalone` standalone document declaration: true or false
  14. constructor(parent, version, encoding, standalone) {
  15. super(parent);
  16. // arguments may also be passed as an object
  17. if (isObject(version)) {
  18. ({version, encoding, standalone} = version);
  19. }
  20. if (!version) {
  21. version = '1.0';
  22. }
  23. this.type = NodeType.Declaration;
  24. this.version = this.stringify.xmlVersion(version);
  25. if (encoding != null) {
  26. this.encoding = this.stringify.xmlEncoding(encoding);
  27. }
  28. if (standalone != null) {
  29. this.standalone = this.stringify.xmlStandalone(standalone);
  30. }
  31. }
  32. // Converts to string
  33. // `options.pretty` pretty prints the result
  34. // `options.indent` indentation for pretty print
  35. // `options.offset` how many indentations to add to every line for pretty print
  36. // `options.newline` newline sequence for pretty print
  37. toString(options) {
  38. return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
  39. }
  40. };
  41. }).call(this);