Class BaseXMLUIParserAbstract

A bare-bones XML UI parser. This must not be used directly as this is an extensible parser; you are supported to create a subclass of this and add all the features/validators that you need.

You won't need to create your own parser unless you have an XML format that is not compatible with the default format. Most times it's enough to use XMLUIParser and register new features if necessary.

Hierarchy (view full)

Constructors

Properties

argumentModifiers: XMLArgumentModifier[] = ...

A list of functions that modify a factory's parameter list.

attributeNamespaceHandlers: Map<string, XMLAttributeNamespaceHandler> = ...

A map which assigns an attribute namespace to a handler function.

attributeValueDeserializers: Map<string, XMLAttributeValueDeserializer> = ...

A map which assigns a single character string prefix to a string deserializer.

domParser: DOMParser = ...

The DOMParser to actually parse the XML into nodes

elementDeserializers: Map<string, [elementDeserializer: XMLElementDeserializer, parameterMode: string]> = ...

A map which assigns an element name to a an XML element deserializer.

factories: Map<string, ((context: XMLUIParserContext, elem: Element) => Widget)> = ...

A map which assigns a factory function to an element name.

parameterModes: Map<string, [validator: null | XMLParameterModeValidator, canBeList: boolean, canBeOptional: boolean]> = ...

A map which defines custom parameter modes.

postInitHooks: XMLPostInitHook[] = ...

A list of functions that are invoked after a widget is instanced, so that the instance can be modified post-initialization.

validators: Map<string, WidgetAutoXMLConfigValidator> = ...

A map which assigns a validator function to a unique name, allowing a validator to be referred to by string. Referred to as built-in validators.

Methods

  • Auto-register a factory for a given widget. Instead of passing an input mapping and name, these are instead supplied in the Widget.autoXML field of the widget class. If it's null, an error is thrown.

    Type Parameters

    Parameters

    Returns void

  • Find the next unset parameter of a given mode.

    Parameters

    • paramConfig: WidgetXMLInputConfig

      The input mapping of the widget being built

    • parametersSet: boolean[]

      A list containing which of the parameters in the input mapping are already set

    • mode: string

      The parameter mode to find

    Returns number

    Returns the index of the next unset parameter of the wanted mode. If none are found, -1 is returned.

  • Parse a value in an attribute. The value will be deserialized according to its prefix. If there is no prefix, the value is treated as a string.

    Parameters

    • rawValue: string

      The value in the attribute, with the prefix included

    • context: XMLUIParserContext

      The current parser context, which will be passed to a deserializer if the value is prefixed with a registered deserializer prefix

    Returns unknown

  • Parse an XML string from a URL. BaseXMLUIParser#parseFromString will be called.

    Parameters

    • resource: URL | RequestInfo

      The URL to download the XML from

    • Optionalconfig: XMLUIParserConfig

      The configuration object to use for the parser

    • OptionalrequestOptions: RequestInit

      Options to use for the HTTP request

    Returns Promise<[Map<string, Widget>, XMLUIParserContext]>

    Returns a pair containing, respectively, a Map which maps a UI tree name to a widget, and the parser context after all UI trees are parsed. Returned asynchronously as a promise

  • Parse an XML document which can contain multiple descendants.

    Parameters

    • xmlDoc: XMLDocument

      The XML document to parse

    • Optionalconfig: XMLUIParserConfig

      The configuration object to use for the parser

    Returns [Map<string, Widget>, XMLUIParserContext]

    Returns a pair containing, respectively, a Map which maps a UI tree name to a widget, and the parser context after all UI trees are parsed

  • Parse a element. Expected to contain at least one widget element, and can contain