ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> Jython-users
Jython-users
[Jython-users] coercion error
by Andres Corrada-Emmanuel other posts by this author
Oct 31 2001 4:05PM messages near this date
Re: [Jython-users] equivalent of posixmodule.c in jython implementation? | [Jython-users] Exception handling ...
Hello,

I'm trying to set-up Jython to use the XML functionality in jaxp.jar and
parser.jar. The code fails with an error of the form:

TypeError: parse(): 1st arg can't be coerced to java.io.File,
org.xml.sax.InputSource, java.io.InputStream or String

The code is as follows:

    # Create new SAXParser
    factory = SAXParserFactory.newInstance()
    saxParser = factory.newSAXParser()

    # Create new handler
    handler = BookLibrary()

    # The test file to parse
    file = java.io.File('./books.xml')

    saxParser.parse( file, handler)

It seems that "parse" is being fed the class instance first, but I cannot
figure out how to do the call properly. Similar code works within Java
code, so I know classes are being recognized and have the required
methods.

Any clue what I'm doing wrong? Thank you.

Andres Corrada-Emmanuel
Senior Research Fellow
Center for Intelligent Information Retrieval
University of Massachusetts, Amherst


_______________________________________________
Jython-users mailing list
Jython-users@[...].net
https://lists.sourceforge.net/lists/listinfo/jython-users

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved