Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Sep 23, 2024
1 parent 7f97a6e commit cad830d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/ottl/ottlfuncs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ Examples:
The `RemoveXML` Converter returns an edited version of an XML string with selected elements removed.

`target` is a Getter that returns a string. This string should be in XML format.
If `target` is not a string, nil, or cannot be parsed as XML, `ParseXML` will return an error.
If `target` is not a string, nil, or is not valid xml, `RemoveXML` will return an error.

`xpath` is a string that specifies an [XPath](https://www.w3.org/TR/1999/REC-xpath-19991116/) expression that
selects one or more elements to remove from the XML document.
Expand Down
10 changes: 5 additions & 5 deletions pkg/ottl/ottlfuncs/func_remove_xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ func NewRemoveXMLFactory[K any]() ottl.Factory[K] {

func createRemoveXMLFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) {
args, ok := oArgs.(*RemoveXMLArguments[K])

if !ok {
return nil, fmt.Errorf("RemoveXML args must be of type *RemoveXMLAguments[K]")
}

if err := validateXPath(args.XPath); err != nil {
return nil, err
}

return removeXML(args.Target, args.XPath), nil
}

// removeXML returns a `pcommon.String` that is a result of removing all matching nodes from the target XML.
// removeXML returns a XML formatted string that is a result of removing all matching nodes from the target XML.
// This currently supports removal of elements, attributes, text values, comments, and CharData.
func removeXML[K any](target ottl.StringGetter[K], xPath string) ottl.ExprFunc[K] {
return func(ctx context.Context, tCtx K) (any, error) {
if err := validateXPath(xPath); err != nil {
return nil, err
}

targetVal, err := target.Get(ctx, tCtx)
if err != nil {
Expand Down

0 comments on commit cad830d

Please sign in to comment.