Skip to content
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

Constructor ChoiceFieldData failed. #72

Open
NeroBlackstone opened this issue Oct 1, 2024 · 1 comment
Open

Constructor ChoiceFieldData failed. #72

NeroBlackstone opened this issue Oct 1, 2024 · 1 comment

Comments

@NeroBlackstone
Copy link

I'm trying to generate julia types from musicxml 4.0 xsd schema.

ERROR: MethodError: Cannot `convert` an object of type XsdToStruct.GroupFieldData to an object of type XsdToStruct.FieldData

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  XsdToStruct.FieldData(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)
   @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_field_data/xsd_field_data_types.jl:9

Stacktrace:
  [1] setindex!(A::Vector{XsdToStruct.FieldData}, x::XsdToStruct.GroupFieldData, i1::Int64)
    @ Base ./array.jl:1021
  [2] _unsafe_copyto!(dest::Vector{XsdToStruct.FieldData}, doffs::Int64, src::Vector{XsdToStruct.AbstractFieldData}, soffs::Int64, n::Int64)
    @ Base ./array.jl:299
  [3] unsafe_copyto!
    @ ./array.jl:353 [inlined]
  [4] _copyto_impl!
    @ ./array.jl:376 [inlined]
  [5] copyto!
    @ ./array.jl:363 [inlined]
  [6] copyto!
    @ ./array.jl:385 [inlined]
  [7] copyto_axcheck!
    @ ./abstractarray.jl:1177 [inlined]
  [8] Vector{XsdToStruct.FieldData}(x::Vector{XsdToStruct.AbstractFieldData})
    @ Base ./array.jl:673
  [9] convert
    @ ./array.jl:665 [inlined]
 [10] ChoiceFieldData
    @ ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_field_data/xsd_field_data_types.jl:22 [inlined]
 [11] #ChoiceFieldData#2
    @ ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_field_data/xsd_field_data_types.jl:21 [inlined]
 [12] parse_xsd_complex_content_choice!(complex_node::XsdToStruct.ComplexTreeNode, xsd_choice::LightXML.XMLElement)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:108
 [13] parse_complex_content!(complex_node::XsdToStruct.ComplexTreeNode, xsd_complex_content::LightXML.XMLElement)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:42
 [14] parse_xsd_complex_content_sequence!(complex_node::XsdToStruct.ComplexTreeNode, xsd_sequence::LightXML.XMLElement)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:52
 [15] parse_complex_content!(complex_node::XsdToStruct.ComplexTreeNode, xsd_complex_content::LightXML.XMLElement)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:36
 [16] parse_xsd_complex_type(xsd_complex::LightXML.XMLElement, type_name::Nothing, sub_module::Nothing)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:193
 [17] parse_xsd_complex_type
    @ ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader_complex_node.jl:143 [inlined]
 [18] create_xsd_tree(xsd_root::LightXML.XMLElement)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader.jl:48
 [19] read_xsd(xsd_path::String)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/xsd_reader/xsd_reader.jl:15
 [20] xsd_to_struct_module(xsd_path::String, output_dir::String)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/XsdToStruct.jl:52
 [21] xsd_to_struct_module(xsd_path::String)
    @ XsdToStruct ~/.julia/packages/XsdToStruct/BGBoC/src/XsdToStruct.jl:88
 [22] top-level scope
    @ REPL[10]:1

It looks like the field is not being converted correctly:

https://github.com/Tom-Lemmens/XmlStructTools.jl/blob/c24a048ddce27506578a589092022ca5a2b41111/XsdToStruct.jl/src/xsd_field_data/xsd_field_data_types.jl#L23C5-L23C19

@NeroBlackstone
Copy link
Author

I think proper exception handling code should be added. When an error is thrown, it shows which part of the xsd caused the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant