| //// |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| //// |
| :documentationPath: /plugins/transforms/ |
| :language: en_US |
| :page-alternativeEditUrl: https://github.com/apache/incubator-hop/edit/master/plugins/transforms/xml/src/main/doc/addxml.adoc |
| = Add XML |
| |
| == Description |
| |
| The Add XML transform allows you to encode the content of a number of fields in a row in XML. This XML is added to the row in the form of a String field. |
| |
| |
| == Options |
| |
| === Content Tab |
| |
| [width="90%", options="header"] |
| |=== |
| |Option|Description |
| |Transform name|Name of the transform. |
| |Encoding|The encoding to use; this encoding is specified in the header of the XML file |
| |Output Value|The name of the new field that contains the XML |
| |Root XML element|The name of the root element in the generated element |
| |Omit XML header|Enable to not include the XML header in the output. |
| |Omit null values from the XML result|Do not add elements or attributes with null values. This is often used to limit the size of the target XML. |
| |=== |
| |
| === Fields Tab |
| |
| The Fields tab is where you configure the output fields and their formats. The table below describes each of the available properties for a field. |
| |
| [width="90%", options="header"] |
| |=== |
| |Option|Description |
| |Fieldname|Name of the field |
| |Element name|The name of the element in the XML file to use |
| |Type|Type of the field can be either String, Date, or Number |
| |Format|Format mask with which to convert data; see Number Formats for a complete description of format specifiers |
| |Length|Output string is padded to this length if it is specified |
| |Precision|The precision to use |
| |Currency|Symbol used to represent currencies like $10,000.00 or E5.000,00 |
| |Decimal|A decimal point can be a "." (10,000.00) or "," (5.000,00) |
| |Grouping|A grouping can be a "," (10,000.00) or "." (5.000,00) |
| |Null|The string to use in case the field value is null. |
| |Attribute|Make this an attribute (N means : element) |
| |Attribute parent name|You can specify the name of the parent element to add the attribute to if previous parameter attribute is set to Y. |
| If no parent name is specified, the attribute is set in the parent element. |
| |=== |
| |
| == Use case |
| |
| Below is data that comes in a variety of classes and which needs to be stored as XML in a database. You want to turn the raw data into the database layout below. |
| |
| === Raw data |
| |
| [width="90%", options="header"] |
| |=== |
| |Shape|Colour|Id|X|Y|Radius |
| |circle|blue|1|3|5|5 |
| |circle|red|2|1|3|5 |
| |circle|blue|5|5|9|5 |
| |circle|blue|6|8|2|5 |
| |circle|red|7|9|7|5 |
| |=== |
| |
| [width="90%", options="header"] |
| |=== |
| |Shape|Colour|Id|X|Y|Length|Width |
| |rectangle|blue|3|3|1|6|4 |
| |rectangle|red|6|2|4|6|4 |
| |rectangle|blue|10|8|2|6|4 |
| |rectangle|red|12|7|8|6|4 |
| |rectangle|blue|14|5|2|6|4 |
| |=== |
| |
| === Output Sample |
| |
| [width="90%", options="header"] |
| |=== |
| |Id|X|Y|Class data |
| |3|4|7|<SHAPE type="circle"><COLOUR>blue</COLOUR><RADIUS> 5</RADIUS></SHAPE> |
| |1|6|3|<SHAPE type="rectangle"><COLOUR>blue</COLOUR><WIDTH> 4</WIDTH><LENGTH> 6</LENGTH></SHAPE> |
| |2|8|8|<SHAPE type="rectangle"><COLOUR>blue</COLOUR><WIDTH> 4</WIDTH><LENGTH>6</LENGTH></SHAPE> |
| |5|5|2|<SHAPE type="circle"><COLOUR>blue</COLOUR><RADIUS> 5</RADIUS></SHAPE> |
| |=== |
| |
| == Metadata Injection Support |
| |
| All fields of this transform support metadata injection. You can use this transform with ETL Metadata Injection to pass metadata to your pipeline at runtime. |