{"action":"created","issue":{"url":"https://api.github.com/repos/brunato/xmlschema/issues/3","repository_url":"https://api.github.com/repos/brunato/xmlschema","labels_url":"https://api.github.com/repos/brunato/xmlschema/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/brunato/xmlschema/issues/3/comments","events_url":"https://api.github.com/repos/brunato/xmlschema/issues/3/events","html_url":"https://github.com/brunato/xmlschema/issues/3","id":226811981,"number":3,"title":"XML Schema support for MinOccurs and MaxOccurs","user":{"login":"davlee1972","id":24494353,"avatar_url":"https://avatars3.githubusercontent.com/u/24494353?v=3","gravatar_id":"","url":"https://api.github.com/users/davlee1972","html_url":"https://github.com/davlee1972","followers_url":"https://api.github.com/users/davlee1972/followers","following_url":"https://api.github.com/users/davlee1972/following{/other_user}","gists_url":"https://api.github.com/users/davlee1972/gists{/gist_id}","starred_url":"https://api.github.com/users/davlee1972/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davlee1972/subscriptions","organizations_url":"https://api.github.com/users/davlee1972/orgs","repos_url":"https://api.github.com/users/davlee1972/repos","events_url":"https://api.github.com/users/davlee1972/events{/privacy}","received_events_url":"https://api.github.com/users/davlee1972/received_events","type":"User","site_admin":false},"labels":[{"id":461531985,"url":"https://api.github.com/repos/brunato/xmlschema/labels/bug","name":"bug","color":"ee0701","default":true},{"id":461531987,"url":"https://api.github.com/repos/brunato/xmlschema/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"login":"brunato","id":2034665,"avatar_url":"https://avatars1.githubusercontent.com/u/2034665?v=3","gravatar_id":"","url":"https://api.github.com/users/brunato","html_url":"https://github.com/brunato","followers_url":"https://api.github.com/users/brunato/followers","following_url":"https://api.github.com/users/brunato/following{/other_user}","gists_url":"https://api.github.com/users/brunato/gists{/gist_id}","starred_url":"https://api.github.com/users/brunato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunato/subscriptions","organizations_url":"https://api.github.com/users/brunato/orgs","repos_url":"https://api.github.com/users/brunato/repos","events_url":"https://api.github.com/users/brunato/events{/privacy}","received_events_url":"https://api.github.com/users/brunato/received_events","type":"User","site_admin":false},"assignees":[{"login":"brunato","id":2034665,"avatar_url":"https://avatars1.githubusercontent.com/u/2034665?v=3","gravatar_id":"","url":"https://api.github.com/users/brunato","html_url":"https://github.com/brunato","followers_url":"https://api.github.com/users/brunato/followers","following_url":"https://api.github.com/users/brunato/following{/other_user}","gists_url":"https://api.github.com/users/brunato/gists{/gist_id}","starred_url":"https://api.github.com/users/brunato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunato/subscriptions","organizations_url":"https://api.github.com/users/brunato/orgs","repos_url":"https://api.github.com/users/brunato/repos","events_url":"https://api.github.com/users/brunato/events{/privacy}","received_events_url":"https://api.github.com/users/brunato/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2017-05-06T23:20:42Z","updated_at":"2017-06-03T14:46:00Z","closed_at":"2017-06-03T14:46:00Z","body":"This is a great package. I tried a ton of other ones before stumbling on this one.\r\n\r\nOne thing I've noticed is that the to_dict() function doesn't behave consistently when MinOccurs > 1 or MaxOccurs > 1  or unbounded.\r\n\r\nThe bikes.xsd says there can be 0 to many bikes in the XML file.\r\n\r\n        <xs:element name=\"bike\" type=\"vh:vehicleType\"\r\n          minOccurs=\"0\" maxOccurs=\"unbounded\" />\r\n\r\nIf you look at the dictionary results:\r\n\r\nThe first test case creates vh:bike as an array of dictionaries with 2 bikes which is correct.\r\n'vh:bikes': {'vh:bike': [{'make': 'Harley-Davidson', 'model': 'WL'}, {'make': 'Yamaha', 'model': 'XS650'}]}\r\n\r\nThe second test case creates vh:bike as just a dictionary with 1 bike which is not consistent\r\n'vh:bikes': {'vh:bike': {'make': 'Harley-Davidson', 'model': 'WL'}}\r\n\r\nShouldn't the second test case create vh:bike as an array of dictionaries with just one dictionary in the array?\r\n'vh:bikes': {'vh:bike': [{'make': 'Harley-Davidson', 'model': 'WL'}]}\r\n\r\nThe reasoning behind this is that in some XML files you would could only see one item, but in others it could be many, but the Python dictionary object is not consistent between the two cases.\r\n\r\nTest Case:\r\n\r\nCopy vehicles.xml to vehicles2.xml.\r\nRemove Yamaha from the bikes section.\r\n\r\n        import xmlschema\r\n        my_schema = xmlschema.XMLSchema(\"vehicles.xsd\")\r\n        a = my_schema.to_dict(\"vehicles.xml\")\r\n        a\r\n        {'vh:bikes': {'vh:bike': [{'make': 'Harley-Davidson', 'model': 'WL'}, {'make': 'Yamaha', 'model': 'XS650'}]}, 'xsi:schemaLocation': 'http://example.com/vehicles vehicles.xsd', 'vh:cars': {'vh:car': [{'make': 'Porsche', 'model': '911'}, {'make': 'Porsche', 'model': '911'}]}}\r\n        a = my_schema.to_dict(\"vehicles2.xml\")\r\n        a\r\n        {'vh:bikes': {'vh:bike': {'make': 'Harley-Davidson', 'model': 'WL'}}, 'xsi:schemaLocation': 'http://example.com/vehicles vehicles.xsd', 'vh:cars': {'vh:car': [{'make': 'Porsche', 'model': '911'}, {'make': 'Porsche', 'model': '911'}]}}\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/brunato/xmlschema/issues/comments/305979436","html_url":"https://github.com/brunato/xmlschema/issues/3#issuecomment-305979436","issue_url":"https://api.github.com/repos/brunato/xmlschema/issues/3","id":305979436,"user":{"login":"brunato","id":2034665,"avatar_url":"https://avatars1.githubusercontent.com/u/2034665?v=3","gravatar_id":"","url":"https://api.github.com/users/brunato","html_url":"https://github.com/brunato","followers_url":"https://api.github.com/users/brunato/followers","following_url":"https://api.github.com/users/brunato/following{/other_user}","gists_url":"https://api.github.com/users/brunato/gists{/gist_id}","starred_url":"https://api.github.com/users/brunato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunato/subscriptions","organizations_url":"https://api.github.com/users/brunato/orgs","repos_url":"https://api.github.com/users/brunato/repos","events_url":"https://api.github.com/users/brunato/events{/privacy}","received_events_url":"https://api.github.com/users/brunato/received_events","type":"User","site_admin":false},"created_at":"2017-06-03T14:46:00Z","updated_at":"2017-06-03T14:46:00Z","body":"Thought a lot about the XLM to JSON decoding conventions: for the new release (0.9.9) the `iter_decode` methods will be improved and into the method ` XsdElement.iter_decode()` a customizable function will be inserted to format the decoded data, considering also the schema of the XSD element. The optional arguments \"dict_class\", \"force_list\", \"text_key\" and \"attribute_prefix\" will be replaced by one argument \"element_hook\" (or \"element_decode_hook\") that shall be used to change the decode format.\r\n \r\nThe use of `iterparse ()` for decoding big files will be considered after."}}
{"actor":{"display_login":"brunato"}}