metaleap/go-xsd

Generated tags for attributes can incorrectly have namespaces

jesand opened this issue · 0 comments

When code is generated from a .xsd with namespaces, those namespaces are included in struct field tags for attribute elements. However, encoding/xml does not properly marshal/unmarshal such fields. Deleting the namespace manually from the struct tag corrects the issue.

Here's the command I ran:

$GOPATH/bin/xsd-makepkg -goinst=false -basepath=github.com/jesand/crowds/amt/gen -uri=http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd

The resulting code fails to unmarshal MinLength and MaxLength in the following XML:

<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
          <Question>
            <QuestionIdentifier>nextmove</QuestionIdentifier>
            <DisplayName>The Next Move</DisplayName>
            <IsRequired>true</IsRequired>
            <QuestionContent>
              <Text>
                What are the coordinates of the best move for player "X" in this game?
              </Text>
            </QuestionContent>
            <AnswerSpecification>
              <FreeTextAnswer>
                <Constraints>
                  <Length minLength="2" maxLength="2" />
                </Constraints>
                <DefaultText>C1</DefaultText>
              </FreeTextAnswer>
            </AnswerSpecification>
          </Question>
</QuestionForm>