JuliaVTK / ReadVTK.jl

Julia package for reading VTK XML files
https://juliavtk.github.io/ReadVTK.jl
MIT License
30 stars 9 forks source link

ReadVTK.jl is breaking #49

Closed eliascarv closed 8 months ago

eliascarv commented 8 months ago

I believe this may have occurred after the LightXML.jl update, but I can't say for sure. MWE:

julia> import ReadVTK

julia> file = ReadVTK.get_example_file("celldata_appended_binary_compressed.vtu")
"./celldata_appended_binary_compressed.vtu"

julia> vtk = ReadVTK.VTKFile(file)
Entity: line 25: parser error : Extra content at the end of the document
</VTKFile>
          ^
ERROR: LightXML.XMLParseError{String}("Failure in parsing an XML file.")
Stacktrace:
 [1] _check_result
   @ ~/.julia/packages/LightXML/g6rbQ/src/document.jl:88 [inlined]
 [2] parse_string(s::String)
   @ LightXML ~/.julia/packages/LightXML/g6rbQ/src/document.jl:99
 [3] ReadVTK.VTKFile(filename::String)
   @ ReadVTK ~/.julia/packages/ReadVTK/XpdR0/src/ReadVTK.jl:106
 [4] top-level scope
   @ REPL[2]:1
juliohm commented 8 months ago

I can reproduce the error with a fresh installation of the package.

sloede commented 8 months ago

LightXML.jl has not been updated in over three years, but the underlying XML2_jll package (providing the libxml2 binaries) was just updated to v2.12 just yesterday. Could you please try to force your installation to use XML2_jll v2.11.5 to verify that this has been caused by the update of libxml2?

Also, does this error only occur for the referenced file or for other example files as well?

eliascarv commented 8 months ago

The same error occurs with files generated by WriteVTK.jl.

MWE in a fresh environment:

(jl_h7aCcK) pkg> st
Status `/tmp/jl_h7aCcK/Project.toml`
  [dc215faf] ReadVTK v0.2.0
  [64499a7a] WriteVTK v1.18.1

julia> using ReadVTK, WriteVTK

julia> savedir = mktempdir()
"/tmp/jl_zxRx3U"

julia> filepath = joinpath(savedir, "test.vti")
"/tmp/jl_zxRx3U/test.vti"

julia> vtk_grid(filepath, 0:10, 0:10) do vtk
           vtk["data", VTKCellData()] = rand(100)
       end
1-element Vector{String}:
 "/tmp/jl_zxRx3U/test.vti"

julia> vtk = VTKFile(filepath)
Entity: line 13: parser error : Extra content at the end of the document
</VTKFile>
          ^
ERROR: LightXML.XMLParseError{String}("Failure in parsing an XML file.")
Stacktrace:
 [1] _check_result
   @ ~/.julia/packages/LightXML/g6rbQ/src/document.jl:88 [inlined]
 [2] parse_string(s::String)
   @ LightXML ~/.julia/packages/LightXML/g6rbQ/src/document.jl:99
 [3] VTKFile(filename::String)
   @ ReadVTK ~/.julia/packages/ReadVTK/XpdR0/src/ReadVTK.jl:106
 [4] top-level scope
   @ REPL[8]:1
ranocha commented 8 months ago
juliohm commented 8 months ago

I can reproduce the error:

julia> versioninfo()
Julia Version 1.9.4
Commit 8e5136fa297 (2023-11-14 08:46 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = 8

julia> st -m XML2_jll
Status `/tmp/jl_ASS4qI/Manifest.toml`
  [02c8fc9c] XML2_jll v2.12.0+0
eliascarv commented 8 months ago

With the new version 0.9.1 of LightXML.jl, ReadVTK.jl is working again!

julia> import ReadVTK

julia> savedir = mktempdir()
"/tmp/jl_P1Y27C"

julia> file = ReadVTK.get_example_file("celldata_appended_binary_compressed.vtu", output_directory=savedir)
"/tmp/jl_P1Y27C/celldata_appended_binary_compressed.vtu"

julia> vtk = ReadVTK.VTKFile(file)
VTKFile("/tmp/jl_P1Y27C/celldata_appended_binary_compressed.vtu", <XMLDocument>, "UnstructuredGrid", "1.0.0", "LittleEndian", "vtkZLibDataCompressor", <appended_data>, 4434, 3085)

(jl_YImX40) pkg> status -m LightXML
Status `/tmp/jl_YImX40/Manifest.toml`
  [9c8b4983] LightXML v0.9.1

(jl_YImX40) pkg> status
Status `/tmp/jl_YImX40/Project.toml`
  [dc215faf] ReadVTK v0.2.0

Closing the issue.