vtkio icon indicating copy to clipboard operation
vtkio copied to clipboard

Error importing VTU with `<AppendedData encoding="raw">` block

Open w1th0utnam3 opened this issue 1 year ago • 6 comments

The attached file fluid_1_91.vtu cannot be loaded using v0.6.0 or the release-0.7 branch and results in the errors:

XML error: Deserialization error: Xml(UnexpectedEof("</Err(Utf8Error { valid_up_to: 0, error_len: Some(1) })>"))
Deserialization error: Xml(UnexpectedEof("</Err(Utf8Error { valid_up_to: 0, error_len: Some(1) })>"))
Unexpected EOF during reading </Err(Utf8Error { valid_up_to: 0, error_len: Some(1) })>.
Unexpected EOF during reading </Err(Utf8Error { valid_up_to: 0, error_len: Some(1) })>.

while Paraview is able to load the file.

The file uses a <AppendedData encoding="raw">...</AppendedData> raw binary block for all the data arrays and I suspect it happens to contain characters or sequences that confuse the XML parser.

The file fluid_1_91_encoded.vtu can be read without problems after opening the original file in Paraview and re-exporting it to VTU with the option "Encode appended data" which I guess applies base64 encoding.

I don't know if it is possible to somehow use different options for the XML parser to support the raw binary block or whether this is actually not allowed by the XML format and would require manual parsing.

fluid_1_91.zip

w1th0utnam3 avatar Apr 19 '23 12:04 w1th0utnam3

Thank you for this issue! Indeed officially the XML format doesn't support binary data, and this is actually what is blocking the 0.7 release currently. The plan is to upstream a feature into quick-xml that allows one to implement a custom parser for the text in XML files. The example file you provided should be very helpful in addressing testing binary support.

elrnv avatar Apr 19 '23 16:04 elrnv

Ah right. I missed that in the version 0.7 PR. I guess this is related to this quick-xml PR then: https://github.com/tafia/quick-xml/pull/555

Hope the sample file helps!

w1th0utnam3 avatar Apr 19 '23 16:04 w1th0utnam3

Yes exactly! Thanks for linking that issue.

elrnv avatar Apr 19 '23 16:04 elrnv

Has https://github.com/tafia/quick-xml/pull/783 managed to resolve blockers on the new release? Or is there more work required to support <AppendedData encoding="raw">-containing vtk files?

DanW97 avatar Aug 30 '24 15:08 DanW97

Sadly not yet, because we use the serde API for dealing with XML files here, we also need to extend the serde API to support binary blobs in quick-xml. I started a PR here but don't have much time to finish it. Any help is appreciated of course! I am happy to help any efforts there.

elrnv avatar Sep 04 '24 01:09 elrnv

That's unfortunate. I haven't got loads of time but I am willing to try, if I can be pointed in the right direction for what's needed to finish it. Is it a case of fixing the failing tests or is there more to it?

DanW97 avatar Sep 05 '24 14:09 DanW97