willemdj / erlsom

XML parser for Erlang
GNU Lesser General Public License v3.0
264 stars 103 forks source link

scan incorrectly fails with error "Unexpected attribute: length" #79

Closed ewestern closed 3 years ago

ewestern commented 3 years ago

test.xsd (Link) test.xml (Link)

{ok, Model} = erlsom:compile_xsd_file("test.xsd"),
erlsom:scan_file("test.xml", Model).
                    {error,[{exception,{error,"Unexpected attribute: length"}},
                            {stack,[descriptionsType,
                                    'partnerContent/seriesItems/series',
                                    'partnerContent/seriesItems',partnerContent]},
                            {received,{startElement,[],"description",[],
                                                    [{attribute,"length",[],[],"60"}]}}]}
willemdj commented 3 years ago

Hi, I just had a quick look, but are you sure your assumptions are correct? I think you have to repeat the "length" attribute on the restricted type. See this post on stackoverflow, for example.

ewestern commented 3 years ago

Thanks for your quick response. I'm not positive my assumptions are correct, but I have some reason to think so. Consider the Xml Schema Primer:

Notice that types derived by restriction must repeat all the particle components (element declarations, model groups, and wildcards) of the base type definition that are to be included in the derived type. However, attribute declarations do not need to be repeated in the derived type definition;

Note that this is consistent with the stackoverflow post as well.

(Also, it's not dispositive, but these successfully validate with libxml and xerces ).

willemdj commented 3 years ago

Yes, you are right. So it is indeed something that should be fixed.

I'll try to do it, but it will probably not be soon.

Anyway, thanks for reporting this.

Op za 6 feb. 2021 om 18:23 schreef Peter France notifications@github.com:

Thanks for your quick response. I'm not positive my assumptions are correct, but I have some reason to think so. Consider the Xml Schema Primer https://www.w3.org/TR/xmlschema-0/#DerivByRestrict:

Notice that types derived by restriction must repeat all the particle components (element declarations, model groups, and wildcards) of the base type definition that are to be included in the derived type. However, attribute declarations do not need to be repeated in the derived type definition;

Note that this is consistent with the stackoverflow post as well.

(Also, it's not dispositive, but these successfully validate with libxml and xerces ).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/willemdj/erlsom/issues/79#issuecomment-774510794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABGHR53H5I6LQSWQO4BBKLS5V3KRANCNFSM4XFHRWSA .