Gosu XSD error

197 views
Skip to first unread message

Claudio Tasso

unread,
Apr 8, 2012, 2:16:05 PM4/8/12
to gosu...@googlegroups.com
Hi guys,
I'm trying to execute a very simple Gosu program, but it doesn't work.
I'm using Gosu 0.9-12 (JDK 1.7) and I'm trying to reproduce what is documented at http://lazygosu.org/xml.html
In the main directory there are two files:
  • example.xsd
  • MyMain.gsp
example.xsd is taken from Gosu documentation and its content is the following:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Person">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="firstname" type="xs:string"/>
                <xs:element name="lastname" type="xs:string"/>
                <xs:element name="age" type="xs:int"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

The content of the Gosu program is the following:

var x = new example.Person();


The output is:

gw.lang.parser.exceptions.ParseResultsException: program_.__Program__251

Errors:

"example" is not a valid type. [line:3 col:13] in
line 2:
Line Number: 1  Column: 13

"example" is not a valid type. [line:3 col:13] in
line 2:
Line Number: 1  Column: 13


    at gw.internal.gosu.parser.ParserBase.verifyParsedElement(ParserBase.java:268)
    at gw.internal.gosu.parser.GosuClassParser.parseDefinitions(GosuClassParser.java:435)
    at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1409)
    at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1354)
    at gw.internal.gosu.parser.GosuClass.isValid(GosuClass.java:774)
    at gw.internal.gosu.parser.GosuProgram_Proxy.isValid(gw.internal.gosu.parser.GosuProgram_Proxy:2)
    at gw.internal.gosu.parser.GosuProgramParser.parseExpressionOrProgram(GosuProgramParser.java:130)
    at gw.internal.gosu.editor.EditorScriptHost.evaluate(EditorScriptHost.java:32)
    at gw.internal.gosu.editor.GosuPanel$58.run(GosuPanel.java:1839)
    at gw.internal.gosu.editor.util.TaskQueue.run(TaskQueue.java:243)


 

Dana Lank

unread,
Apr 8, 2012, 2:23:39 PM4/8/12
to gosu...@googlegroups.com
Hi Claudio,

The problem is that example.xsd is not in the Gosu classpath. I'd suggest placing it into a subdirectory, such as "xsd", then add "-classpath /path/to/xsd" to the Gosu command line. You should then be able to do "var x = new example.Person()"

Dana




 

--
You received this message because you are subscribed to the Google Groups "gosu-lang" group.
To view this discussion on the web visit https://groups.google.com/d/msg/gosu-lang/-/A0iHNL0f13UJ.
To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.

Claudio Tasso

unread,
Apr 8, 2012, 2:58:22 PM4/8/12
to gosu...@googlegroups.com
Hi Dana,
thank you very much for your reply.
I followed your advice, but it still doesn't work.
I created the following directory structure:

  • MyMain.gsp
  • xsd/example.xsd

and I tried to execute the following commands:

gosu -classpath C:/Users/Claudio/Gosu/src/miopackage/xsd MyMain.gsp

gosu -classpath C:\Users\Claudio\Gosu\src\miopackage\xsd MyMain.gsp

gosu -classpath xsd MyMain.gsp

but all of them fails with this output:

C:\Users\Claudio\Gosu\src\miopackage>gosu -classpath xsd MyMain.gsp
gw.lang.parser.exceptions.ParseResultsException: MyMain.gsp

Errors:

"xsd" is not a valid type. [line:3 col:13] in


line 2:
Line Number: 1  Column: 13

"xsd" is not a valid type. [line:3 col:13] in


line 2:
Line Number: 1  Column: 13


        at gw.internal.gosu.parser.ParserBase.verifyParsedElement(ParserBase.java:268)
        at gw.internal.gosu.parser.GosuClassParser.parseDefinitions(GosuClassParser.java:435)
        at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1409)
        at gw.internal.gosu.parser.GosuClass.compileDefinitionsIfNeeded(GosuClass.java:1354)
        at gw.internal.gosu.parser.GosuClass.isValid(GosuClass.java:774)
        at gw.internal.gosu.parser.GosuProgram_Proxy.isValid(gw.internal.gosu.parser.GosuProgram_Proxy:2)
        at gw.internal.gosu.parser.GosuProgramParser.parseExpressionOrProgram(GosuProgramParser.java:130)

        at gw.lang.Gosu$ExecuteMode.runWithFile(Gosu.java:792)
        at gw.lang.Gosu$ExecuteMode.run(Gosu.java:749)
        at gw.lang.Gosu.start(Gosu.java:87)
        at gw.lang.launch.GosuLauncher.run(GosuLauncher.java:116)
        at gw.lang.launch.GosuLauncher.main(GosuLauncher.java:46)








On Sunday, April 8, 2012 8:23:39 PM UTC+2, Dana Lank wrote:
Hi Claudio,

The problem is that example.xsd is not in the Gosu classpath. I'd suggest placing it into a subdirectory, such as "xsd", then add "-classpath /path/to/xsd" to the Gosu command line. You should then be able to do "var x = new example.Person()"

Dana

To unsubscribe from this group, send email to gosu-lang+unsubscribe@googlegroups.com.

Dana Lank

unread,
Apr 8, 2012, 3:12:43 PM4/8/12
to gosu...@googlegroups.com
I'm not sure then, one of the Gosu core guys can probably help you when they get online.

Dana

To view this discussion on the web visit https://groups.google.com/d/msg/gosu-lang/-/W1_0EMO9oKsJ.

To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.

Brian Chang

unread,
Apr 8, 2012, 8:30:18 PM4/8/12
to gosu...@googlegroups.com
Claudio:

You will need to have example.xsd in a package within that source directory (in this case, xsd/), and also either fully qualify your XSD type in your .gsp code or import it with a "uses" statement.

So you should have something like:
  MyMain.gsp
  xsd/claudio/example.xsd

And in your Gosu code in the .gsp,
  uses claudio.example.MyXsdType

Also, rather than using a -classpath parameter on the command line, you could put a classpath directive at the very top of the .gsp file:
  classpath "xsd"

If you're still having trouble, send me a zip directly of your starter project and I'll take a look.

Brian

Message has been deleted

Claudio Tasso

unread,
Apr 9, 2012, 11:57:33 AM4/9/12
to gosu...@googlegroups.com
Dear Brian,
you can find my simple project attached to this message.
Thank you very much for your help and your time.
miopackage.zip

Brian Chang

unread,
Apr 10, 2012, 12:52:42 AM4/10/12
to gosu...@googlegroups.com
Try adding a line at the top as such:
  classpath "remote:releases:gosu-lang.org-releases:http://gosu-lang.org/nexus/content/groups/releases"
While leaving your existing classpath line intact. This will make Gosu download the XML type loader library, which is no longer in the core distribution, and include it in the classpath. 

I'm at an airport at the moment so I haven't had a chance to verify the line I wrote. I'll do my best to get online soon and try it out. 

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "gosu-lang" group.
To view this discussion on the web visit https://groups.google.com/d/msg/gosu-lang/-/yMsYS2tJvaQJ.

To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.
<miopackage.zip>

Claudio Tasso

unread,
Apr 10, 2012, 1:48:05 AM4/10/12
to gosu...@googlegroups.com
Dear Brian,
you were right, the XML jar was missing in the classpath.
I tried the code below and it works:

classpath "xsd,c:/Tools/gosu-full-0.9-12/ext/gosu-xml-0.9-12.jar"

var x = new claudio.example.Person()


Thank you very much for your help.



On Tuesday, April 10, 2012 6:52:42 AM UTC+2, Brian Chang wrote:
Try adding a line at the top as such:
  classpath "remote:releases:gosu-lang.org-releases:http://gosu-lang.org/nexus/content/groups/releases"
While leaving your existing classpath line intact. This will make Gosu download the XML type loader library, which is no longer in the core distribution, and include it in the classpath. 

I'm at an airport at the moment so I haven't had a chance to verify the line I wrote. I'll do my best to get online soon and try it out. 

Sent from my iPhone
To unsubscribe from this group, send email to gosu-lang+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.
<miopackage.zip>

Brian Chang

unread,
Apr 10, 2012, 1:50:48 AM4/10/12
to gosu...@googlegroups.com
Yes, that works, but I recommend the approach I covered in my email a few minutes ago.  Best for your .gsp file not to have a file system path specific to your machine!


To view this discussion on the web visit https://groups.google.com/d/msg/gosu-lang/-/X2sHMIeF4FMJ.

To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.
Reply all
Reply to author
Forward
0 new messages