×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 device

    org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 device

    Hi,
    i'm parsing an simple XML with Sax in a Midlet :

    <?xml version="1.0" encoding="UTF-8"?>
    <Sample>
    <Category id="1" value="Users">
    <Record id="1" value="First">
    <item id="Name" type="String" maxLength="15" value="User1"/>
    <Item id="Language" type="String" maxLength="20" value="English"/>
    <Item id="City" type="String" maxLength="20" value="Rome"/>
    <Item id="Country" type="String" maxLength="10" value="Italy"/>
    </Record>
    </Category>
    </Sample>

    in emulators (S60 3rd FP1 and S40 5th) and real device Nokia N70 (S60 2nd FP3)
    and Nokia N73 (S60 3rd Ed.) all OK.

    But in Nokia N95 (S60 3rd FP1 with last firmware 20.0.015 13 Nov 07) the midlet keep org.xml.sax.SAXParseException
    without details message, afther "Record" tag.

    I thinks there is a big problem in SaxParser in S60 3rd Ed. FP1.
    Some one can help me ?
    I would not like to change J2me SaxParser with other open implementation.
    Thanks Roberto

    This a Midlet and Parse class source :

    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.SAXException;
    public class MidletXMLParse extends MIDlet implements CommandListener {

    private static final Command CMD_OK = new Command("Go", Command.SCREEN, 1);
    private static final Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
    private Display display;
    private Form mainForm;
    String XMLString = "";

    public void startApp() {

    display = Display.getDisplay(this);

    mainForm = new Form("XML Example");

    StringItem item = new StringItem("This is an XML Sample", "");
    mainForm.append(item);
    mainForm.addCommand(CMD_OK);
    mainForm.addCommand(CMD_EXIT);
    mainForm.setCommandListener(this);
    display.setCurrent(mainForm);
    }
    public void setXML() {
    XMLString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
    "<Sample>" +
    "<Category id=\"1\" value=\"Users\">" +
    "<Record id=\"1\" value=\"First\">" +
    "<item id=\"Name\" type=\"String\" maxLength=\"15\" value=\"User1\"/>" +
    "<Item id=\"Language\" type=\"String\" maxLength=\"20\" value=\"English\"/>" +
    "<Item id=\"City\" type=\"String\" maxLength=\"20\" value=\"Rome\"/>" +
    "<Item id=\"Country\" type=\"String\" maxLength=\"10\" value=\"Italy\"/>" +
    "</Record>" +
    "</Category>" +
    "</Sample>";
    }
    public void pauseApp() {
    }
    public void destroyApp(boolean unconditional) {
    }
    public void commandAction(Command arg0, Displayable arg1) {
    if (arg0 == CMD_OK) {
    try {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser saxParser = factory.newSAXParser();

    setXML();
    mainForm.append(new StringItem("XML=", XMLString));
    System.out.println("XML="+XMLString);

    InputStream is = new ByteArrayInputStream(XMLString.getBytes());
    ParserXML parserXML = new ParserXML();
    ParserXML.setForm(mainForm);
    saxParser.parse(is, parserXML);
    } catch (SAXException ex) {
    mainForm.append("Error:"+ex.toString());
    ex.printStackTrace();
    } catch (IOException ex) {
    mainForm.append("Error:"+ex.toString());
    ex.printStackTrace();
    } catch (ParserConfigurationException ex) {
    mainForm.append("Error:"+ex.toString());
    ex.printStackTrace();
    }

    } else {
    destroyApp(false);
    notifyDestroyed();
    }
    }
    }

    ---------------------------------------------------
    import java.io.*;
    import javax.microedition.lcdui.Form;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    public class ParserXML extends DefaultHandler {

    private String categoryId = null;
    private String categoryName = null;
    private String recordId = null;
    private String recordName = null;
    private String itemValue = null;
    private String itemName = null;
    private String itemType = null;
    private String itemMaxLength = null;
    static Form form;
    public void startDocument() throws SAXException {
    }
    public void endDocument() throws SAXException {
    debug("END Parser");
    }
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    debug("startElement:" + qName);
    if (qName.equalsIgnoreCase("Category")) {
    categoryId = attributes.getValue("id");
    categoryName = attributes.getValue("value");
    debug("Category name=" + categoryName);
    }
    if (qName.equalsIgnoreCase("Record")) {
    recordId = attributes.getValue("id");
    recordName = attributes.getValue("value");
    debug("Record=" + categoryName + "." + recordName);
    }
    if (qName.equalsIgnoreCase("Item")) {
    itemName = attributes.getValue("id");
    itemType = attributes.getValue("type");
    itemValue = attributes.getValue("value");
    itemMaxLength = attributes.getValue("maxLength");
    debug(itemName + ":" + itemType + "(" + itemMaxLength + ")=" + itemValue );
    }
    }

    public void characters(char[] ch, int start, int length) throws SAXException {
    }

    public void endElement(String uri, String localName, String qName) throws SAXException {
    debug("endElement:" + qName);
    if (qName.equalsIgnoreCase("Category"))
    {
    categoryId = "";
    categoryName = "";
    recordId = "";
    recordName = "";
    }
    if (qName.equalsIgnoreCase("Record"))
    {
    recordId = "";
    recordName = "";
    }
    }
    static void setForm(Form newForm) {
    form = newForm;
    }
    static void debug(String s) {
    System.out.println("DEBUG:" + s+ "\n");
    form.append(s+"\n");
    }
    }

    -------------------------------------
    Error of System.out :
    DEBUG:startElement:Sample
    DEBUG:startElement:Category
    DEBUG:Category name=Users
    DEBUG:startElement:Record
    DEBUG:Record=Users.First
    DEBUG:END Parser
    Errorrg.xml.sax.SAXParserException:

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    I solve problem using kXml library.
    I'm sure N95 have a big problem in Sax Xml parser.

    Bye Roberto

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    1

    Unhappy Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    I got the same problem, it works perfectly in the emulator, but on the N95 device it just gave a SAXParseException. Tracked it down to the attributes in the tag items. When using more than 3 attributes it gave an Exception and you probably got the same problem.

    Try to remove a attribute from the item tags, and it should work fine with the parser. However just crazy! Guess I have to change parser

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Smile Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Try kXml. With it you can do all, in very simple and performance way.

  5. #5
    Registered User
    Join Date
    Dec 2008
    Posts
    6

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    For what it is worth I have the same problem.

    Xml will not parse with S60 2nd Edition FP1 & FP2 .

    Xml parses fine with S60 3rd Edition and all other emulators.

    I think it is an issue with XML attributes.
    It is difficult to nail down what the parser is objecting to.
    Certainly there is nothing wrong with the Xml it is getting fed as it parses fine in other emulators :-<

  6. #6
    Registered User
    Join Date
    Dec 2008
    Posts
    6

    Talking Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    I had a problem last night with some Xml that would not parse on the N95 or in S60 3rd Edition FP2 Beta but would parse in S60 3rd Edition FP1.

    Looking at the element where the S60 parser had a 'panic' I noticed the attributes were in a different order.
    Rearranging attributes so that they are always in a consistent order allowed the Xml to be parsed on the N95 and S60 FP2.

    It looks like the attributes are always provided in the same order in the Xml below but something to watch out for.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Hello,

    I have same problem on N95. Error when parsing a document. On S60 3rd Ed. initial release works just fine. The document is parsed until a certain point then gets an exception.

    Same code works well on S60 3rd Ed. initial release.

    Muntergator, you found where the issue was? What do you mean by attributes order?

    Thanks a lot for your help!

  8. #8
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Hello,

    FYI, there is this (possibly related) Known Issue on Forum Nokia Knowledge Base: http://wiki.forum.nokia.com/index.ph...ops_characters

    The issue is about S60 3rd Ed., FP1 devices, therefore worth to check just in case.

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Hello,

    Thanks for the link but the XML I'm parsing does not contain any "]" nor "?". I have a regular XML, but is right that let's say I have

    <element1 attribute1="something" attribute2="something else">
    and somewhere else later on in the XML:
    <element2 attribute2="something blah" attribute1="something else blah">.

    Somehow when second element is reached there is an exception on N95.

    Could this be the problem? I mean not having attribute1 followed by attribute2 in all elements?

    Thanks

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    I solve problem using kXml (http://kxml.sourceforge.net/) library, and open source library to parse in very fast way an xml.

    It work in alway devices.

    Bye Roberto

  11. #11
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Thanks for the post Roberto,

    Have you tried this parser on other manufacturers as well: Sony Ericsson, BlackBerry, Nokia S40?

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Yes i try kXML with SonyEricsson,Samsung,LG,RIM Wireless Handheld (BlackBerry) and obviously Nokia (S40 e S60).
    I don't remember for Motorola.
    Bye Roberto

  13. #13
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Re: org.xml.sax.SAXParseException in parsing XML only in real Series 60 3rd FP1 devic

    Thanks again,

    I'll change the parser then. Too bad that this issue was not solved by Nokia on org.xml.sax parser.

Similar Threads

  1. mmfcodec.h in s60 3rd edition FP1
    By ecio83 in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2009-06-13, 13:22
  2. How to dump CommDb on the real device. Symbian s60 3rd
    By Hexxx in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2008-07-15, 12:27
  3. Replies: 6
    Last Post: 2007-12-17, 18:16
  4. Replies: 0
    Last Post: 2007-03-28, 08:59
  5. Series 60 SDK 1.0 for Symbian OS, xml parsing
    By alokkumarsingh in forum Symbian
    Replies: 0
    Last Post: 2004-03-19, 06:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×