×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    25

    LWUIT XMLParser parsing content in CDATA

    I am using LWUIT for the Series 40 below.

    http://projects.developer.nokia.com/LWUIT_for_Series_40

    I need to parse a string similar to below:

    <key>title</key>
    <string><![CDATA[Status[CLOSED]]]></string>
    <key>thumbnail</key>
    <string><![CDATA[Hello World]]></string>

    However, I am unable to receive the correct content in textElement() below

    System.out output:
    Start tag=key
    textElement=title
    endTag=key
    Start tag=string
    textElement=Status[CLOSED]]]></string><key>thumbnail</key><string><![CDATA[Hello World
    endTag=string

    It seems the end of a CDATA which is a ']]>' pattern could not be detected.
    May I know what I do to fix this?

    More details about CDATA
    http://www.w3schools.com/xml/xml_cdata.asp

    Code:
    import com.sun.lwuit.xml.XMLParser;
    
    public class Parser extends XMLParser {
        
        protected void attribute(String tag, String attributeName, String value) {
            super.attribute(tag, attributeName, value);
        }
    
        protected void endTag(String tag) {
            System.out.println("endTag="+tag);
            super.endTag(tag);
            
        }
    
        protected boolean startTag(String tag) {
            System.out.println("Start tag="+tag);    
            return super.startTag(tag);
        }
    
        protected void textElement(String text) {
            System.out.println("textElement="+text);
            super.textElement(text);   
        }   
    }

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: LWUIT XMLParser parsing content in CDATA

    Yeah. I still do not know LWUIT, but I have been thinking that the problem comes from the 3 closing brackets, especially since the second closing tag was recognized.
    According to a Google search, LWUIT is open source and https://projects.developer.nokia.com...XMLParser.java seems to be in action. Line 503 calls a method parseCommentOrXMLDeclaration with "]]>" as closing sequence.
    And indeed parseCommentOrXMLDeclaration (line 741 in the same file) implements a classical parsing error: it does matching on a per-character basis, however when a non-matching character comes, the previous characters are not checked again.
    So the first ] comes, it is a match, the second ] comes, it is a match too. The third ] does not match to >, all characters (the previous ones and the current one) are appended to 'text', and the check starts again from scratch. The next character parsed from the input is going to be the >, which does not match with ] (the ]]> pattern is checked from the beginning again).
    As far as I understand LWUIT is something what is not on the phone, but you build into your application. If this is the case, as a quick workaround you can fix this bug for your own builds via extracting the LWUIT .jar file, and providing your own XMLParser class (but keeping the rest from the original code).
    A report has been filed as https://projects.developer.nokia.com...es_40/ticket/4

  3. #3
    Registered User
    Join Date
    Jul 2012
    Posts
    25

    Re: LWUIT XMLParser parsing content in CDATA

    Excellent! I am amazed with how helpful and responsive this forum is for Nokia developers.
    This has helped my work immensely!

    I currently have a very ugly code work around for the time being.
    However, I would really like to build my apps with official Nokia builds for easier build mgmt in the future.
    May I know how long it would take nokia to fix the issue? and create a new build? Thanks in advance.
    Thanks in advance.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: LWUIT XMLParser parsing content in CDATA

    It does not mean anything, but a couple minutes ago a remark has been added about that they will check it. Based on the other tickets, it may take weeks to have it fixed.

Similar Threads

  1. XML escaped content parsing
    By mstrug in forum Symbian C++
    Replies: 1
    Last Post: 2009-03-09, 11:23
  2. xml parsing : white space chars recognized as content
    By strike_noir in forum Symbian C++
    Replies: 5
    Last Post: 2008-06-13, 06:35
  3. Parsing file content
    By hendrawan.ashari in forum Symbian C++
    Replies: 7
    Last Post: 2007-03-09, 10:41
  4. Parsing the HTML content..?
    By mayankkedia in forum Symbian C++
    Replies: 2
    Last Post: 2007-02-21, 06:09

Posting Permissions

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