-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
empty attributes are removed in generated XML #230
Comments
You are right the serializer is ignoring empty strings as well, that doesn't sound right. Let me run a few tests to see if we can change this default behavior or if we need to add some sort of configuration there. Same behavior for v20.8 as well |
Out of curiosity @gjvc are you working with a schema definition or do you write the models yourself? Also did you encounter an issue with v20.8 and didn't upgrade? |
Thank you very much for the quick response! I am using an XSD generated from a RelaxNG grammar via the "trang" tool. I tried v20.8 to see if it fixed this problem (which it didn't)[1], but held off making this problem report until I'd gone through the documentation one more time :-) [1] I will try the latest version |
Can you share how that attribute is defined in the xsd? |
Notes: Exception to the rule is an empty tokens list!
Currently it is defined in the XSD as
I am able (and might need) to change this to "xs:string", because in some cases the value is of the format "1000|2000|3000" (as I said, legacy system :-)) |
Notes: Exception to the rule is an empty tokens list!
I have just tried your fix via this in my etc/pip/requirements.txt file
...and it looks like it works great. Thank you very much for the amazingly quick fix. :-) |
awesome man, I also confirmed with the w3c-test-suite that the updated behavior still produces valid xml instances. I am going to merge it to master, and it will be included in the next release v20.9, make sure you switch to the master branch till then. |
Hello,
First of all, thank you for a wonderful project. It's a great leap forward over walking XML trees via ElementTree findall() and such.
I am using it to generate a configuration for a system. This is a legacy application and as such has many quirks. One such quirk is that it needs to see an empty attribute in an element like this
The problem I'm having is that
amount=""
is getting removed and does not appear in the generated XML, even when I set it to "". I would expect it to be removed if it were set to None in Python, but i'm setting it to the empty string and that is what I would like to see in the XML. I'm using xsdata version 20.7 on python 3.8.5.The text was updated successfully, but these errors were encountered: