Skip to content

Commit 2ecf98a

Browse files
authored
XML Parser Limitations (#288)
Added missing limitation parts for xml parser.
2 parents 640b4fe + 924615b commit 2ecf98a

1 file changed

Lines changed: 72 additions & 6 deletions

File tree

doc/_admin-guide/120_Parser/022_XML_parser/000_Limitations.md

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ description: >-
77

88
The XML parser comes with certain limitations.
99

10-
## Vector-like structures
10+
## Using the list-handling functionality with vector-like structures
1111

12-
It is not possible to address each element of a vector-like structure
13-
individually. For example, take this input:
12+
The XML parser uses the list-handling functionality to handle lists in the XML. The list-handling functionality has limitations when handling name-value pairs or quoting in SDATA as described below. Note that you can disable the list-handling functionality if needed.
13+
14+
The list-handling functionality of the XML parser separates vector-like structures by a comma as separate entries. Using the following structure as an example:
1415

1516
```xml
1617
<vector>
@@ -21,10 +22,11 @@ individually. For example, take this input:
2122
</vector>
2223
```
2324

24-
After parsing, the entries cannot be addressed individually. Instead,
25-
the text of the entries will be concatenated:
25+
After parsing, the entries are separated by a comma. If an entry has a space or is separated by a comma, for example, `value 2` or `Doe,John` in the previous example, quoting is applied to the entry:
2626

27-
> vector.entry = "value1value2...valueN"
27+
```xml
28+
vector.entry = value1,"value 2","Doe,John",value3...valueN
29+
```
2830

2931
Note that xmllint has the same behavior:
3032

@@ -33,6 +35,70 @@ $ xmllint --xpath "/vector/entry/text()" test.xml
3335
value1value2valueN%
3436
```
3537

38+
## Using the list-handling functionality with name-value pairs
39+
40+
As every value in name-value pairs can be quoted, One Identity recommends that you access name-values as lists as follows:
41+
* Use list-related template functions on the list created by the XML parser.
42+
* Use type-hinting using the format-json template function as shown in the example below:
43+
44+
```xml
45+
template("$(format-json --scope dot-nv-pairs LIST=list(${.xml.Event.EventData.Data}))\n")
46+
```
47+
48+
## Using the list-handling functionality with SDATA
49+
50+
According to RFC5424, SDATA parameter values must be quoted with double-quote ('"') characters. If the value contains double-quotes, they must be escaped with a backslash (\) character.
51+
52+
Due to the list-handling functionality of the XML parser, parsed XML text contents are also quoted using double-quote ('"') characters. As parsed XML text content are part of the message, they are quoted when used as SDATA parameter values.
53+
54+
Using the following structure as an example:
55+
56+
```xml
57+
<Event>
58+
<Data>42</Data>
59+
<Data>Testing testing</Data>
60+
</Event>
61+
```
62+
63+
The expected name-value pair is as follows:
64+
65+
```xml
66+
Event.Data = 42,"Testing testing"
67+
```
68+
69+
In SDATA, this is quoted as shown below:
70+
71+
```xml
72+
[Event Data="42,\"Testing testing\""]
73+
```
74+
75+
## Disabling the list-handling functionality
76+
77+
To disable the list-handling functionality, use the create_lists(`yes`/`no`) option as shown below. The default value is set to `yes`.
78+
79+
```xml
80+
parser p_xml {
81+
xml(create_lists(no));
82+
};
83+
```
84+
85+
Note that if you disable the list-handling functionality, the XML parser cannot address each element of a vector-like structure individually. Using the following structure as an example:
86+
87+
```xml
88+
<vector>
89+
<entry>value1</entry>
90+
<entry>value2</entry>
91+
...
92+
<entry>valueN</entry>
93+
</vector>
94+
```
95+
96+
After parsing, the entries are not addressed individually. Instead, the text of the entries are concatenated:
97+
98+
```xml
99+
vector.entry = "value1value2...valueN"
100+
```
101+
36102
## CDATA
37103

38104
The XML parser does not support CDATA. CDATA inside the XML input is

0 commit comments

Comments
 (0)