JuliaIO/LightXML.jl

LoadError: syntax: { } vector syntax is discontinued

Closed this issue · 5 comments

I'm new to Julia and was testing your package based on the "Create new XML document" section of your README.

However, I got this error LoadError: syntax: { } vector syntax is discontinued on this line:

set_attributes(xs2, {"tag"=>"IL", "cap"=>"Springfield"})

I'm using Julia 1.1.1 (on Ubuntu 19.04).

Is appears it is just a matter of using this with square brackets instead:

set_attributes(xs2, ["tag"=>"IL", "cap"=>"Springfield"])

Perhaps update the README if this is correct.

omus commented

Curly braces were previous used to create dictionaries in an early version of Julia. The modern equivalent would be:

set_attributes(xs2, Dict("tag"=>"IL", "cap"=>"Springfield"))

The README should definitely be updated.

Since you mentioned you're new to Julia you should also checkout the EzXML.jl package

Thanks. What is the main difference between your package and EzXML? Are both maintained to the same extent? I will have to generate very large XML files (defining computational models with millions of nodes and elements).

Below is what I currently use (with MATLAB and my GIBBON toolbox), perhaps you can recommend a certain approach with your package:

febio_spec.Geometry.Nodes{1}.ATTR.name='nodeSet1';
febio_spec.Geometry.Nodes{1}.node.ATTR.id=[1 102 2]';
febio_spec.Geometry.Nodes{1}.node.VAL=randn(3,3);

Which translates to:

<Nodes name="nodeSet1">
      <node id="1">5.3766714e-01, 8.6217332e-01, -4.3359202e-01</node>
      <node id="102">1.8338850e+00, 3.1876524e-01, 3.4262447e-01</node>
      <node id="2">-2.2588469e+00, -1.3076883e+00, 3.5783969e+00</node>
</Nodes>

Note my use of ATTR and VAL to trigger attributes or value entries in the conversion from the MATLAB structure to an XML file.

omus commented

I'm not a maintainer on this package or EzXML but I've found that EzXML has been more actively maintained as of late.

If you are concerned with performance and memory allocations I would recommend making prototype implementations with both libraries and using BenchmarkTools.jl to compare.

You also may want to join the Julia Slack which will get you help and advice from the general Julia community.

omus commented

Issue can now be closed