Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated code does not output values #35

Open
muncha opened this issue Sep 24, 2018 · 7 comments
Open

Generated code does not output values #35

muncha opened this issue Sep 24, 2018 · 7 comments

Comments

@muncha
Copy link

muncha commented Sep 24, 2018

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.

@muncha
Copy link
Author

muncha commented Sep 24, 2018

I see that you are in the process of updating the documentation, and that the -f flag code is commented out in in chidley.go, and that there is a slice of xml files in the generated code, so I am assuming that the current version simply doesn't need that flag. It throws an error if I include it of course. Perhaps I'm just doing this wrong and all will become clear when you publish your most recent documentation.

@gnewton
Copy link
Owner

gnewton commented Sep 28, 2018

Hello,

I will properly respond to your issue over the weekend. Sorry for the delay.

Thanks,
Glen

@lynchdavis
Copy link

Hi - I believe this is the same issue that I am currently experiencing. I generated all the data structures with the -G and then I tried with the -W for a standalone, and I do not get node values when the code runs, just empty nodes.

@NadjaVidnes
Copy link

Hi. I need both to generate values and to supply -f for witch file to convert. Is there any plans for this functionality?

@gnewton
Copy link
Owner

gnewton commented Nov 9, 2018

I am working on a branch to resolve these issues.
@lynchdavis Could you supply your XML so I can validate
@NadjaVidnes Let me look into this. So you want the generated code to have a '-f' so you can supply the file needed?

@lynchdavis
Copy link

lynchdavis commented Nov 10, 2018 via email

@payne8
Copy link

payne8 commented Mar 1, 2023

I noticed that the generated code using -G outputs the structs really well, but the base types for the low level values are all:

string string   `xml:",chardata" json:",omitempty"` // note the lower case string as the field name

since the field name is lower case they aren't being exported for use in the Marshal/Unmarshalling. I was able to get my stuff working simply by replacing all of the string string values with Value string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants