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.
$ 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
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.
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:
1894932014-03-27T12:39:24+00:00A new type of attack has taken all of our printers offline.Bill Foldscontact@cert.example.com
Note that support is provided for multiple elements where permitted by the specification (currently
The following example shows how an XML IODEF document can be parsed into JSON:
var iodefXml = '' +'<IODEF-Document' +' version="' + iodefVERSION_IODEF + '"' +' lang="en"'+' formatid="simulation"' +' xmlns="' + iodefNS_IODEF +'">' +'<Incident purpose="ext-value" ext-purpose="new-purpose" lang="en" restriction="need-to-know">' +'<IncidentID name="cert.example.com" 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">firstname.lastname@example.org</Email>' +'</Contact>' +'</Incident>' +'</IODEF-Document>'parservar iodefJson = parser
The following example shows how IODEF in JSON format can be built into a valid IODEF XML document:
var iodefJson ='IODEF-Document':version: iodefVERSION_IODEFlang: 'en'formatid: 'simulation'Incidents:purpose: 'ext-value''ext-purpose': 'new-purpose'lang: 'en'restriction: 'need-to-know'IncidentID:IncidentID: '189493'name: 'cert.example.com'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: 'email@example.com'var elementToBuildInto = ltxvar iodefXml = parser
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: