Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/ottl] Add AddElementXML Converter #35435

Closed
wants to merge 2 commits into from
Closed

Conversation

djaglowski
Copy link
Member

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:

<Files>
   <File>foo.txt</File>
</Files>
<Files>
   <File>foo.txt</File>
   <File>bar.txt</File>
</Files>

The second document can clearly be understood as a slice of File elements:

Files:
  - File: foo.txt

but the first document could be misunderstood as a map where File is a unique key:

Files:
  File: foo.txt

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.

<Files>
   <File>foo.txt</File>
   <File/>
</Files>

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.

@djaglowski
Copy link
Member Author

Closed in favor of #35436

@djaglowski djaglowski closed this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant