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 namespaces getting injected into attribute names - parker covention #35

Open
LaughingBubba opened this issue Nov 29, 2018 · 6 comments

Comments

@LaughingBubba
Copy link

Hi, after reading issues #1 , #8 and PR #9 I think I have a different issue.

Essentially this:

<EML xmlns="urn:oasis:names:tc:evs:schema:eml" >
  <TransactionId>B313CBA4-BCA9-4B8F-8C50-BADE9423A020</TransactionId>
</EML>

becomes this:

{
  "{urn:oasis:names:tc:evs:schema:eml}TransactionId": "B313CBA4-BCA9-4B8F-8C50-BADE9423A020"
}

where as I was actually expecting this:

{
  "TransactionId": "B313CBA4-BCA9-4B8F-8C50-BADE9423A020"
}

Am I missing something?

@dagwieers
Copy link
Contributor

So you want to ignore namespaces. What if the same element is used in different namespaces, they would end up being the same.

@LaughingBubba
Copy link
Author

Hi In the 5 - 6 different xml files I'm dealing with, what you describe does not occur. Also as this I'm specifically using the Parker covention, I would have thought that name spaces would have been discarded along with the root element. If I'd used the preserve root element, not so much..

Thoughts?

@javadev
Copy link

javadev commented Nov 30, 2018

Hi,

<EML xmlns="urn:oasis:names:tc:evs:schema:eml" >
  <TransactionId>B313CBA4-BCA9-4B8F-8C50-BADE9423A020</TransactionId>
</EML>

may be converted to json

 {
  "EML": {
    "-xmlns": "urn:oasis:names:tc:evs:schema:eml",
    "TransactionId": "B313CBA4-BCA9-4B8F-8C50-BADE9423A020"
  },
  "#omit-xml-declaration": "yes"
}

@LaughingBubba
Copy link
Author

LaughingBubba commented Dec 2, 2018

Thanks @javadev that would be the result I would expect if I'd used the option preserve_root=True option. @sanand0 & @dagwieers happy to do a PR but might need some guidance as I'm relatively new to Python but not new to PRs and XML/JSON

@LaughingBubba
Copy link
Author

LaughingBubba commented Dec 4, 2018

Strike my last comment xmltodict is effectively parker convention without the annoying (and superfluous) namespace injections. Consider this closed but thanks for the work done on this library and your time to read this.

@sanand0
Copy link
Owner

sanand0 commented Dec 8, 2018

Thanks @LaughingBubba

The way xmltodict handles namespaces is elegant. I'm re-opening this issue to apply the same for all conventions. Not sure when we'll get this done, but this is definitely useful.

@sanand0 sanand0 reopened this Dec 8, 2018
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

No branches or pull requests

4 participants