Skip to content

Commit

Permalink
Add Pretty Print XML Example (#108)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandar Aytov <[email protected]>
  • Loading branch information
alexaytov and aleks-aytov authored Jul 16, 2024
1 parent ac9f319 commit bc2119c
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ After importing, you'll see a new catalog tile - **Automation Pilot Examples**.
|---------|-------------|
| [Transform Data](transform-data) | Transform Data between different formats - JSON, XML, YAML, and CSV |
| [Trigger and Collect Outputs Batching](trigger-and-collect-outputs-batching) | Trigger Multiple Executions in Batches and Collect their Outputs |
| [Pretty Print XML](pretty-print-xml) | Pretty Print XML Data |

## Resources

Expand Down
25 changes: 25 additions & 0 deletions pretty-print-xml/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Pretty Print XML

Table of Contents

* [Description](#description)
* [Requirements](#requirements)
* [How to use](#how-to-use)
* [Expected result](#expected-result)

## Description

The command uses a python script to pretty print xml.

## Requirements

There are no requirements to use this command.

## How to use

1. Trigger the PrettyPrintXml command
2. Enter the XML you want to pretty print in the required input key `xml`

## Expected result

The expected result is to receive the pretty printed XML in the `xml` output key.
70 changes: 70 additions & 0 deletions pretty-print-xml/catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"id": "examples-<<<TENANT_ID>>>",
"technicalName": "examples",
"name": "Automation Pilot Examples",
"description": "Source: https://github.com/SAP-samples/automation-pilot-examples",
"owner": "<<<TENANT_ID>>>",
"inputs": [],
"commands": [
{
"configuration": {
"values": [],
"output": {
"xml": "$(.prettyPrintXml.output.output | filter(length != 0 and . != \"\\t\" and . != \"\\t\\t\") | join(\"\\n\"))"
},
"executors": [
{
"execute": "scripts-sapcp:ExecuteScript:2",
"input": {
"environment": "{\"XML\":\"$(.execution.input.xml | toEscapedJson)\"}",
"script": "printf \"%s\" \"${XML}\" > data.xml\n\necho 'import xml.dom.minidom\n\ndom = xml.dom.minidom.parse(\"data.xml\")\npretty_xml_as_string = dom.toprettyxml()\nprint(pretty_xml_as_string)\n' > program.py\n\npython3 program.py"
},
"alias": "prettyPrintXml",
"description": null,
"progressMessage": null,
"initialDelay": null,
"pause": null,
"when": null,
"validate": null,
"autoRetry": null,
"repeat": null,
"errorMessages": [],
"dryRun": null
}
],
"listeners": []
},
"id": "examples-<<<TENANT_ID>>>:PrettyPrintXml:1",
"name": "PrettyPrintXml",
"description": null,
"catalog": "examples-<<<TENANT_ID>>>",
"version": 1,
"inputKeys": {
"xml": {
"type": "string",
"sensitive": false,
"required": true,
"minSize": null,
"maxSize": null,
"minValue": null,
"maxValue": null,
"allowedValues": null,
"allowedValuesFromInputKeys": null,
"suggestedValues": null,
"suggestedValuesFromInputKeys": null,
"defaultValue": null,
"defaultValueFromInput": null,
"description": null
}
},
"outputKeys": {
"xml": {
"type": "string",
"sensitive": false,
"description": null
}
},
"tags": {}
}
]
}

0 comments on commit bc2119c

Please sign in to comment.