Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This example parses an XML record received in the "body" field of the input record following the xPathMappings for each field name. The output structured record will be created using the type specified for each field in the "fieldTypeMapping". Only years and prices will be passed on for books with a price over 35.00:

...

Property

Value

Input field to parse as an XML record

body

XML encoding

UTF-8

XPath Mappings

Code Block
category://book/@category

...


...

title://book/title

...


...

year:/bookstore/book[price>35.00]/year,

...


...

price:/bookstore/book[price>35.00]/price,

...


...

subcategory://book/subcategory

...

Field Name Schema Type Mapping

Code Block
category:string 
title:string
year:int
price:double
subcategory:string

Error handling

Ignore error and continue

For example, suppose the transform receives these input records:

...

offset

body

1

<bookstore><book category="cooking"><subcategory><type>Continental</type><genre>European

...

cuisines</genre></subcategory><title

...

lang="en">Everyday

...

Italian</title><author>Giada

...

DeLaurentiis</author><year>2005</year><price>30.00</price></book></bookstore>

...

2

<bookstore><book category="children"><subcategory><type>Series</type><genre>fantasy

...

literature</genre></subcategory><title

...

lang="en">Harry

...

Potter</title><author>J.

...

K.

...

Rowling</author><year>2005</year><price>49.99</price></book></bookstore>

...

The output records will contain:

...

category

title

year

price

subcategory

cooking

Everyday Italian

null

null

<subcategory><type>Continental</type><genre>European cuisines</genre></subcategory>

children

Harry Potter

2005

49.99

<subcategory><type>Series</type><genre>fantasy literature</genre></subcategory>

Here, since the subcategory contains child nodes, the plugin will return the complete subcategory node (along with its child elements) as string as <subcategory><type>Continental</type><genre>European cuisines</genre></subcategory> . This is to ensure that the plugin returns a single XML event for a structured record instead of the two child events: <type>Continental</type> and <genre>European cuisines</genre>.

...