gnewton / chidley Goto Github PK
View Code? Open in Web Editor NEWConvert XML to Go structs / XML to JSON
License: Apache License 2.0
Convert XML to Go structs / XML to JSON
License: Apache License 2.0
Great tool, thanks for developing!
I have an XML file that includes a couple of mixed case xml tags, which causes tool to generate duplicate structs. Here is the example:
https://www.dropbox.com/s/0jqqyvvk1ll6nm9/gamedata.xml?dl=0
<cluster ContinentType="Outlands" ClusterQuality="High">
<RareState state="0" weight="1556" />
<RareState state="1" weight="400" />
<RareState state="2" weight="40" />
<RareState state="3" weight="4" />
</cluster>
and then later:
<Cluster default="0.05" minimum="0" maximum="0.05"/>
This causes duplicate structs to be generated in the xml. I know this xml probably isnt the best use case for chudley, but would be nice if it combined the 2 elements and generated code that still compiled.
Add a command line argument that allows a list of arbitrary, comma separated case tags to be ignored.
Hi Team,
Can you please guide me how to generate an executable for this.
When I am running go build chidley.go I am getting following errors.
./chidley.go:50: undefined: PrintGoStructVisitor
./chidley.go:234: undefined: Node
./chidley.go:234: undefined: FQN
./chidley.go:268: undefined: FQN
./chidley.go:315: undefined: Source
./chidley.go:378: undefined: XMLType
./chidley.go:378: undefined: Node
./chidley.go:398: undefined: Node
./chidley.go:406: undefined: PrintGoStructVisitor
./chidley.go:406: too many errors
Add a command line argument that allows lower case tags to be ignored.
The code that is generated with the -W flag does not include the values in the output JSON or XML. I tried this with my XML initially, but then with the examples that you provide. Here is a run of "test1" (minus the -f flag):
booty@limnognathia:gospace/src/github.com/gnewton/chidley$ ls
chidley data examples fqn.go jaxbTemplate.go mvnTemplate.go printGoStructVisitor.go source.go test_xml.sh xml
chidley.go decl.go extractor.go genericReader.go LICENSE node.go printJavaJaxbVisitor.go stdoutWriter.go util.go xml_source_test.go
codegenTemplates.go encoding_test.go fieldTemplate.go javaTypes.go makereadme nodeTypeInfo.go README.md tests_util.go util_test.go xml_test.go
booty@limnognathia:gospace/src/github.com/gnewton/chidley$ ./chidley -W xml/test1.xml > examples/test1/ChidTest1.go
booty@limnognathia:gospace/src/github.com/gnewton/chidley$ cd examples/test1/
booty@limnognathia:gospace/src/github.com/gnewton/chidley/examples/test1$ go build
booty@limnognathia:gospace/src/github.com/gnewton/chidley/examples/test1$ ls
ChidTest1.go test1
booty@limnognathia:gospace/src/github.com/gnewton/chidley/examples/test1$ ./test1 -x
<docs language="eng">
<doc type="book">
<author>
<firstName></firstName>
<last-name></last-name>
</author>
<title></title>
</doc>
<doc type="article">
<author>
<firstName></firstName>
<last-name></last-name>
</author>
<title></title>
</doc>
</docs>
booty@limnognathia:gospace/src/github.com/gnewton/chidley/examples/test1$ cat ../../xml/test1.xml
<?xml version="1.0"?>
<docs language="eng">
<doc type="book">
<title>Dune</title>
<author>
<last-name>Herbert</last-name>
<firstName>Frank</firstName>
</author>
</doc>
<doc type="article">
<title>Brave New Wold</title>
<author>
<last-name>Huxley</last-name>
<firstName>Aldous</firstName>
</author>
</doc>
</docs>
booty@limnognathia:gospace/src/github.com/gnewton/chidley/examples/test1$
The JSON output is similar in that the structure is all there, for the right number of elements, but the values themselves are missing.
Generate Java classes for JAXB to represent the input XML
When xml like this is encountered:
<credit-words default-x="1124" default-y="1393" font-size="12" font-weight="bold" halign="right" justify="center" valign="top" xml:space="preserve">Words and Music by J.Bach</credit-words>
The "xml:
" in xml:space
refers to a name space which is: http://www.w3.org/XML/1998/namespace
However, chidley
does not handle this properly, creating in a referencing struct:
AttrHttp://www.w3.org/XML/1998/namespaceSpace string `xml:"http://www.w3.org/XML/1998/namespace space,attr"`
Which does not compile due to the ': / .' characters in the variable name.
Instead, it should replace these characters in some canonical (if perhaps ugly) way, such as:
AttrHttp_colon__slash__slash_www_dot_w3_dot_org_slash_XML_slash_1998_slash_namespaceSpace xml:"http://www.w3.org/XML/1998/namespace space,attr"
Ugly like this to avoid accidental name clashes.
In addition to supporting the creation of Java/JAXB classes, also support the creation of ig-json-parser Java classes.
In case an XML element has CharData as well as (possibly multiple) sub-elements with the name Text
the resulting Go struct will have two fields called Text
, e.g.
type Foo struct {
Text []*Text `xml:"text,omitempty" json:"text,omitempty"`
Text string `xml:",chardata" json:",omitempty"`
}
`package main
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
)
type Query struct {
rpc Rpc_reply xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-reply,omitempty" json:"rpc-reply,omitempty"
}
type Addr_tag_list struct {
Addr_tag Addr_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 addr,omitempty" json:"addr,omitempty"
Pref_tag Pref_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 pref,omitempty" json:"pref,omitempty"
Tag Tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 tag,omitempty" json:"tag,omitempty"
Type_tag Type_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 type,omitempty" json:"type,omitempty"
VpcPeer_tag VpcPeer_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 vpcPeer,omitempty" json:"vpcPeer,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 Addr-list,omitempty" json:"Addr-list,omitempty"
}
type Dom_list struct {
If_items If_items xml:"urn:ietf:params:xml:ns:netconf:base:1.0 if-items,omitempty" json:"if-items,omitempty"
Name_tag Name_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 name,omitempty" json:"name,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 Dom-list,omitempty" json:"Dom-list,omitempty"
}
type If_list struct {
Addr_items_tag Addr_items_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 addr-items,omitempty" json:"addr-items,omitempty"
Id_tag Id_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 id,omitempty" json:"id,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 If-list,omitempty" json:"If-list,omitempty"
}
type Systemtag struct {
Ipv4_items Ipv4_items xml:"urn:ietf:params:xml:ns:netconf:base:1.0 ipv4-items,omitempty" json:"ipv4-items,omitempty"
Test_name Test_name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 test-name,omitempty" json:"test-name,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 System,omitempty" json:"System,omitempty"
}
type Addr_tag struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 addr,omitempty" json:"addr,omitempty"
}
type Addr_items_tag struct {
Addr_tag_list Addr_tag_list xml:"urn:ietf:params:xml:ns:netconf:base:1.0 Addr-list,omitempty" json:"Addr-list,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 addr-items,omitempty" json:"addr-items,omitempty"
}
type Data_tag struct {
Systemtag Systemtag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 System,omitempty" json:"System,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 data,omitempty" json:"data,omitempty"
}
type Dom_items struct {
Dom_list []Dom_list xml:"urn:ietf:params:xml:ns:netconf:base:1.0 Dom-list,omitempty" json:"Dom-list,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 dom-items,omitempty" json:"dom-items,omitempty"
}
type Id_tag struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 id,omitempty" json:"id,omitempty"
}
type If_items struct {
If_list []If_list xml:"urn:ietf:params:xml:ns:netconf:base:1.0 If-list,omitempty" json:"If-list,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 if-items,omitempty" json:"if-items,omitempty"
}
type Inst_items struct {
Dom_items Dom_items xml:"urn:ietf:params:xml:ns:netconf:base:1.0 dom-items,omitempty" json:"dom-items,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 inst-items,omitempty" json:"inst-items,omitempty"
}
type Ipv4_items struct {
Inst_items Inst_items xml:"urn:ietf:params:xml:ns:netconf:base:1.0 inst-items,omitempty" json:"inst-items,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 ipv4-items,omitempty" json:"ipv4-items,omitempty"
}
type Name_tag struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 name,omitempty" json:"name,omitempty"
}
type Pref_tag struct {
Text bool xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 pref,omitempty" json:"pref,omitempty"
}
type Rpc_reply struct {
Attr_message_id string xml:" message-id,attr" json:",omitempty"
Attr_xmlns string xml:" xmlns,attr" json:",omitempty"
Data_tag Data_tag xml:"urn:ietf:params:xml:ns:netconf:base:1.0 data,omitempty" json:"data,omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-reply,omitempty" json:"rpc-reply,omitempty"
}
type Tag struct {
Text bool xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 tag,omitempty" json:"tag,omitempty"
}
type Type_tag struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 type,omitempty" json:"type,omitempty"
}
type VpcPeer_tag struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 vpcPeer,omitempty" json:"vpcPeer,omitempty"
}
type Test_name struct {
Text string xml:",chardata" json:",omitempty"
XMLName xml.Name xml:"urn:ietf:params:xml:ns:netconf:base:1.0 test-name,omitempty" json:"test-name,omitempty"
}
func main() {
xmlFile, err := os.Open("interface.xml")
if err != nil {
fmt.Println("Error opening file:", err)
return
}
defer xmlFile.Close()
b, _ := ioutil.ReadAll(xmlFile)
var q Query
err2 := xml.Unmarshal(b, &q)
if err2 != nil {
fmt.Printf("error: %v", err2)
return
}
fmt.Println(q)
//#2fmt.Printf("%#v",q)
fmt.Printf("%s",q.rpc.Attr_message_id);
}`
The structs above were generated using Chidley, I have removed the Chi prefix and the pointers.
When I try printing anything, its just a blank. Only #2 gives me the XML structure. Rest all blank.
Sample of my interface.xml file:
<?xml version="1.0" encoding="UTF-8"?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"> <data> <System> <test-name>##WORK##</test-name> <ipv4-items> <inst-items> <dom-items> <Dom-list> <name>default</name> <if-items> <If-list> <id>eth5/8</id> <addr-items> <Addr-list> <addr>1.1.1.1</addr> <pref>1</pref> <tag>0</tag> <type>primary</type> <vpcPeer>0.0.0.0</vpcPeer> </Addr-list> </addr-items> </If-list> </if-items> </Dom-list> <Dom-list> <name>management</name> <if-items> <If-list> <id>eth5/8</id> <addr-items> <Addr-list> <addr>11.11.11.11</addr> <pref>1</pref> <tag>0</tag> <type>primary</type> <vpcPeer>0.0.0.0</vpcPeer> </Addr-list> </addr-items> </If-list> </if-items> </Dom-list> </dom-items> </inst-items> </ipv4-items> </System> </data> </rpc-reply>
Hi @gnewton,
I found that chidley generated source is having problem dealing with the Selenium IDE Xml source (e.g. this one):
chidley -W ~/l/t/Wordpress.html > /tmp/Wordpress.go
$ go run /tmp/Wordpress.go
Usage of /tmp/go-build915403080/command-line-arguments/_obj/exe/Wordpress:
-c Count each instance of XML tags
-f string
XML file or URL to read in (default "/path/to/l/t/Wordpress.html")
-h Usage
-j Convert to JSON
-s Stream XML by using XML elements one down from the root tag. Good for huge XML files (see http://blog.davidsingleton.org/parsing-huge-xml-files-with-go/
-x Convert to XML
$ go run /tmp/Wordpress.go -j ~/l/t/Wordpress.html
{
"html": {
"Space": "",
"Local": ""
}
}
Is it supposed to output this few?
It's a normal xml file of:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
...
Furthermore the -x Convert to XML
can't handle such files:
$ go run /tmp/Wordpress.go -x ~/l/t/Wordpress.html
error: main.ChiHtml field "AttrHttp_colon__slash__slash_www_dot_w3_dot_org_slash_XML_slash_1998_slash_namespaceLang" with tag "http://www.w3.org/XML/1998/namespace lang,attr" conflicts with field "AttrLang" with tag "lang,attr"
Would you look into it please?
[org.xml.sax.SAXParseException; systemId: file:/home/gnewton/gocode/src/github.com/gnewton/chidley/xml/ActorPreludeSample.xml; lineNumber: 2; columnNumber: 123; External DTD: Failed to read external DTD 'partwise.dtd', because 'http' access is not allowed due to restriction set by the accessExternalDTD property.]
Add (optional - false by default) ability to also have gorm tags for generated Go structs.
Right now Chidley merges all the child elements / attributes of each tag into a struct of the same name. Is there a way to tell it to keep separate XML elements instead of appending all the keys into a single master struct named the shared element name?
<root>
<children>
<sub>
<children>
<foo>...</foo>
</children>
</sub>
</children>
</root>
Creates a struct that looks like this:
type Children struct {
Sub ...
Foo ...
}
Instead of multiple structs
type Children struct {
Sub
}
type SubChildren struct {
Foo
}
Right now, only one XML file is used to build the XML 'model', so if it is missing some XML elements the model will be incomplete. However, if multiple XML files can be read and the union of them used to create the model, then elements that are in one but not in the other will be captured, and the model will be complete (actually, just more complete, i.e. as complete as all the XML files can make it)
Hi @gnewton, would parsing JSON more difficult than parsing XML? Is you internal structure for parsed XML make it easy to accept JSON as the source as well?
The reason I'm asking is that, of all JSON to Go Struct packages that I found, all of them has limitations [1] that made them impractical to be used, which after years haven't been fixed.
Thus I'm hoping you will extend chidley to support JSON someday. Thx.
[1] github.com/ChimeraCoder/gojson/issues/14
Adding some tests would be a good thing.
Given the following XML:
<cars>
<car>
<type>Ford</type>
<struct>small</struct>
</car>
<car>
<type>Honda</type>
<struct>medium</struct>
</car>
</cars>
Right now chidley assumes that the XML sample it is given might be incomplete, and assumes that all tags:
That is, while the following is XML provided:
<type>Honda</type>
chidley assumes that these might also exist:
<type type="foo">Honda</type>
or
<type><otherTag>Honda</otherTag></type>
And therefor generates additional structs instead of inlining strings:
type ChiCar struct {
ChiStruct *ChiStruct `xml:" struct,omitempty" json:"struct,omitempty"`
ChiType *ChiType `xml:" type,omitempty" json:"type,omitempty"`
}
type ChiCars struct {
ChiCar []*ChiCar `xml:" car,omitempty" json:"car,omitempty"`
}
type ChiStruct struct {
Text string `xml:",chardata" json:",omitempty"`
}
type ChiType struct {
Text string xml:",chardata" json:",omitempty"
}
If the user has provided sample XML that is complete, then the above is overkill.
The following should be generated instead:
type ChiCar struct {
ChiStruct string `xml:"struct,omitempty"`
ChiType string `xml:"type,omitempty"`
}
type ChiCars struct {
ChiCar []*ChiCar `xml:" car,omitempty" json:"car,omitempty"`
}
A command line argument should support this mode (false by default so as to not alter the default behaviour).
I have a snippet of XML that does something weird with the generated struct:
<con1:actions>
<con2:route xmlns:con2="http://www.bea.com/wli/sb/stages/routing/config">
<con3:id xmlns:con3="http://www.bea.com/wli/sb/stages/config">_ActionId-3525062221263473230--64db5972.154ce25275c.-7fc5</con3:id>
<con2:service ref="Something/Proxy/Something" xsi:type="ref:ProxyRef" xmlns:ref="http://www.bea.com/wli/sb/reference" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<con2:operation passThrough="true"/>
<con2:outboundTransform/>
<con2:responseTransform/>
</con2:route>
</con1:actions>
Generates this struct, with the duplicated Attr_ref
field:
type Chicon2_service struct {
Attr_ref string `xml:" ref,attr" json:",omitempty"`
Attr_ref string `xml:"xmlns ref,attr" json:",omitempty"`
Attr_xsi_type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr" json:",omitempty"`
Attr_xsi string `xml:"xmlns xsi,attr" json:",omitempty"`
XMLName xml.Name `xml:"http://www.bea.com/wli/sb/stages/routing/config service,omitempty" json:"service,omitempty"`
}
When attempting to build Chidley, the following error is output for me:
chidley-master laptop$ GOOS=darwin GOARCH=amd64 go build chidley.go
# command-line-arguments
./chidley.go:218:29: undefined: Node
./chidley.go:218:105: undefined: FQN
./chidley.go:252:43: undefined: FQN
./chidley.go:300:79: undefined: Source
./chidley.go:367:29: undefined: Node
./chidley.go:367:70: undefined: FQN
./chidley.go:367:79: undefined: XMLType
./chidley.go:390:34: undefined: Node
./chidley.go:398:27: undefined: PrintGoStructVisitor
./chidley.go:419:34: undefined: PrintGoStructVisitor
./chidley.go:419:34: too many errors
Some potential helpful information regarding environment:
laptop$ go version
go version go1.10 darwin/amd64
laptop$
laptop$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/laptop/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/laptop/Development/Go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/41/jf6b3x3d63q5w5my6h16q_f80000gq/T/go-build296077778=/tmp/go-build -gno-record-gcc-switches -fno-common"
As a user, I would like to run chidley
on XML files that contain statements like
<xi:include href="path/to/include/file.xml" />
and let chidley
generate Go structs for the XML with all includes resolved.
For small amounts of XML, and to allow cutting-and-pasting of a complete working (chidley generated) code into the Go Playground http://www.codata.info/canada/ , allow for the inclusion of the file XML as a string.
chidley:
generated code:
chidley is a very useful tool.
I'm trying it for the first time, but have found that its out order is inconsistent. Is it so?
-t
switch, but the outputs are incomparable as well because of the inconsistent ordering.Is it really so? Thx.
When using both -t
(use type information) and -F
(collapse simple tags), only the collapsing is occurring, with no changes due to type information.
Example XML:data/typeCollapsing.xm
<record>
<name>Bill Smith</name>
<age>42</age>
</record>
$chidley data/typeCollapsing.xml
type Cage struct {
XMLName xml.Name`xml:"age,omitempty" json:"age,omitempty"`
Text string `xml:",chardata" json:",omitempty"`
}
type Cname struct {
XMLName xml.Name`xml:"name,omitempty" json:"name,omitempty"`
Text string `xml:",chardata" json:",omitempty"`
}
type Crecord struct {
XMLName xml.Name`xml:"record,omitempty" json:"record,omitempty"`
Cage *Cage `xml:"age,omitempty" json:"age,omitempty"`
Cname *Cname `xml:"name,omitempty" json:"name,omitempty"`
}
This is correct.
-t
:$chidley -t data/typeCollapsing.xml
type Cage struct {
XMLName xml.Name`xml:"age,omitempty" json:"age,omitempty"`
Number int8 `xml:",chardata" json:",omitempty"`
}
type Cname struct {
XMLName xml.Name`xml:"name,omitempty" json:"name,omitempty"`
Text string `xml:",chardata" json:",omitempty"`
}
type Crecord struct {
XMLName xml.Name`xml:"record,omitempty" json:"record,omitempty"`
Cage *Cage `xml:"age,omitempty" json:"age,omitempty"`
Cname *Cname `xml:"name,omitempty" json:"name,omitempty"`
}
Note in Cage Number int8
instead of Cage Text string
This is correct.
$chidley -F data/typeCollapsing.xml
type Crecord struct {
XMLName xml.Name`xml:"record,omitempty" json:"record,omitempty"`
Cage string `xml:"age,omitempty" json:"age,omitempty"`
Cname string `xml:"name,omitempty" json:"name,omitempty"`
}
Cage
and Cname
are now variable fields not struct fields.
This is correct.
$chidley -F -t data/typeCollapsing.xml
type Crecord struct {
XMLName xml.Name`xml:"record,omitempty" json:"record,omitempty"`
Cage string `xml:"age,omitempty" json:"age,omitempty"`
Cname string `xml:"name,omitempty" json:"name,omitempty"`
}
This is not correct.
Cage string
should be Cage int8
This is a nice tool, and does save me some effort. That said, I'd like to be able to generate according to the suggestions provided by golint
to be compatible with the community conventions. For one small example, I have a stub that turns out to look like so:
type Chixml_fragment struct {
Chiser_coreEntry *Chiser_coreEntry `xml:"http://www.bea.com/wli/sb/services coreEntry,omitempty" json:"coreEntry,omitempty"`
Chiser_endpointConfig *Chiser_endpointConfig `xml:"http://www.bea.com/wli/sb/services endpointConfig,omitempty" json:"endpointConfig,omitempty"`
Chiser_router *Chiser_router `xml:"http://www.bea.com/wli/sb/services router,omitempty" json:"router,omitempty"`
}
But, it has a couple lint errors:
exported type Chixml_fragment should have comment or be unexported (golint)
don't use underscores in Go names; type Chixml_fragment should be ChixmlFragment (golint)
This gets much, much worse as you expand out, and the linter stops reporting after the first 70+ errors that it finds, all related to those two errors.
I would like to be able to specify a camelCase
convention for struct naming. Right now, OOTB, it generates an exported struct, which doesn't have documentation, and also includes underscores _
when it's not a convention used in Go.
Other than that, this thing works great!
When there are a large number of input XMl files (like 929 pubmed xml files) opening all the readers at the beginning wastes a lot of memory, especially when these readers are only used one at a time. In the pubmed example, memory usage spikes to 10GB at start right after all the bufios are created. Make it so only one is created at a time to reduce this memory load.
You're probably loving all of these issues...Sorry about that.
I found something that I'm not sure if it's a Go encoding/xml
error, or if there's something wrong with my XML. The following piece of XML
<ser:binding type="SOAP" isSoap12="false" xsi:type="con:SoapBindingType" xmlns:con="http://www.bea.com/wli/sb/services/bindings/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- other nested items -->
...
</ser:binding>
Generates the following struct:
type Chiser_binding struct {
Attr_con string `xml:"xmlns con,attr" json:",omitempty"`
Attr_isSoap12 string `xml:"isSoap12,attr" json:",omitempty"`
Attr_type string `xml:" type,attr" json:",omitempty"`
Attr_xsi_type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr" json:",omitempty"`
Attr_xsi string `xml:"xmlns xsi,attr" json:",omitempty"`
Chicon_WSI_compliant *Chicon_WSI_compliant `xml:"http://www.bea.com/wli/sb/services/bindings/config WSI-compliant,omitempty" json:"WSI-compliant,omitempty"`
Chicon_port *Chicon_port `xml:"http://www.bea.com/wli/sb/services/bindings/config port,omitempty" json:"port,omitempty"`
Chicon_selector *Chicon_selector `xml:"http://www.bea.com/wli/sb/services/bindings/config selector,omitempty" json:"selector,omitempty"`
Chicon_wsdl *Chicon_wsdl `xml:"http://www.bea.com/wli/sb/services/bindings/config wsdl,omitempty" json:"wsdl,omitempty"`
XMLName xml.Name `xml:"http://www.bea.com/wli/sb/services binding,omitempty" json:"binding,omitempty"`
}
However, when I unmarshal, I get the following error:
proxy_test.go:18: lint.Chiser_binding field "Attr_type" with tag " type,attr" conflicts with field "Attr_xsi_type" with tag "http://www.w3.org/2001/XMLSchema-instance type,attr"
Can this be done as is?
2017/03/02 14:42:29 extractor.go:58: xml: encoding "windows-1251" declared but Decoder.CharsetReader is nil
2017/03/02 14:42:29 chidley.go:151: FATAL ERROR: xml: encoding "windows-1251" declared but Decoder.CharsetReader is nil
for file like
<?xml version="1.0" encoding="windows-1251"?>
<data status="ok"><cont...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.