Transform XSLT
Allows to do an XSLT transformation. An XSLT transformation allows to switch from one XML format to another file format among XML, CSV, TXT, JSON or HTML.
For example, you need to transform an xml file to the standard xml file of Product-Live, or you need to transform the standard xml output file of Product-Live to a specific format.
Json
Example
json
{
"name": "file-transformation-xslt",
"taskReferenceName": "transform_xslt",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"mode": "FILE",
"file": "${previous_taskReferenceName.output.file}",
"xslt": "file://assets/transform.xslt",
"fileName": "result.xml"
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
json
{
"name": "file-transformation-xslt",
"taskReferenceName": "transform_xslt",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"mode": "FILES",
"files": "${previous_taskReferenceName.output.files}",
"xslt": "file://assets/transform.xslt",
"fileName": "result.xml"
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
json
{
"name": "file-transformation-xslt",
"taskReferenceName": "transform_xslt",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"mode": "FILE",
"file": "${previous_taskReferenceName.output.file}",
"xslt": "file://assets/transform.xslt",
"params": [
{
"name": "color",
"select": "red"
},
{
"name": "settings",
"select": "file://assets/settings.xml"
},
{
"name": "items",
"select": "${previous_taskReferenceName.output.file}"
},
{
"name": "language",
"select": "${workflow.input.language}"
}
],
"fileName": "result.xml"
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Definition
| Property | Type | Required | Description |
|---|---|---|---|
| The name (or type) of the task | |||
| The unique name of the task in your job. It is used to reference this task in the workflow. | |||
| The functional description of this task in your job. | |||
The type of the task. It must be SUB_WORKFLOW. | |||
| : | true: the job continues if there is an error on this task. false: the job fails. | ||
| Input parameters of the task. See below |
Inputs
| Property | Type | Required | Description |
|---|---|---|---|
| : | FILE: transform the file input. FILES: transform each file of the files input. REQUEST: transform each file listed in the request document. | ||
It can reference the output of a previous task, example: ${previous_taskReferenceName.output.file} , or a static file, example: file://assets/file.xml, or a user input, example: ${workflow.input.input_key}. | |||
It can reference the output of a previous task, example: ${previous_taskReferenceName.output.files} , or a user input, example: ${workflow.input.input_key}. | |||
| The XLST file. Usually a static file in the assets folder. | |||
Allows to pass parameters to your XSLT. Then parameters are accessible within the element <xsl:param name="" /> of your xslt, where the name you used is the name of the parameter. If you need to pass a static string, the string must be encapsulated in simple quotes. It can also reference the output of a previous task, example: ${previous_taskReferenceName.output.file} , or a static file, example: file://assets/file.xml, or a user input, example: ${workflow.input.input_key}. | |||
| A file listing the documents to transform. See the definition below. | |||
| : | optional | Only taken into account when mode = FILE. Defaults to FILE. With STRING, the transformation is returned in the result output instead of being written to a file. | |
The output file name. In FILES and REQUEST modes an index is appended to it - see below. | |||
| : | Default: falseWhen set to true, the report generation is skipped and thus the report is not available in the output parameters. | ||
| : | Default: info It defines the log level to be recorded in the report. error < warning < info < debug |
Outputs
| Property | Type | Description |
|---|---|---|
| file | The first transformation result. Present in every mode. | |
| files | All transformation results, in every mode - see the note below. | |
| listing | An XML file containing the urls of the generated temporary files. | |
| result | The transformation as a string. Only when mode = FILE and output = STRING; in that case no file is produced. | |
| allFilesTransformed | YES | NO. YES: all files have been transformed. NO: at least one file has an error. |
files holds only the transformations that succeeded, in the order of the input (the files array, or the File elements of the request document), and file is its first entry. A file that fails is left out, allFilesTransformed becomes NO, and the reason is written to the report - the task itself still completes, so read allFilesTransformed rather than the task status.
In FILES and REQUEST modes the outputs are named after fileName with their position appended before the extension and without a separator: with fileName = products.xml you get products1.xml, products2.xml, and so on.
Input request
Used when mode = REQUEST. Each File names a document to transform and the name its result must take.
xml
<Xslt>
<File>
<Url>https://app.product-live.com/files-data-factory/2345...bcde</Url>
<File-Name>products-1.xml</File-Name>
</File>
<File>
<Url>https://app.product-live.com/files-data-factory/1234...abcd</Url>
<File-Name>products-2.xml</File-Name>
</File>
</Xslt>1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
| XPath | Description | Occurs |
|---|---|---|
Xslt | Root of the document | 1 |
./File | For each file to transform | 0..* |
./File/Url | The url of the file to transform. It can come from a previous task, from the job assets, or be a public url. | 1 |
./File/File-Name | The name to give to the output of this transformation. | 1 |
Output listing
Example
xml
<Files>
<File>
<Url>https://app.product-live.com/files-data-factory/3456...cdef</Url>
<File-Name>product-1.xml</File-Name>
</File>
<File>
<Url>https://app.product-live.com/files-data-factory/6789...f012</Url>
<File-Name>product-2.xml</File-Name>
</File>
</Files>1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Limits and additional notes
- The limitation of the input file size is 500 Mb.
In addition to these limitations, the following practices are recommended:
- Optimize your xslt by applying xslt best practices, e.g. never call the same xpath twice.
- Before developing your own xslt function, check that it doesn't already exist: http://www.xsltfunctions.com/.
FAQ
What is the version of the XSLT processor?
You can use XSLT 1.0 or 2.0 or 3.0 or 3.1.