SlideShare uma empresa Scribd logo
1 de 69
Baixar para ler offline
Parsing XML in J2ME

                      Rohan Chandane
               rohan.chandane@indiatimes.com


These notes are created by me, Rohan Chandane as learning material while pursuing MSc(CA) from SICSR 2005-2007 (CC)
Parse XML in
a MIDP client application
Multi-tier System Architecture
Typical multi-tier architecture
 In web-centric systems
   Clients - HTML browsers
   Server - Serving HTML over HTTP &
   Applications which uses a database for
   persistent storage.
Continued…
 Wireless
   Client - Browser as front end application
   Server - serving WML over WAP
Standalone Client Approach
 It can communicate in different ways
 with server
   HTTP connection
   RMI as RPC
   Any customized protocol
MIDP Client
 Advantage
  Provide a richer user interface
  Run offline
  Make updates to the server periodically
 Disadvantage
  Difficulty of client installation
  Maintenance
MIDP Client
 Has following limitations
   Network connection setup is slow.
   Data rates are slow.
   The processor is slow.
   Memory is scarce
Multi-tier System Architecture
with MIDP Client
A multi-tier architecture: with
use of XML
 Server side code/application returns
 data as XML document
   No need to write custom server-side code
   for each client type
   One way to supporting multiple client types
   XML document can be transformed using
   XSLT into whatever client requirement. e.g.
     HTML for desktop browses
     WML for WAP browses
Continued…
  XML can be a data exchange format
    XML can be send as it is
     or
    With some with simple transformation to send
    more terse (brief and up to the point) XML
    format.
Continued…
  Advantages of XML
    Data is self-describing
    Opportunity to loosely couple the client and
    server
       loosely couple: even if they use incompatible system
       technologies, can be joined together on demand to
       create composite services, or disassembled just as
       easily into their functional components
    During development, XML parsing can be
    validated using emulator, before running it on
    application on MIDP device.
Continued…
  Disadvantages of XML
    Not a very efficient way of expressing data
    On slow wireless networks, before using XML
    as a data exchange format, have to do some
    real device testing.
    (cause now a days latency is issue than
    transfer rate)
Parser Overview
 Small size phone need small size
 application
   Application and other required files should
   not exceed particular size limit for MIDP
   device (normally 128kb)
Continued…
 Parser must be of small and light
   Parser are traditionally bulky
     Featuring lots of code.
     Hefty (large amount of) runtime memory
     requirements.
   Open source parsers are attractive
     Can customize it if need additional features.
     Can fix the parser if it has bugs.
Parser Types
 3 Fundamental Types
   A Model parser
   A Push parser
   A Pull parser
 Choosing a parser is depends on
   Application behavior
   Types of documents to be parsed
Continued…
 A model parser
   Reads an entire document
   Creates a representation of the document
   in memory
   Use significantly more memory than other
   types of parsers
   This is how the popular DOM-based parser
   operates
Continued…
 A push parser
   Reads through an entire document.
   As it encounters various parts of the
   document, it notifies a listener object.
   Use comparative much memory and
   processing power
   This is how the popular SAX API operates.
Continued…
 A pull parser
   Reads a little bit of a document at once.
   Parser goes through the document by
   repeatedly requesting the next piece.
   Best suitable for J2ME application as take
   comparatively less memory and processing
   than other type of parser
XML Parser
 An XML processing model describes the
 steps an application should take to
 process XML
 This model is called XML Parser
 Java API for XML Processing (JAXP)
   This is used to integrate an XML parser
   into your Java applications
   Mostly used with J2EE
Current offering of small XML
   parsers for MIDP
1DPH                             /LFHQVH                  6L]H              0,'3              7SH
                                                                                              SXVK
ASXMLP 020308                    Modified BSD              N%              HV                  PRGHO

kXML 2.0 alpha                   EPL                       N%              HV               SXOO

kXML 1.2                         EPL                       N%             HV               SXOO

MinML 1.7                        BSD                       N%             QR                SXVK

NanoXML 1.6.4                    zlib/libpng               N%             SDWFK             PRGHO

TinyXML 0.7                      GPL                       N%             QR                PRGHO

Xparse-J 1.1                     GPL                       N%              HV               PRGHO
Size: size of the class file MIDP: whether the parser will compile without modifications in a MIDP environment
                           Parsers represent the current offerings in the MIDP 1.0 world
Frequently used XML parsers
 For resource-constrained devices
   kXML
     Written exclusively for the J2ME platform
     (CLDC and MIDP).
   NanoXML
     Version 1.6.8 for MIDP, supports DOM parsing.
Incorporation a parser into
MIDlet suite
 If parsers are .java files
   Place these files into the src directory of
   your J2MEWTK project
 If parsers are .jar or .zip archive of
 .class files
   Place the archive in the lib directory of the
   J2MEWTK project.
Performance
 MIDlet code run well in a constrained
 environment
   If XML parser used, code will become
   significantly bigger and slower.
   Code optimization can be the solution
The optimizations
  Three Categories of optimizations
    Runtime performance
    User perception
    Deployment code size
1. Runtime performance
 While designing XML document
  Long time to set up a network connection
  XML Document sent to a MIDlet should
  contain useful information
    Aggregate documents on the server side and
    send one larger document.
  Too large document will keep user waiting
  for long time.
Continued…
 Find a balance between
   Avoiding connection setup times
    and
   Minimizing download wait times
2. User perception/experience
 Do not lock-up UI While the MIDlet is
   Parsing an XML document
   Reading the document from the network
 User can allow to perform offline tasks
 while network activities
3. Deployment code size
 Concern : size of your MIDlet suite JAR
 Three Problems
   Less space on MIDP device
   Downloading application over network is
   slow
   XML Parsing adds intensive string parsing,
   which adds overhead in MIDP applications
Continued…
 Solution: Use of obfuscator (alter)
   MIDlet suite JAR contains
     Class files, images, icons  other resource files
   Obfuscator has following features
     Removes unused classes
     Removes unused methods and variables
     Renames classes, packages, methods, and
     variables
Continued…
  These features are fine and will reduce the
  size of your MIDlet suite JAR
    Example: if incorporated an XML parser in your
    MIDlet project, there may be parts of the
    parser that application never uses.
    An obfuscator is good for pruning (cut back)
    out the stuff don't need.
Use of obfuscator
Continued…
  To use obfuscator, it need proguard.jar file
  to get it, do the following
    Go to http://proguard.sourceforge.net/.
    Select the quot;Downloadquot; link.
     Select quot;Download sectionquot;.
     Choose the latest version of proguard.zip and
    save it to yours disk.
    Extract the proguard.jar file from proguard.zip
    into the bin subdirectory of the WTK.
ProGuard
 What is ProGuard
   A free Java class file shrinker, optimizer,
   and obfuscator
   It can detect and remove unused classes,
   fields, methods, and attributes
   It can then optimize bytecode and remove
   unused instructions
Continued…
  It can rename the remaining classes,
  fields, and methods using short
  meaningless name
  The resulting jars are smaller and harder to
  reverse-engineer
Integrate ProGuard with WTK
 ProGuard plug-in can be seamlessly
 integrated in the Sun J2ME Wireless
 Toolkit (WTK)
 Edit in the file
   {WTK_DIR}/wtklib/Linux/ktools.properties
    or
   {WTK_DIR}wtklibWindowsktools.properti
   es
Continued…
   Put these lines in above file (for windows)
 obfuscator.runner.class.name: proguard.wtk.ProGuardObfuscator
 obfuscator.runner.classpath: wtklibproguard3.6libproguard.jar

   Uncompress the zip file to
       {WTK_DIR}wtklibproguard3.6
   To apply it on projects
       Open project in WTK
          go to
       Project - Package - Create Obfuscated
       Package
After using it…
XML Parsing with kXML in
   J2ME application
Purpose
 A J2ME application, ParseXML, that
 parses XML documents
 Displays the information encoded in
 those documents on a phone screen
Requirements
 J2ME Wireless Toolkit 2.2
   http://java.sun.com/products/sjwtoolkit/do
   wnload-2_2.html
 SDK of J2SE, J2EE
 kXML Parser 1.2
   http://kxml.objectweb.org/software/downl
   oads/
 Any ASCII/Unicode Editor
Installation
 Install J2SD  J2EE
 Install WTK 2.2
 Place kxml.zip file in following directory
   {WTK_DIR}/apps/{Project_Folder}/lib
XML file
 ?xml version=quot;1.0quot;?
 testXML
         fnameRohan/fname
         lnameChandane/lname
 /testXML



 This XML will be parsed by J2ME
 applications and it will extract data from
 tags fname  lname
Continued…
 XML data is made available MIDP
 application (ParseXML) in the form of a
 String, using any server side technology
 Server side technology preferably
 should be Java(J2EE), so it will be
 better for integration
 We can also use PHP, Ruby, ASP.net
 instead
J2EE Application
 Firstly, for generating XML we will
 create J2EE application
 We will use NetBeans 5.0 as J2EE IDE
 Follow the steps ahead -
Select Category : Web
File   New Project…   Select Project : Web Application
Project Name : J2EEXMLParsing
Select Location : As you want   Press Finish
Double Click on Source Packages in Projects
Create new servlet : Right Click on Default Package, New   Servlet…
Write Class Name : GeneralXML   Press Next
Press Finish
Default Package will show GenerateXML.java
A new tab will show code of GenerateXML.java
Write a code for generating XML string as show in red square
Content type : text/xml , This will generate content of page as XML
Right Click in code window and Click Run File Menu
Press OK
Here is XML String generated and displayed in Browser
Address in red square need to call by MIDP application to retrive XML String
J2ME Application
 Secondly, for reading XML we will
 create J2ME application
 We will use Wireless Toolkit 2.2 as
 J2ME IDE  text editor
 Follow the steps ahead -
Writing a Java code
 We need to know
   MIDP GUI programming
     Use of javax.microedition.lcdui classes
   J2ME network programming
     Use of javax.microedition.io classes
     Use of java.io classes
   kXML XML parsing Programming
     Use of org.kxml.parse classes
MIDP GUI programming
 To display XML data, we require
   import javax.microedition.midlet.*;
   import javax.microedition.lcdui.*;
   Class neet to extend ‘MIDlet’ as a super
   class
   Use of classes
     Display
     TextBox
Continued…
     Here is the code
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class ParseXML extends MIDlet
{
                 private Display display;
                 public ParseXML()
                 {
                                  display = Display.getDisplay(this);
                 }

                public void startApp()
                {
                                 TextBox t = new TextBox(quot;XML Dataquot;,quot;Here, will be displyed data extracted from XMLquot;, 1024, 0);
                                 display.setCurrent(t);
                }

                public void pauseApp() { }
                public void destroyApp(boolean unconditional) { }
}
J2ME network programming
 To get XML data over network using
 HTTP, we require
   import javax.microedition.io classes
   import java.io classes
   Use of classes
     HttpConnection
        Using Server URL, to get XML Stream -
        http://localhost:8084/J2EEXMLParseing/GenerateXML
     InputStreamReader
Continued…
 import javax.microedition.midlet.*;
 import javax.microedition.lcdui.*;

 import javax.microedition.io.*;
 import java.io.*;

 public class ParseXML extends MIDlet
 {
                  private Display display;
                  private String url = quot;http://localhost:8084/J2EEXMLParseing/GenerateXMLquot;;

                 public ParseXML()
                 {
                                display = Display.getDisplay(this);
                 }

                 public void startApp()
                 {
                                  try
                                  {
                                              downloadPage(url);
                                 }
                                 catch(IOException ioe)
                                 {
                                              System.out.println(quot;Error : quot; + ioe);
                                 }
                 }

                 public void pauseApp() {}
                 public void destroyApp(boolean unconditional) {}

                 private void downloadPage(String url) throws IOException
                 {
                                HttpConnection conn = (HttpConnection)Connector.open(url);
                                InputStreamReader doc = new InputStreamReader(conn.openInputStream());
                 }
 }
kXML XML parsing
 To use kXML parsing classes, methods
 we require –
   import org.kxml classes
   import org.kxml.parser classes
   Use of classes
     XmlParser
     ParseEvent
Continued…                                                                                           Check code below


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import javax.microedition.io.*;
import java.io.*;

import org.kxml.*;
import org.kxml.parser.*;

public class ParseXML extends MIDlet
{
                 private Display display;
                 private String url = quot;http://localhost:8084/J2EEXMLParseing/GenerateXMLquot;;

                public ParseXML()
                {
                               display = Display.getDisplay(this);
                }

                public void startApp()
                {
                                 try
                                 {
                                                 downloadPage(url);
                                  }
                                  catch(IOException ioe)
                                  {
                                                 System.out.println(quot;Error : quot; + ioe);
                                  }
                }

                public void pauseApp() {}
                public void destroyApp(boolean unconditional) {}

                private void downloadPage(String url) throws IOException
                {
                                HttpConnection conn = (HttpConnection)Connector.open(url);
                                InputStreamReader doc = new InputStreamReader(conn.openInputStream());
Code explanation
 XmlParser parser = new XmlParser(doc);
   This will create object of XmlParser and will
   read InputStreamReader doc, XML stream
   which we got from HttpConnection from
   server
 ParseEvent event = parser.read();
   This will create ParseEvent object event,
   which will read all events from XmlParser
   object parser
Continued…
 ParseEvent object’s method
   getType() - returns the event type integer
   constant assigned to this event
     These are possible event types:
        Xml.START_TAG
        Xml.END_TAG
        Xml.TEXT
        Xml.WHITESPACE
        Xml.COMMENT
        Xml.PROCESSING_INSTRUCTION
        Xml.DOCTYPE
        Xml.END_DOCUMENT
Continued…
  getName() - returns the (local) name of
  the element started if instance of StartTag,
  null otherwise
    example - If element start tag is fname,
    then event.getName() it will return fname
Continued…
  getText() - returns a String, if event types
  are
    TEXT
    PROCESSING_INSTRUCTION
    DOCTYPE
  for rest events, it returns null
RSS: Rich Site Summary
Simple XML format that summarizes
headlines and story descriptions for a news
site

Mais conteúdo relacionado

Mais procurados

Aceleracion de aplicacione 2
Aceleracion de aplicacione 2Aceleracion de aplicacione 2
Aceleracion de aplicacione 2jfth
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to PostgresEDB
 
Migration DB2 to EDB - Project Experience
 Migration DB2 to EDB - Project Experience Migration DB2 to EDB - Project Experience
Migration DB2 to EDB - Project ExperienceEDB
 
Introduction to Microsoft's Big Data Platform and Hadoop Primer
Introduction to Microsoft's Big Data Platform and Hadoop PrimerIntroduction to Microsoft's Big Data Platform and Hadoop Primer
Introduction to Microsoft's Big Data Platform and Hadoop PrimerDenny Lee
 
Whats new in Oracle Database 12c release 12.1.0.2
Whats new in Oracle Database 12c release 12.1.0.2Whats new in Oracle Database 12c release 12.1.0.2
Whats new in Oracle Database 12c release 12.1.0.2Connor McDonald
 
An Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformAn Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformMongoDB
 
Key Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to PostgresKey Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to PostgresEDB
 
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...Trivadis
 
New life inside monolithic application
New life inside monolithic applicationNew life inside monolithic application
New life inside monolithic applicationTaras Matyashovsky
 
Spark For Faster Batch Processing
Spark For Faster Batch ProcessingSpark For Faster Batch Processing
Spark For Faster Batch ProcessingEdureka!
 
SQL Server Reporting Services: IT Best Practices
SQL Server Reporting Services: IT Best PracticesSQL Server Reporting Services: IT Best Practices
SQL Server Reporting Services: IT Best PracticesDenny Lee
 
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...timfanelli
 
Database@Home : Data Driven Apps : Core-dev or Low Code UI
Database@Home : Data Driven Apps : Core-dev or Low Code UIDatabase@Home : Data Driven Apps : Core-dev or Low Code UI
Database@Home : Data Driven Apps : Core-dev or Low Code UITammy Bednar
 
Database Cloud Services Office Hours : Oracle sharding hyperscale globally d...
Database Cloud Services Office Hours : Oracle sharding  hyperscale globally d...Database Cloud Services Office Hours : Oracle sharding  hyperscale globally d...
Database Cloud Services Office Hours : Oracle sharding hyperscale globally d...Tammy Bednar
 
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBase
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBaseHBaseCon 2015: Trafodion - Integrating Operational SQL into HBase
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBaseHBaseCon
 
Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Sid Anand
 

Mais procurados (20)

Aceleracion de aplicacione 2
Aceleracion de aplicacione 2Aceleracion de aplicacione 2
Aceleracion de aplicacione 2
 
Migrating from Oracle to Postgres
Migrating from Oracle to PostgresMigrating from Oracle to Postgres
Migrating from Oracle to Postgres
 
Migration DB2 to EDB - Project Experience
 Migration DB2 to EDB - Project Experience Migration DB2 to EDB - Project Experience
Migration DB2 to EDB - Project Experience
 
Introduction to Microsoft's Big Data Platform and Hadoop Primer
Introduction to Microsoft's Big Data Platform and Hadoop PrimerIntroduction to Microsoft's Big Data Platform and Hadoop Primer
Introduction to Microsoft's Big Data Platform and Hadoop Primer
 
NetWeaver Gateway- Introduction to OData
NetWeaver Gateway- Introduction to ODataNetWeaver Gateway- Introduction to OData
NetWeaver Gateway- Introduction to OData
 
Practical OData
Practical ODataPractical OData
Practical OData
 
PASS Summit 2020
PASS Summit 2020PASS Summit 2020
PASS Summit 2020
 
Whats new in Oracle Database 12c release 12.1.0.2
Whats new in Oracle Database 12c release 12.1.0.2Whats new in Oracle Database 12c release 12.1.0.2
Whats new in Oracle Database 12c release 12.1.0.2
 
An Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media PlatformAn Elastic Metadata Store for eBay’s Media Platform
An Elastic Metadata Store for eBay’s Media Platform
 
Key Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to PostgresKey Methodologies for Migrating from Oracle to Postgres
Key Methodologies for Migrating from Oracle to Postgres
 
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
TechEvent 2019: Status of the partnership Trivadis and EDB - Comparing Postgr...
 
New life inside monolithic application
New life inside monolithic applicationNew life inside monolithic application
New life inside monolithic application
 
Spark For Faster Batch Processing
Spark For Faster Batch ProcessingSpark For Faster Batch Processing
Spark For Faster Batch Processing
 
SQL Server Reporting Services: IT Best Practices
SQL Server Reporting Services: IT Best PracticesSQL Server Reporting Services: IT Best Practices
SQL Server Reporting Services: IT Best Practices
 
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
 
Database@Home : Data Driven Apps : Core-dev or Low Code UI
Database@Home : Data Driven Apps : Core-dev or Low Code UIDatabase@Home : Data Driven Apps : Core-dev or Low Code UI
Database@Home : Data Driven Apps : Core-dev or Low Code UI
 
Azure Databases with IaaS
Azure Databases with IaaSAzure Databases with IaaS
Azure Databases with IaaS
 
Database Cloud Services Office Hours : Oracle sharding hyperscale globally d...
Database Cloud Services Office Hours : Oracle sharding  hyperscale globally d...Database Cloud Services Office Hours : Oracle sharding  hyperscale globally d...
Database Cloud Services Office Hours : Oracle sharding hyperscale globally d...
 
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBase
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBaseHBaseCon 2015: Trafodion - Integrating Operational SQL into HBase
HBaseCon 2015: Trafodion - Integrating Operational SQL into HBase
 
Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)Big Data, Fast Data @ PayPal (YOW 2018)
Big Data, Fast Data @ PayPal (YOW 2018)
 

Destaque

Videos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQueryVideos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQueryMahantesh Devoor
 
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...Wojciech Podgórski
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARStephan Schmidt
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming LanguageMahantesh Devoor
 
Beginner’s Guide to Windows Installer XML (WiX)
Beginner’s Guide to Windows Installer XML (WiX)Beginner’s Guide to Windows Installer XML (WiX)
Beginner’s Guide to Windows Installer XML (WiX)Alek Davis
 
Database system concepts
Database system conceptsDatabase system concepts
Database system conceptsKumar
 
Xml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelXml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelDuncan Davies
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up ParsingGerwin Ocsena
 
Introduction to Cloud Computing
Introduction to Cloud Computing Introduction to Cloud Computing
Introduction to Cloud Computing CloudSyntrix
 
Efficient processing of large and complex XML documents in Hadoop
Efficient processing of large and complex XML documents in HadoopEfficient processing of large and complex XML documents in Hadoop
Efficient processing of large and complex XML documents in HadoopDataWorks Summit
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computingRkrishna Mishra
 

Destaque (18)

Videos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQueryVideos indexing and retrieval using XML/XQuery
Videos indexing and retrieval using XML/XQuery
 
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...
eXtensible Markup Language APIs in Java 1.6 - Simple and efficient XML parsin...
 
XML
XMLXML
XML
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEAR
 
Xml parsing
Xml parsingXml parsing
Xml parsing
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Database Concepts
Database ConceptsDatabase Concepts
Database Concepts
 
Beginner’s Guide to Windows Installer XML (WiX)
Beginner’s Guide to Windows Installer XML (WiX)Beginner’s Guide to Windows Installer XML (WiX)
Beginner’s Guide to Windows Installer XML (WiX)
 
MySQL Database with phpMyAdmin
MySQL Database with  phpMyAdminMySQL Database with  phpMyAdmin
MySQL Database with phpMyAdmin
 
Database system concepts
Database system conceptsDatabase system concepts
Database system concepts
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
Xml Publisher And Reporting To Excel
Xml Publisher And Reporting To ExcelXml Publisher And Reporting To Excel
Xml Publisher And Reporting To Excel
 
Top down and botttom up Parsing
Top down     and botttom up ParsingTop down     and botttom up Parsing
Top down and botttom up Parsing
 
Cloud Computing by AGDMOUN Khalid
Cloud Computing by AGDMOUN KhalidCloud Computing by AGDMOUN Khalid
Cloud Computing by AGDMOUN Khalid
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Introduction to Cloud Computing
Introduction to Cloud Computing Introduction to Cloud Computing
Introduction to Cloud Computing
 
Efficient processing of large and complex XML documents in Hadoop
Efficient processing of large and complex XML documents in HadoopEfficient processing of large and complex XML documents in Hadoop
Efficient processing of large and complex XML documents in Hadoop
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computing
 

Semelhante a Parsing XML in J2ME

What Have We Lost - A look at some historical techniques
What Have We Lost - A look at some historical techniquesWhat Have We Lost - A look at some historical techniques
What Have We Lost - A look at some historical techniquesLloydMoore
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5Peter Lawrey
 
A two stage feature selection method for text categorization
A two stage feature selection method for text categorizationA two stage feature selection method for text categorization
A two stage feature selection method for text categorizationParag Tamhane
 
Big data Argentina meetup 2020-09: Intro to presto on docker
Big data Argentina meetup 2020-09: Intro to presto on dockerBig data Argentina meetup 2020-09: Intro to presto on docker
Big data Argentina meetup 2020-09: Intro to presto on dockerFederico Palladoro
 
WS-VLAM workflow
WS-VLAM workflowWS-VLAM workflow
WS-VLAM workflowguest6295d0
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch Joshua
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application sizeKeval Patel
 
Node JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applicationsNode JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applicationsExpeed Software
 
Leo's Notes about Apache Kafka
Leo's Notes about Apache KafkaLeo's Notes about Apache Kafka
Leo's Notes about Apache KafkaLéopold Gault
 
SERVER SIDE SCRIPTING
SERVER SIDE SCRIPTINGSERVER SIDE SCRIPTING
SERVER SIDE SCRIPTINGProf Ansari
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupMickaël Rémond
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkbanq jdon
 

Semelhante a Parsing XML in J2ME (20)

8023.ppt
8023.ppt8023.ppt
8023.ppt
 
What Have We Lost - A look at some historical techniques
What Have We Lost - A look at some historical techniquesWhat Have We Lost - A look at some historical techniques
What Have We Lost - A look at some historical techniques
 
Low latency in java 8 v5
Low latency in java 8 v5Low latency in java 8 v5
Low latency in java 8 v5
 
A two stage feature selection method for text categorization
A two stage feature selection method for text categorizationA two stage feature selection method for text categorization
A two stage feature selection method for text categorization
 
Big data Argentina meetup 2020-09: Intro to presto on docker
Big data Argentina meetup 2020-09: Intro to presto on dockerBig data Argentina meetup 2020-09: Intro to presto on docker
Big data Argentina meetup 2020-09: Intro to presto on docker
 
WS-VLAM workflow
WS-VLAM workflowWS-VLAM workflow
WS-VLAM workflow
 
X Usax Pdf
X Usax PdfX Usax Pdf
X Usax Pdf
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Decrease build time and application size
Decrease build time and application sizeDecrease build time and application size
Decrease build time and application size
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
 
An Optics Life
An Optics LifeAn Optics Life
An Optics Life
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
 
Ajaxworld West 08
Ajaxworld West 08Ajaxworld West 08
Ajaxworld West 08
 
Infrastructure Strategies 2007
Infrastructure Strategies 2007Infrastructure Strategies 2007
Infrastructure Strategies 2007
 
Node JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applicationsNode JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applications
 
Leo's Notes about Apache Kafka
Leo's Notes about Apache KafkaLeo's Notes about Apache Kafka
Leo's Notes about Apache Kafka
 
Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
 
SERVER SIDE SCRIPTING
SERVER SIDE SCRIPTINGSERVER SIDE SCRIPTING
SERVER SIDE SCRIPTING
 
A vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF MeetupA vision for ejabberd - ejabberd SF Meetup
A vision for ejabberd - ejabberd SF Meetup
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 

Mais de Rohan Chandane

Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Rohan Chandane
 
Agile & Scrum, Certified Scrum Master! Crash Course
Agile & Scrum,  Certified Scrum Master! Crash CourseAgile & Scrum,  Certified Scrum Master! Crash Course
Agile & Scrum, Certified Scrum Master! Crash CourseRohan Chandane
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications Rohan Chandane
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so farRohan Chandane
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptRohan Chandane
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideRohan Chandane
 
Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Rohan Chandane
 
Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2MERohan Chandane
 

Mais de Rohan Chandane (13)

Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!Agile Maturity Model, Certified Scrum Master!
Agile Maturity Model, Certified Scrum Master!
 
Agile & Scrum, Certified Scrum Master! Crash Course
Agile & Scrum,  Certified Scrum Master! Crash CourseAgile & Scrum,  Certified Scrum Master! Crash Course
Agile & Scrum, Certified Scrum Master! Crash Course
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
Agile :what i learnt so far
Agile :what i learnt so farAgile :what i learnt so far
Agile :what i learnt so far
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Node js
Node jsNode js
Node js
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScript
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS Guide
 
Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)Blogger's Park Presentation (Blogging)
Blogger's Park Presentation (Blogging)
 
J2ME GUI Programming
J2ME GUI ProgrammingJ2ME GUI Programming
J2ME GUI Programming
 
J2ME RMS
J2ME RMSJ2ME RMS
J2ME RMS
 
J2ME IO Classes
J2ME IO ClassesJ2ME IO Classes
J2ME IO Classes
 
Java2 MicroEdition-J2ME
Java2 MicroEdition-J2MEJava2 MicroEdition-J2ME
Java2 MicroEdition-J2ME
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Último (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Parsing XML in J2ME

  • 1. Parsing XML in J2ME Rohan Chandane rohan.chandane@indiatimes.com These notes are created by me, Rohan Chandane as learning material while pursuing MSc(CA) from SICSR 2005-2007 (CC)
  • 2. Parse XML in a MIDP client application
  • 4. Typical multi-tier architecture In web-centric systems Clients - HTML browsers Server - Serving HTML over HTTP & Applications which uses a database for persistent storage.
  • 5. Continued… Wireless Client - Browser as front end application Server - serving WML over WAP
  • 6. Standalone Client Approach It can communicate in different ways with server HTTP connection RMI as RPC Any customized protocol
  • 7. MIDP Client Advantage Provide a richer user interface Run offline Make updates to the server periodically Disadvantage Difficulty of client installation Maintenance
  • 8. MIDP Client Has following limitations Network connection setup is slow. Data rates are slow. The processor is slow. Memory is scarce
  • 10. A multi-tier architecture: with use of XML Server side code/application returns data as XML document No need to write custom server-side code for each client type One way to supporting multiple client types XML document can be transformed using XSLT into whatever client requirement. e.g. HTML for desktop browses WML for WAP browses
  • 11. Continued… XML can be a data exchange format XML can be send as it is or With some with simple transformation to send more terse (brief and up to the point) XML format.
  • 12. Continued… Advantages of XML Data is self-describing Opportunity to loosely couple the client and server loosely couple: even if they use incompatible system technologies, can be joined together on demand to create composite services, or disassembled just as easily into their functional components During development, XML parsing can be validated using emulator, before running it on application on MIDP device.
  • 13. Continued… Disadvantages of XML Not a very efficient way of expressing data On slow wireless networks, before using XML as a data exchange format, have to do some real device testing. (cause now a days latency is issue than transfer rate)
  • 14. Parser Overview Small size phone need small size application Application and other required files should not exceed particular size limit for MIDP device (normally 128kb)
  • 15. Continued… Parser must be of small and light Parser are traditionally bulky Featuring lots of code. Hefty (large amount of) runtime memory requirements. Open source parsers are attractive Can customize it if need additional features. Can fix the parser if it has bugs.
  • 16. Parser Types 3 Fundamental Types A Model parser A Push parser A Pull parser Choosing a parser is depends on Application behavior Types of documents to be parsed
  • 17. Continued… A model parser Reads an entire document Creates a representation of the document in memory Use significantly more memory than other types of parsers This is how the popular DOM-based parser operates
  • 18. Continued… A push parser Reads through an entire document. As it encounters various parts of the document, it notifies a listener object. Use comparative much memory and processing power This is how the popular SAX API operates.
  • 19. Continued… A pull parser Reads a little bit of a document at once. Parser goes through the document by repeatedly requesting the next piece. Best suitable for J2ME application as take comparatively less memory and processing than other type of parser
  • 20. XML Parser An XML processing model describes the steps an application should take to process XML This model is called XML Parser Java API for XML Processing (JAXP) This is used to integrate an XML parser into your Java applications Mostly used with J2EE
  • 21. Current offering of small XML parsers for MIDP 1DPH /LFHQVH 6L]H 0,'3 7SH SXVK ASXMLP 020308 Modified BSD N% HV PRGHO kXML 2.0 alpha EPL N% HV SXOO kXML 1.2 EPL N% HV SXOO MinML 1.7 BSD N% QR SXVK NanoXML 1.6.4 zlib/libpng N% SDWFK PRGHO TinyXML 0.7 GPL N% QR PRGHO Xparse-J 1.1 GPL N% HV PRGHO Size: size of the class file MIDP: whether the parser will compile without modifications in a MIDP environment Parsers represent the current offerings in the MIDP 1.0 world
  • 22. Frequently used XML parsers For resource-constrained devices kXML Written exclusively for the J2ME platform (CLDC and MIDP). NanoXML Version 1.6.8 for MIDP, supports DOM parsing.
  • 23. Incorporation a parser into MIDlet suite If parsers are .java files Place these files into the src directory of your J2MEWTK project If parsers are .jar or .zip archive of .class files Place the archive in the lib directory of the J2MEWTK project.
  • 24. Performance MIDlet code run well in a constrained environment If XML parser used, code will become significantly bigger and slower. Code optimization can be the solution
  • 25. The optimizations Three Categories of optimizations Runtime performance User perception Deployment code size
  • 26. 1. Runtime performance While designing XML document Long time to set up a network connection XML Document sent to a MIDlet should contain useful information Aggregate documents on the server side and send one larger document. Too large document will keep user waiting for long time.
  • 27. Continued… Find a balance between Avoiding connection setup times and Minimizing download wait times
  • 28. 2. User perception/experience Do not lock-up UI While the MIDlet is Parsing an XML document Reading the document from the network User can allow to perform offline tasks while network activities
  • 29. 3. Deployment code size Concern : size of your MIDlet suite JAR Three Problems Less space on MIDP device Downloading application over network is slow XML Parsing adds intensive string parsing, which adds overhead in MIDP applications
  • 30. Continued… Solution: Use of obfuscator (alter) MIDlet suite JAR contains Class files, images, icons other resource files Obfuscator has following features Removes unused classes Removes unused methods and variables Renames classes, packages, methods, and variables
  • 31. Continued… These features are fine and will reduce the size of your MIDlet suite JAR Example: if incorporated an XML parser in your MIDlet project, there may be parts of the parser that application never uses. An obfuscator is good for pruning (cut back) out the stuff don't need.
  • 33. Continued… To use obfuscator, it need proguard.jar file to get it, do the following Go to http://proguard.sourceforge.net/. Select the quot;Downloadquot; link. Select quot;Download sectionquot;. Choose the latest version of proguard.zip and save it to yours disk. Extract the proguard.jar file from proguard.zip into the bin subdirectory of the WTK.
  • 34. ProGuard What is ProGuard A free Java class file shrinker, optimizer, and obfuscator It can detect and remove unused classes, fields, methods, and attributes It can then optimize bytecode and remove unused instructions
  • 35. Continued… It can rename the remaining classes, fields, and methods using short meaningless name The resulting jars are smaller and harder to reverse-engineer
  • 36. Integrate ProGuard with WTK ProGuard plug-in can be seamlessly integrated in the Sun J2ME Wireless Toolkit (WTK) Edit in the file {WTK_DIR}/wtklib/Linux/ktools.properties or {WTK_DIR}wtklibWindowsktools.properti es
  • 37. Continued… Put these lines in above file (for windows) obfuscator.runner.class.name: proguard.wtk.ProGuardObfuscator obfuscator.runner.classpath: wtklibproguard3.6libproguard.jar Uncompress the zip file to {WTK_DIR}wtklibproguard3.6 To apply it on projects Open project in WTK go to Project - Package - Create Obfuscated Package
  • 39. XML Parsing with kXML in J2ME application
  • 40. Purpose A J2ME application, ParseXML, that parses XML documents Displays the information encoded in those documents on a phone screen
  • 41. Requirements J2ME Wireless Toolkit 2.2 http://java.sun.com/products/sjwtoolkit/do wnload-2_2.html SDK of J2SE, J2EE kXML Parser 1.2 http://kxml.objectweb.org/software/downl oads/ Any ASCII/Unicode Editor
  • 42. Installation Install J2SD J2EE Install WTK 2.2 Place kxml.zip file in following directory {WTK_DIR}/apps/{Project_Folder}/lib
  • 43. XML file ?xml version=quot;1.0quot;? testXML fnameRohan/fname lnameChandane/lname /testXML This XML will be parsed by J2ME applications and it will extract data from tags fname lname
  • 44. Continued… XML data is made available MIDP application (ParseXML) in the form of a String, using any server side technology Server side technology preferably should be Java(J2EE), so it will be better for integration We can also use PHP, Ruby, ASP.net instead
  • 45. J2EE Application Firstly, for generating XML we will create J2EE application We will use NetBeans 5.0 as J2EE IDE Follow the steps ahead -
  • 46. Select Category : Web File New Project… Select Project : Web Application
  • 47. Project Name : J2EEXMLParsing Select Location : As you want Press Finish
  • 48. Double Click on Source Packages in Projects Create new servlet : Right Click on Default Package, New Servlet…
  • 49. Write Class Name : GeneralXML Press Next
  • 51. Default Package will show GenerateXML.java A new tab will show code of GenerateXML.java
  • 52. Write a code for generating XML string as show in red square Content type : text/xml , This will generate content of page as XML
  • 53. Right Click in code window and Click Run File Menu
  • 55. Here is XML String generated and displayed in Browser Address in red square need to call by MIDP application to retrive XML String
  • 56. J2ME Application Secondly, for reading XML we will create J2ME application We will use Wireless Toolkit 2.2 as J2ME IDE text editor Follow the steps ahead -
  • 57. Writing a Java code We need to know MIDP GUI programming Use of javax.microedition.lcdui classes J2ME network programming Use of javax.microedition.io classes Use of java.io classes kXML XML parsing Programming Use of org.kxml.parse classes
  • 58. MIDP GUI programming To display XML data, we require import javax.microedition.midlet.*; import javax.microedition.lcdui.*; Class neet to extend ‘MIDlet’ as a super class Use of classes Display TextBox
  • 59. Continued… Here is the code import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ParseXML extends MIDlet { private Display display; public ParseXML() { display = Display.getDisplay(this); } public void startApp() { TextBox t = new TextBox(quot;XML Dataquot;,quot;Here, will be displyed data extracted from XMLquot;, 1024, 0); display.setCurrent(t); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } }
  • 60. J2ME network programming To get XML data over network using HTTP, we require import javax.microedition.io classes import java.io classes Use of classes HttpConnection Using Server URL, to get XML Stream - http://localhost:8084/J2EEXMLParseing/GenerateXML InputStreamReader
  • 61. Continued… import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import java.io.*; public class ParseXML extends MIDlet { private Display display; private String url = quot;http://localhost:8084/J2EEXMLParseing/GenerateXMLquot;; public ParseXML() { display = Display.getDisplay(this); } public void startApp() { try { downloadPage(url); } catch(IOException ioe) { System.out.println(quot;Error : quot; + ioe); } } public void pauseApp() {} public void destroyApp(boolean unconditional) {} private void downloadPage(String url) throws IOException { HttpConnection conn = (HttpConnection)Connector.open(url); InputStreamReader doc = new InputStreamReader(conn.openInputStream()); } }
  • 62. kXML XML parsing To use kXML parsing classes, methods we require – import org.kxml classes import org.kxml.parser classes Use of classes XmlParser ParseEvent
  • 63. Continued… Check code below import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import java.io.*; import org.kxml.*; import org.kxml.parser.*; public class ParseXML extends MIDlet { private Display display; private String url = quot;http://localhost:8084/J2EEXMLParseing/GenerateXMLquot;; public ParseXML() { display = Display.getDisplay(this); } public void startApp() { try { downloadPage(url); } catch(IOException ioe) { System.out.println(quot;Error : quot; + ioe); } } public void pauseApp() {} public void destroyApp(boolean unconditional) {} private void downloadPage(String url) throws IOException { HttpConnection conn = (HttpConnection)Connector.open(url); InputStreamReader doc = new InputStreamReader(conn.openInputStream());
  • 64. Code explanation XmlParser parser = new XmlParser(doc); This will create object of XmlParser and will read InputStreamReader doc, XML stream which we got from HttpConnection from server ParseEvent event = parser.read(); This will create ParseEvent object event, which will read all events from XmlParser object parser
  • 65. Continued… ParseEvent object’s method getType() - returns the event type integer constant assigned to this event These are possible event types: Xml.START_TAG Xml.END_TAG Xml.TEXT Xml.WHITESPACE Xml.COMMENT Xml.PROCESSING_INSTRUCTION Xml.DOCTYPE Xml.END_DOCUMENT
  • 66. Continued… getName() - returns the (local) name of the element started if instance of StartTag, null otherwise example - If element start tag is fname, then event.getName() it will return fname
  • 67. Continued… getText() - returns a String, if event types are TEXT PROCESSING_INSTRUCTION DOCTYPE for rest events, it returns null
  • 68.
  • 69. RSS: Rich Site Summary Simple XML format that summarizes headlines and story descriptions for a news site