Report an issue
Class

XmlDataProcessor (engine/dataprocessor)

@ckeditor/ckeditor5-engine/src/dataprocessor/xmldataprocessor

class

The XML data processor class. This data processor implementation uses XML as input and output data. This class is needed because unlike HTML, XML allows to use any tag with any value. For example, <link>Text</link> is a valid XML but invalid HTML.

Filtering

Properties

  • namespaces : DOMParser

    A list of namespaces allowed to use in the XML input.

    For example, registering namespaces [ 'attribute', 'container' ] allows to use <attirbute:tagName></attribute:tagName> and <container:tagName></container:tagName> input. It is mainly for debugging.

  • DOM converter used to convert DOM elements to view elements.

  • _domParser : DOMParser

    private

    DOM parser instance used to parse an XML string to an XML document.

  • A basic HTML writer instance used to convert DOM elements to an XML string. There is no need to use a dedicated XML writer because the basic HTML writer works well in this case.

Methods

  • constructor( options = { [options.namespaces] } )

    Creates a new instance of the XML data processor class.

    Parameters

    options : Object

    Configuration options.

    Properties
    [ options.namespaces ] : Array.<String>

    A list of namespaces allowed to use in the XML input.

    Defaults to []

  • toData( viewFragment ) → String

    Converts the provided document fragment to data format — in this case an XML string.

    Parameters

    viewFragment : DocumentFragment

    Returns

    String

    An XML string.

  • toView( data ) → Node | DocumentFragment | null

    Converts the provided XML string to a view tree.

    Parameters

    data : String

    An XML string.

    Returns

    Node | DocumentFragment | null

    A converted view element.

  • _toDom( data ) → DocumentFragment

    private

    Converts an XML string to its DOM representation. Returns a document fragment containing nodes parsed from the provided data.

    Parameters

    data : String

    Returns

    DocumentFragment