Skip to content

Conversation

@baodrate
Copy link
Contributor

@baodrate baodrate commented Oct 1, 2025

fixes --xml-keep-namespace=true so that element tags keep their namespace prefix. e.g.

<xsi:foo>bar</xsi:foo>

does a roundtrip unchanged (rather than becoming <foo>bar</foo>)

fixes #1730

@baodrate
Copy link
Contributor Author

baodrate commented Oct 1, 2025

Note that when using --xml-raw-token=false this causes any elements with a default namespace (i.e. the xmlns attribute) to become prefixed with the value of xmlns.

This might be out of scope of this PR since --xml-raw-token=false seems to behave incorrectly anyways. e.g.

yq -px -ox --xml-raw-token=false (prior to this PR) already processed:

<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <bar xsi:abc="xyz">123</bar>
</foo>

into:

<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <bar http://www.w3.org/2001/XMLSchema-instance:abc="xyz">123</bar>
</foo>

which is invalid xml.

I'm not sure how xml-raw-token is supposed to work, so I'm unsure how to fix this. But in any case, it should likely be tracked in a separate issue

@mikefarah mikefarah merged commit f353885 into mikefarah:master Oct 12, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Xml: is keep the namespace

2 participants