Element Details: Flattener
 Back


Available in: Logi Info Source code name: FlattenerIntroduced in: v11.2.040

Some data sources return information in hierarchical formats, which may contain multiple levels of parent-child relationships. This structure can be difficult for further processing, display and consumption.

The Flattener element "flattens" hierarchical data into the simpler tabular form of rows and columns, making the information usable for other elements.

Usage of Flattener is best described with some examples.

Consider this hierarchical document:

<Library commonName="Library of Congress">
<Book ID="B1" />
<Book ID="B2">
<Category name="Fiction" />
<Category name="Mystery" />
<PublishDate year="1900" />
<Author>John Doe</Author>
</Book>
<Book ID="3" >
<Category name="Nonfiction" />
</Book>
<Video ID="V1" />
</Library>

Flattener Definition (most basic, no options)
<Flattener />

Output
<dataLayer rdFlattenedElement="Book" ID="B1" />
<dataLayer rdFlattenedElement="Book" ID="B2" Author="John Doe"/>
<dataLayer rdFlattenedElement="Book" ID="B3" />


Flattener Definition (Row for each <Book>, with content from <Library>)
<Flattener
TopLevelXPath="." or “//Library"
DataRowElementName="Book" />

Output
<dataLayer rdFlattenedElement="Book" commonName="Library of Congress" ID="B1" />
<dataLayer rdFlattenedElement="Book" commonName="Library of Congress" ID="B2" name="Mystery" year="1900" Author="John Doe" />
<dataLayer rdFlattenedElement="Book" commonName="Library of Congress" ID="B3" name="Nonfiction" />

Flattener Definition (Row for both <Book> and <Video> elements)
<Flattener
TopLevelXPath="//Library"
DataRowElementName="Book,Video"
PullDeepAttributes="True"
PrependElementNames="True" />

Output
<dataLayer rdFlattenedElement="Book" Library_commonName="Library of Congress" Book_ID="B1" />
<dataLayer rdFlattenedElement="Book" Library_commonName="Library of Congress" Book_ID="B2" Category_name="Mystery" PublishDate_year="1900" Book_Author="John Doe" />
<dataLayer rdFlattenedElement="Book" Library_commonName="Library of Congress" Book_ID="B3" Category_name="Nonfiction" />
<dataLayer rdFlattenedElement="Video" Library_commonName="Library of Congress" Video_ID="V1 />

The Flattener adds an attribute to each output element, rdFlattenedElement, that indicates the original element's name.

Flattener Definition (Row for each <Category> and <PublishDate>, with content from <Book>)
<Flattener
TopLevelXPath="//Library/Book"
DataRowElementName="Category,PublishDate" />

<dataLayer rdFlattenedElement="Book" ID="B2" name="Fiction" Author="dave was here" />
<dataLayer rdFlattenedElement="Book" ID="B2" name="Mystery" Author="dave was here" />
<dataLayer rdFlattenedElement="Book" ID="B2" year="1900" Author="dave was here" />
<dataLayer rdFlattenedElement="Book" ID="B3" name="Nonfiction" />

Element Group:Organize Data





ATTRIBUTES

Click attribute Name to drill down for more information.

NamePossible ValuesDescription
BottomLevelElementName
UserDefined
BottomLevelElementName specifies the name of the element where the flattening should stop. The default is blank so flattening ends when at the lowest child level.
DataRowElementNames
UserDefined
By default, an output data row is produced for each child element of the root element. DataRowElementNames allows detailed specification of the input rows which should generate output rows. Specify the name of input elements which should trigger output rows. Multiple element names may be specified, comma-delimited.
ID
UserDefined
The ID attribute is a pervasive attribute that uniquely identifies an element within a definition file. The ID needs to be a unique value within the definition.
IgnoreDeepAttributes
True
False
By default, all attributes of elements which generate data rows are added to the output, even attributes from lower-level child elements. When True, those lower-level attributes are not copied.
IgnoreTextElements
True
False
By default text nodes (elements) are moved into attributes of their parent element. When True, text nodes are ignored.
PrependElementNames
True
False
Specifies whether the element name should be prepended to the attribute when flattened. For example, if this is set to the default value of True, will become . If it is set to False, it would output .
TopLevelXPath
UserDefined
This is an XPath query used to select the data set that the flattener element will work with. The default value is "*" which returns the entire data set. The Flattener flattens all of the data unless the BottomLevelElementName attribute is specified, which stops the Flattener from going deeper in the element tree.



PARENT ELEMENTS

Click element to drill down for more information.

DataLayer.JSON
DataLayer.Mongo Find
DataLayer.Mongo Map Reduce
DataLayer.Mongo Run Command
DataLayer.REST
DataLayer.Web Service
DataLayer.XML


CHILD ELEMENTS

Click element to drill down for more information.



 Back to top