[pkg/ottl] Add InsertXML Converter #35436
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This simple converter allows a basic form of XML document modification. Aside from the obvious, this can be used to disambiguate elements which should be members of a slice when parsed by the proposed
ParseSimplifiedXML
.To illustrate this, consider how you would expect the following two documents to parse:
The second document can clearly be understood as a slice of
File
elements:but the first document could be misunderstood as a map where
File
is a unique key:That is, there is no way to infer the schema from a single example. However, by adding an empty
File
element, we can disambiguate the schema.Many users will not care about this detail but for those who need the schema to be interpreted consistently, this mechanism provides a solution. Note that in the proposed
ParseSimplifyXML
converter, empty elements without text content are dropped, since they would be keys without values in a map.See #35281