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

XML: Unable to reference Attribute instead of Value. #2825

Open
1 task done
zonorti opened this issue Oct 14, 2024 · 3 comments
Open
1 task done

XML: Unable to reference Attribute instead of Value. #2825

zonorti opened this issue Oct 14, 2024 · 3 comments
Labels
bug Something isn't working resource-xml Modify resource of type xml

Comments

@zonorti
Copy link

zonorti commented Oct 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I am trying to read or write an XML Attribute using updatecli.
But not finding the value. According to XPath it's a valid query.
Error:

SOURCES
=======

xml
---
ERROR: ✗ cannot find value for path "/a/b/@MyVal" from file "test.xml"
ERROR: ✗ cannot find value for path "/a/b/@MyVal" from file "test.xml"
Pipeline "Test XML" failed
Skipping due to:
	sources stage:	"cannot find value for path \"/a/b/@MyVal\" from file \"test.xml\""

See further for example files.

Expected Behavior

Source: reads 1 from XML
Target: writes 1 into MyVal of /a/c

Steps To Reproduce

test.xml

<a>
  <b MyVal="1">1</b>
  <c MyVal="2">2</c>
</a>

updatecli.yaml

name: Test XML

sources:
  xml:
    name: Read Attribute from XML
    kind: xml
    spec:
      file: test.xml
      path: "/a/b/@MyVal"

targets:
  xml:
    name: Change Attribute in XML
    kind: xml
    spec:
      file: test.xml
      path: "/a/c/@MyVal"

run updatecli diff

Environment

- OS: macOS Sonoma 14.4.1
- updatecli: 0.85.0

Anything else?

No response

@zonorti zonorti added the bug Something isn't working label Oct 14, 2024
@olblak olblak added the resource-xml Modify resource of type xml label Oct 14, 2024
@olblak
Copy link
Member

olblak commented Oct 14, 2024

Thanks for opening this pull request, Updatecli is currently using the library github.com/beevik/etree and it appears that there is a limitation on the attribute syntax

cfr github.com/beevik/etree/#51

@zonorti
Copy link
Author

zonorti commented Oct 15, 2024

Thanks for a swift reply, @olblak!
We are trying to change csproj file from dotnet here.
Would it make sense for us to experiment with another XML library? Is this something that could get merged?
Otherwise using shell is probably way to go, right?

@olblak
Copy link
Member

olblak commented Oct 15, 2024

Thanks for a swift reply, @olblak!
We are trying to change csproj file from dotnet here.
Would it make sense for us to experiment with another XML library? Is this something that could get merged?
Otherwise using shell is probably way to go, right?

We could use another golang library if you know one, that's something we did for the yaml plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resource-xml Modify resource of type xml
Projects
Status: Todo
Development

No branches or pull requests

2 participants