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.

XMLDTDElement.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Generated by CoffeeScript 2.4.1
  2. (function() {
  3. var NodeType, XMLDTDElement, XMLNode;
  4. XMLNode = require('./XMLNode');
  5. NodeType = require('./NodeType');
  6. // Represents an attribute
  7. module.exports = XMLDTDElement = class XMLDTDElement extends XMLNode {
  8. // Initializes a new instance of `XMLDTDElement`
  9. // `parent` the parent `XMLDocType` element
  10. // `name` element name
  11. // `value` element content (defaults to #PCDATA)
  12. constructor(parent, name, value) {
  13. super(parent);
  14. if (name == null) {
  15. throw new Error("Missing DTD element name. " + this.debugInfo());
  16. }
  17. if (!value) {
  18. value = '(#PCDATA)';
  19. }
  20. if (Array.isArray(value)) {
  21. value = '(' + value.join(',') + ')';
  22. }
  23. this.name = this.stringify.name(name);
  24. this.type = NodeType.ElementDeclaration;
  25. this.value = this.stringify.dtdElementValue(value);
  26. }
  27. // Converts the XML fragment to string
  28. // `options.pretty` pretty prints the result
  29. // `options.indent` indentation for pretty print
  30. // `options.offset` how many indentations to add to every line for pretty print
  31. // `options.newline` newline sequence for pretty print
  32. toString(options) {
  33. return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
  34. }
  35. };
  36. }).call(this);