Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 7ae9a0c

Browse files
author
Pablo Mercado
authored
Merge pull request #146 from triggermesh/task/update-infrajs-xml
Add InfraJS XML support
2 parents 2b47b93 + 3fbcadd commit 7ae9a0c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/targets/infrajs.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ The JS Script field must include a function named `handle` with a single paramet
3838
- `id` will be set to the incoming value.
3939
- `datacontenttype` will default to `application/json`.
4040

41+
### XML Support
42+
43+
InfraJS scripting does not support any XML library and cannot manipulate XML. However under certain circunstances XML can be used to create outgoing events:
44+
45+
- Incoming event `data` element must contain a valid XML element
46+
- `datacontenttype` attribute, which is `Content-Type` HTTP header, must be set to either `application/xml` or `text/xml`
47+
48+
In such cases the XML data is converted to JSON element by element. If XML attributes are present the element is rendered using prefixes:
49+
50+
- An attribute will be rendered as a chile JSON element prepended with `-`
51+
- An element that contains attributes and also text, will render the text on a `#text` element.
52+
53+
For example:
54+
- incoming event `<A><B>B value</B><C attr="C attr">C Value</C></A>`
55+
- will be avaliable as `{"A":{"B":"B value","C":{"#text":"C Value","-attr":"C attr"}}}`
56+
4157
## Examples
4258

4359
These examples for the InfraJS target show different usages of the `JS Script` function. The incoming parameter for all of the examples will be this CloudEvent:

0 commit comments

Comments
 (0)