-
Notifications
You must be signed in to change notification settings - Fork 6
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
Constants like pi or expressions like nothing, are not interpreted but result in "pi" and "nothing" #22
Comments
Just learned this behaviour is probably inherited from the
My quick and dirty fix now checks if the thing is nothing: function aen(main_node::Node,sub_node_name::String, args...; kwargs...)
if isnothing(args)
sub_node = XML.Element(sub_node_name; kwargs...)
else
sub_node = XML.Element(sub_node_name, args...; kwargs...)
end
push!(main_node, sub_node)
return sub_node
end |
Most things don't have a This has the drawback of what you're describing here, but the benefit of not hitting errors all the time for things that you would expect to work: julia> repr("text/xml", 1)
ERROR: MethodError: no method matching show(::IOBuffer, ::MIME{Symbol("text/xml")}, ::Int64) Think of this as the rule for how XML.jl writes a given showable("text/xml", x) ? repr("text/xml", x) : repr(x) I like having a clear rule vs. special cases for different types, so I'm going to close this issue. |
If I do something like this:
The XML will contain:
The correct behaviour should be:
So it looks like constants and expressions like
nothing
are currently converted to "strings" based on their name, rather than being interpreted first? Note I also tried usingXML.Text(pi)
orXML.Text(nothing)
, but the same happens.The context is that I am trying to create an "add element node" function called
aen
, to remove the clutter from my code. Here is one attempt where I was hoping to use an optional amount ofargs
andkwargs
.However, if one now uses the following, one still gets
<bread>nothing</bread>
:So when
args...
is empty Julia passes anothing
which is currently again producing the string"nothing"
in the XML file at the moment.A workaround for constants seems to be to force them to be interpreted e.g. by multiplying by 1:
Sidenote, not sure if
breadNode = XML.Element("bread",[])
should produce the following either:This may highlight a general issue in interpreting the XML.Text entry.
Thanks for your help!
The text was updated successfully, but these errors were encountered: