-
-
Notifications
You must be signed in to change notification settings - Fork 56
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:space="preserve" attribute is dropped from elements when parsing .arxml #704
Comments
Is it possible to send me the sampe file? I can't reproduce that In [1]: from xsdata.formats.dataclass.parsers import XmlParser
...: from generated import Sd
...: from xsdata.formats.dataclass.serializers import XmlSerializer
...:
...: raw = """<SD GID="ElementNumber" xml:space="preserve">4529224</SD>"""
...:
...: obj = XmlParser().from_string(raw, Sd)
...:
...: print(XmlSerializer().render(obj))
<?xml version="1.0" encoding="UTF-8"?>
<SD GID="ElementNumber" xml:space="preserve">4529224</SD>
In [2]: |
Just checked this is the same issue with #701, before the patch the class doesn't get the xml:space attr, Before @dataclass
class Sd:
...
class Meta:
name = "SD"
value_extension: str = field(
default="",
metadata={
"required": True,
"white_space": "preserve",
}
)
value: Optional[str] = field(
default=None,
metadata={
"name": "VALUE",
"type": "Element",
"namespace": "http://autosar.org/schema/r4.0",
"white_space": "preserve",
}
) After the patch in master @dataclass
class Sd:
...
class Meta:
name = "SD"
value: str = field(
default="",
metadata={
"required": True,
"white_space": "preserve",
}
)
s: Optional[str] = field(
default=None,
metadata={
"name": "S",
"type": "Attribute",
}
)
t: Optional[str] = field(
default=None,
metadata={
"name": "T",
"type": "Attribute",
"pattern": r"([0-9]{4}-[0-9]{2}-[0-9]{2})(T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|([+\-][0-9]{2}:[0-9]{2})))?",
}
)
gid: Optional[str] = field(
default=None,
metadata={
"name": "GID",
"type": "Attribute",
}
)
space: Optional[str] = field(
default=None,
metadata={
"type": "Attribute",
"namespace": "http://www.w3.org/XML/1998/namespace",
}
) Make sure you install the latest master @magnus-lindstrom |
Yes, I realize now that the file I had been comparing against was the previously generated file using the old installation. I am not able to reproduce the problem stated in this issue again. Sorry, and thanks for the clarification! |
(similar to my previous question/bug report. This time I'm using the latest master version of xsData installed roughly 30mins prior to writing this text)
I am working with large xml files called .arxml, the schema for which can be seen here. When I parse an .arxml file and then serialize to a new file and compare the input and output, all instances of the xml:space="preserve" attribute are dropped. For example, the element
is reduced to
Is this because there is no whitespace in the element content, and therefore the tag is meaningless? I have looked through all instances where the attribute is dropped, and in all cases the content is void of any whitespace.
If this is the case, should the attribute perhaps be kept anyway, should the element happen to be modified to contain whitespace which should be ignored?
Below are the steps that I have taken to arrive at my current problem.
Followed by running the below python script
The text was updated successfully, but these errors were encountered: