metaleap / go-xsd

[stable since 2013] a lib for loading XML Schema Definition (XSD) files ➜ plus, a tool `makepkg` to code-generate from any *.xsd your Go package with all needed `struct`s to readily `xml.Unmarshal()` documents into, based on the XSD's schema definitions. NOT REALLY MAINTAINED FOR YEARS NOW: try the forks if running into issues.
http://www.reddit.com/r/golang/comments/12g6sl/is_there_a_tool_that_generates_go_source_code_for/
MIT License
216 stars 66 forks source link

Create a Golang struct from an XSD #16

Closed aresetian closed 7 years ago

aresetian commented 9 years ago

I want to create a Golang struct from an XSD (Structure XSD).

I've read the post http://stackoverflow.com/questions/20734450/generate-go-structs-from-xsd which recommend using go-xsd, but I have downloaded go-xsd and installed xsd-makepkg and I cannot generate my struct.

What I am doing?

xsd-makepkg -basepath="/Users/XSD_Access/" -goinst=false

-xsd-makepkg: it is the binary create from apart go-xsd-pkg
-basepath: Contains the route where I have Structure XSD that I want to transform to struct. -goinst : I have not installed go-buildrun and I think it is not neccesary , for that reason is ser false

What is the result of the command?

A folder($GOPATH/usr/Users/XSD_Access/) that contains other folders with all followers XML wrappers

Structure XSD

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:element name="Request" type="Request"/>
   <xs:complexType name="Request">
      <xs:annotation>
         <xs:documentation xml:lang="sp"><![CDATA[
        Comment xxxxx
     ]]></xs:documentation>
  </xs:annotation>
  <xs:sequence>
     <xs:element name="idOne" type="xs:string" minOccurs="0" maxOccurs="1">
      <xs:annotation>
     <xs:documentation xml:lang="sp"><![CDATA[Comment xxxxx
     ]]></xs:documentation>
      </xs:annotation>
    </xs:element>
         <xs:element name="idTwo" type="xs:string" minOccurs="0" maxOccurs="1">
  <xs:annotation>
     <xs:documentation xml:lang="sp"><![CDATA[Comment xxxxxx
     ]]></xs:documentation>
  </xs:annotation>
</xs:element>
  </xs:sequence>
   </xs:complexType>
</xs:schema>

Can anyone tell me what I am doing wrong or what step I missed that it does not let me create a struct from my Structure XSD?

Thanks in advance

thiloplanz commented 8 years ago

This has been cross-posted (and answered) at http://stackoverflow.com/questions/28052863/create-a-golang-struct-from-an-xsd

Should be closed here.