BaseParseOptions

import { BaseParseOptions } from "jsr:@ende/xml";

interface

interface BaseParseOptions

Base options shared by parsing functions.

Properties

ignoreWhitespace

readonly ignoreWhitespace?: boolean

If true, text nodes containing only whitespace are not emitted/included.

Default: false

ignoreComments

readonly ignoreComments?: boolean

If true, comments are not emitted/included.

Default: false

trackPosition

readonly trackPosition?: boolean

If true, track line/column positions for events and error messages. Disabling improves performance but makes debugging harder.

disallowDoctype

readonly disallowDoctype?: boolean

If true, DOCTYPE declarations are rejected immediately with an XmlSyntaxError, before any internal subset is parsed. This prevents resource exhaustion attacks via hostile DTD content.

Set to false to tolerate DOCTYPE declarations in trusted input (e.g. legacy XHTML or RSS feeds). DTD contents are still not processed: custom entity declarations are ignored, and external DTDs are never fetched.

Default: true

maxDepth

readonly maxDepth?: number

Maximum element nesting depth. Exceeding this throws XmlSyntaxError. Prevents stack exhaustion from deeply nested documents.

Default: Infinity

maxAttributes

readonly maxAttributes?: number

Maximum number of attributes per element. Exceeding this throws XmlSyntaxError. Prevents memory exhaustion from elements with huge attribute lists.

Default: Infinity

xmlVersion

readonly xmlVersion?: "1.0" | "1.1"

XML version to use for character and line-ending validation.

When "1.1", the parser applies XML 1.1 rules:

  • Character references to C0 controls (– except �) are accepted
  • Literal C1 controls (#x7F–#x9F except #x85) are rejected
  • NEL (#x85) and Unicode line separator (#x2028) are normalized to LF
  • Namespace prefix unbinding (xmlns:prefix="") is allowed

This option is independent of the <?xml version="..."> declaration in the document. Set it explicitly to handle documents that declare version="1.0" but contain XML 1.1-style character references.

Default: "1.0"

Source