Skip to content

Commit cad830d

Browse files
committed
feedback
1 parent 7f97a6e commit cad830d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/ottl/ottlfuncs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ Examples:
12931293
The `RemoveXML` Converter returns an edited version of an XML string with selected elements removed.
12941294

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

12981298
`xpath` is a string that specifies an [XPath](https://www.w3.org/TR/1999/REC-xpath-19991116/) expression that
12991299
selects one or more elements to remove from the XML document.

pkg/ottl/ottlfuncs/func_remove_xml.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ func NewRemoveXMLFactory[K any]() ottl.Factory[K] {
2525

2626
func createRemoveXMLFunction[K any](_ ottl.FunctionContext, oArgs ottl.Arguments) (ottl.ExprFunc[K], error) {
2727
args, ok := oArgs.(*RemoveXMLArguments[K])
28-
2928
if !ok {
3029
return nil, fmt.Errorf("RemoveXML args must be of type *RemoveXMLAguments[K]")
3130
}
3231

32+
if err := validateXPath(args.XPath); err != nil {
33+
return nil, err
34+
}
35+
3336
return removeXML(args.Target, args.XPath), nil
3437
}
3538

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

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

0 commit comments

Comments
 (0)