Nutritious Pancake Mountain


    1.5.1 • Public • Published


    Used to parse "standard" XMPP pubsub payloads both from XML→JSON, and build stanzas JSON→XML.

    Takes XML in the form of ltx objects and parses these down to JSON. Alternatively its builds ltx objects (XML) from JSON objects.

    Build status

    Build Status

    Coverage Status


    $ npm i --save xmpp-ftw-item-parser



    It is possible to configure this component to only enable parsers for the formats you wish to handle in your application. A set of common parsers are enabled by default but some will need to be enabled depending on the needs of your application.

    The following example shows how to add the IODEF parser to the standard set of enabled parsers:


    Removing a parser from the set of enabled parsers is equally simple:


    The full list of available parsers is available from parser.availableParsers.

    As well as adding and removing individual parsers you are also able to define a list of parsers to add in a single call. The following example replaces the default set of parsers with the JSON and IODEF parsers.

    parser.setParsers([parser.availableParsers.json, parser.availableParsers.iodef])

    You can, if you wish, remove all parsers from the list of enabled parsers using the following call:



    The IODEF parser will translate between XML and JSON in both directions. The following JSON and XML documents represent the complete set of elements and attributes currently supported:

    <IODEF-Document version="1.00" lang="en" formatid="simulation" xmlns="urn:ietf:params:xml:ns:iodef-1.0">
    <Incident purpose="ext-value" ext-purpose="new-purpose" lang="en" restriction="need-to-know">
        <IncidentID name="" instance="5" restriction="private">189493</IncidentID>
        <Assessment occurrence="actual" restriction="private">
            <Impact lang="en" severity="medium" completion="succeeded" type="ext-value" ext-type="new-type">
                A new type of attack has taken all of our printers offline.
        <Contact role="ext-value" ext-role="new-role" type="ext-value" ext-type="new-type" restriction="public">
            <ContactName>Bill Folds</ContactName>
            <Email meaning="IRT group address, manned Mon-Fri 9-5 UTC"></Email>
        "IODEF-Document" : {
            "version" : "1.00",
            "lang" : "en",
            "formatid" : "simulation",
            "Incidents" : [{
                "purpose" : "ext-value",
                "ext-purpose" : "new-purpose",
                "lang" : "en",
                "restriction" : "need-to-know",
                "IncidentID" : {
                    "IncidentID" : "189493",
                    "name" : "",
                    "instance" : "5",
                    "restriction" : "private"
                "ReportTime" : {"ReportTime" : "2014-03-27T12:39:24+00:00"},
                "Assessments" : [{
                    "occurrence" : "actual",
                    "restriction" : "private",
                    "Impacts" : [{
                        "lang" : "en",
                        "severity" : "medium",
                        "completion" : "succeeded",
                        "type" : "ext-value",
                        "ext-type" : "new-type",
                        "Impact" : "A new type of attack has taken all of our printers offline."
                "Contacts" : [{
                    "role" : "ext-value",
                    "ext-role" : "new-role",
                    "type" : "ext-value",
                    "ext-type" : "new-type",
                    "restriction" : "public",
                    "ContactName" : {"ContactName" : "Bill Folds"},
                    "Emails" : [{
                        "meaning" : "IRT group address, manned Mon-Fri 9-5 UTC",
                        "Email" : ""

    Note that support is provided for multiple elements where permitted by the specification (currently Incident, Assessment, Impact, Contact, Email).

    The following example shows how an XML IODEF document can be parsed into JSON:

    var iodefXml = '' +
        '<IODEF-Document'  +
            ' version="' + iodef.VERSION_IODEF + '"' +
            ' lang="en"'+
            ' formatid="simulation"' +
            ' xmlns="' + iodef.NS_IODEF +
        '">' +
        '<Incident purpose="ext-value" ext-purpose="new-purpose" lang="en" restriction="need-to-know">' +
            '<IncidentID name="" instance="5" restriction="private">189493</IncidentID>' +
            '<ReportTime>2014-03-27T12:39:24+00:00</ReportTime>' +
            '<Assessment occurrence="actual" restriction="private">' +
                '<Impact lang="en" severity="medium" completion="succeeded" type="ext-value" ext-type="new-type">' +
                    'A new type of attack has taken all of our printers offline.' +
                '</Impact>' +
            '</Assessment>' +
            '<Contact role="ext-value" ext-role="new-role" '  +
                        'type="ext-value" ext-type="new-type" restriction="public">' +
                '<ContactName>Bill Folds</ContactName>' +
                '<Email meaning="IRT group address, manned Mon-Fri 9-5 UTC"></Email>' +
            '</Contact>' +
        '</Incident>' +
    var iodefJson = parser.parse(iodefXml)

    The following example shows how IODEF in JSON format can be built into a valid IODEF XML document:

    var iodefJson = {
        'IODEF-Document': {
            version: iodef.VERSION_IODEF,
            lang: 'en',
            formatid: 'simulation',
            Incidents: [{
                purpose: 'ext-value',
                'ext-purpose': 'new-purpose',
                lang: 'en',
                restriction: 'need-to-know',
                IncidentID: {
                    IncidentID: '189493',
                    name: '',
                    instance: '5',
                    restriction: 'private',
                ReportTime: {ReportTime:'2014-03-27T12:39:24+00:00'},
                Assessments: [{
                    occurrence : 'actual',
                    restriction : 'private',
                    Impacts: [{
                        lang: 'en',
                        severity: 'medium',
                        completion: 'succeeded',
                        type: 'ext-value',
                        'ext-type': 'new-type',
                        Impact: 'A new type of attack has taken all of our printers offline.',
                Contacts: [{
                    role: 'ext-value',
                    'ext-role': 'new-role',
                    type: 'ext-value',
                    'ext-type': 'new-type',
                    restriction: 'public',
                    ContactName: {ContactName:'Bill Folds'},
                    Emails: [{
                        meaning: 'IRT group address, manned Mon-Fri 9-5 UTC',
                        Email: '',
    var elementToBuildInto = ltx.parse('<item/>')
    var iodefXml =, elementToBuildInto)


    • The atom builder does not currently build the 'rights' element. If you require this please raise an issue or, better still, send me a pull request

    • Support for IODEF is limited to a minimal set of elements. The implementation currently supports the IODEF-Document element and all of its attributes along with the following sub-elements, including all of their attributes:

      • Incident
        • IncidentID
        • ReportTime
      • Assessment
        • Impact
      • Contact
        • ContactName
        • Email


    npm i xmpp-ftw-item-parser

    DownloadsWeekly Downloads





    Apache 2.0

    Last publish


    • lloydwatkin