JuliaIO / LibExpat.jl

Julia interface to the Expat XML parser library
Other
9 stars 32 forks source link

ERROR: type: instantiate_type: expected TypeConstructor, got Type{(Any...,)} #28

Closed tkelman closed 9 years ago

tkelman commented 9 years ago

The xml file looks okay here from a visual inspection (https://gist.github.com/392165b87c4139e4ce23, libxml2/LightXML also parse it okay), is expat wrong?

  | | |_| | | | (_| |  |  Version 0.4.0-dev+4346 (2015-04-19 04:12 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 3074b70* (3 days old master)
|__/                   |  x86_64-linux-gnu

shell> curl http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.1/repodata/repomd.xml > repomd.xml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1620  100  1620    0     0   4409      0 --:--:-- --:--:-- --:--:--  4414

julia> using LibExpat

julia> xml = xp_parse("repomd.xml")
ERROR: "ErrorException(\"Error parsing document : 0\"), syntax error, 1, 1, 1"
 in error at error.jl:19
 in xp_parse at /home/tkelman/.julia/v0.4/LibExpat/src/LibExpat.jl:289

On Windows I get a slightly different error, "not well-formed (invalid token), 1, 3, 3".

amitmurthy commented 9 years ago

xp_parse(open(readall, "repomd.xml")) ought to work. xp_parse takes in a string.

tkelman commented 9 years ago

duh, thanks, I'm misreading what WinRPM is calling xp_parse on

tkelman commented 9 years ago
julia> xml = xp_parse(readall("repomd.xml"));
julia> xml[xpath"/repomd/data[@type='primary']"]
ERROR: type: instantiate_type: expected TypeConstructor, got Type{(Any...,)}
tkelman commented 9 years ago

works on 0.4 but not 0.3

tkelman commented 9 years ago

Where did this come from?

julia> using LibExpat

julia> LibExpat.Tuple
(Any...,)
amitmurthy commented 9 years ago

Since Base is automatically available, all exported entities from Base are available in all modules.

julia> using JSON

julia> JSON.Tuple
Tuple

I think the problem is due to how @compact is resolving Tuple{Symbol,Any} on 0.3

tkelman commented 9 years ago

yeah, about to submit a PR which should fix this

tkelman commented 9 years ago

this is what I was seeing in 0.3:

julia> macroexpand(:(xpath"/repomd/data[@type='primary']"))
:((LibExpat.XPath{ASCIIString,Array{ETree,1}})((:xpath,LibExpat.push!(LibExpat.push!(LibExpat.push!(LibExpat.push!(LibExpat.push!(LibExpat.push!(LibExpat.Array(LibExpat.Tuple{LibExpat.Symbol,LibExpat.Any},0),(:root,:node)),(:child,:element)),(:name,"repomd")),(:child,:element)),(:name,"data")),(:filter,(:binop,(:(=),(:xpath_str,LibExpat.push!(LibExpat.Array(LibExpat.Tuple{LibExpat.Symbol,LibExpat.Any},0),(:attribute,"type"))),(:string,"primary"))))))))