Usage
This package helps with parsing NewsML articles created in the Digital Writer into a format that can be easily used by Everyware.
The package contains parsers corresponding to the various items and embeds that can be added in the Digital Writer. The goal is to add new parsers whenever there is support for new types of content in the Digital Writer. It can also be extended on a project level if the customer has their own Digital Writer plugins.
If you're not using everyware-resources and wish to make your own implementation see below for a quick guide on getting started.
Before you attempt to parse an item you need to instantiate your objectParsers. After you've instantiated your parsers you create a transformer by calling either
createTransformer
- For elements with tag idf
createObjectTransformer
- For elements with tag object
createMetaDataTransformer
- For elements with tag metadata
Returns an instance of NewsMLTransformer
that exposes the transform
function which takes an xml string as its argument.
Example:
Response:
All parsers return an array containing Item
or an extended class of Item
like TeaserItem
, ImageItem
or ContentPartItem
.
In addition to the default data some parsers modify the data or return additional data. Read description for more information of a each parsers behaviour.
ObjectParsers
|
|
|
ContentPartParser | x-im/content-part | |
HtmlEmbedParser | x-im/htmlembed | |
ImageGalleryParser | x-im/imagegallery | caption: elements data.text. |
ImageParser | x-im/image | Uses |
LinkObjectParser | x-im/link | |
MapEmbedParser | x-im/mapembed | |
PdfParser | x-im/pdf | If the elements link rel="self" it also includes the following properties. title: text, file: uri without 'im://pdf/' and url: |
ReviewParser | x-gm/review | text: html elements parsed through |
SocialEmbedParser | x-im/socialembed | content: data returned by |
TableParser | x-im/table | |
TeaserParser | x-im/teaser | links: Uses |
YouplayParser | x-im/youplay | thumb: if link type="image/jpg" uses |
YoutubeParser | x-im/youtube | uri: uri with 'watch?v=' replaced by 'embed/', thumb width, height and url. Is only set if link type="image/jpg". |
ContactinfoParser | x-im/contact-info | |
PersonParser | x-im/person | |
PolygonParser | x-im/polygon |
LinkParsers
|
|
|
ArticleLinkParser | x-im/article | Parse related links. Used by |
AuthorLinkParser | x-im/author | Parse author links. Used by |
CropLinkParser | x-im/crop | Parse crop links. Used by |
FacebookPageLinkParser | x-im/facebook-page | Parse Facebook page links. Used by |
FacebookPostLinkParser | x-im/facebook-post | Parse Facebook post links. Used by |
FacebookVideoLinkParser | x-im/facebook-video | Parse Facebook video links. Used by |
FocalPointLinkParser | x-im/focal-point | Parse focal-point links. Used by |
ImageLinkParser | x-im/image | Parse Image links. crop: if link rel="self" |
InstagramLinkParser | x-im/instagram | Parse Instagram links. embed_url: |
SoundcloudLinkParser | x-im/soundcloud | Parse Soundcloud links. Used by |
TwitterLinkParser | x-im/tweet | Parse Twitter links. Used by |
VimeoLinkParser | x-im/vimeo | Parse Vimeo links. Used by |
Tag Parsers These are the parsers that uses the parsers mentioned above. They take a xml block and loop over it and parsers each element according to its tag name.
|
|
|
ElementParser | element | Parses elements with element tag. Removes all elements which are not the following: |
GroupParser | group | Parses elements with group tag. Uses |
LinkParser | Accepts an array of LinkParsers. | |
IdfParser | Parses idf elements. Uses | |
ObjectParser | object | This parser accepts an array of parses that should be used to parse objects. |
MetaDataParser | metadata | Parses elements with metadata tag. Uses |
Last updated