Can you post the code you created by hand, so we can compare it with the xsd source? (I have created some xml-to-perl code generators in the past, but since they don't solve this exact problem, it would be useful to see how the target should be -- even if incomplete.)