Earlier I talked about my vision. In that application there are pages like "More", "About" they are rendered from markup files(more.xml, about.xml, ..) found here. They are following markup.dtd rules. Surely you can create documents on fly and work on DOM.
Note that it is svn-branch, the trunk is always containing the updated features.
And there are application-switches making it possible to interact with user. Here are the responsible code doing the magic.
The markup is not rich in features. It was good to follow an existing markup rule. I am hoping to do that in future. And I am keeping eye on w3.org for that.
Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts
Wednesday, December 10, 2008
Tuesday, December 9, 2008
XMPP client with browser-like features
I am back to j2me again. In my earlier attempt I was trying to render a WML content. Now I am here with a little advanced browser like feature to show web content. Note that I have dropped the idea of writing WML renderer. I have added a markup renderer. To be specific it can render a list of markup items. Here we can show on line content. It is stylable on compile-time.
Motivation
When I want to add some feature to my sweet application, it just gets bigger in size. And bigger size prevent it to work in low end mobile phones. So the idea is to write little j2me code and add most of the features in the servers. And here I am sharing the implementation of the idea in a hope that it gets richer and useful to you.
Similar efforts
There is something similar available in ZK project. And there is also a browser feature in j2mepolish project. I prefer mine, because I believe that it has very small footprint, it is light-weight(reuses objects) and I am willing to process any feature request that will suite this. Mobile Ajax is another interesting project.
Input fields
It has textbox, selection(multiple) box, checkbox, radio input ideas implemented. I am hoping to add some multimedia feature as well. Like an input box for image, sound etc and also playback of the media content.
Benchmark
It is tested on WTk monitor output that shows low object instantiation.
Caveats
It is using document parser from kxml project. The document and elements there uses vectors and it makes the parsing little slower. I am looking for some alternative to this.
Thinking forward
I think this is a step forward to social features. The next thing to do is to write web application to represent information from social sites. I am now looking for any kind of reusable component for this. I mean I am not trying to reinvent. And it is hard to maintain too. If you think you have nice idea or have something to say please feel free post comment or email me directly.
Additionally it has a IM framework to develop end to end application too.
Please consider testing MiniIM in your mobile.
Motivation
When I want to add some feature to my sweet application, it just gets bigger in size. And bigger size prevent it to work in low end mobile phones. So the idea is to write little j2me code and add most of the features in the servers. And here I am sharing the implementation of the idea in a hope that it gets richer and useful to you.
Similar efforts
There is something similar available in ZK project. And there is also a browser feature in j2mepolish project. I prefer mine, because I believe that it has very small footprint, it is light-weight(reuses objects) and I am willing to process any feature request that will suite this. Mobile Ajax is another interesting project.
Input fields
It has textbox, selection(multiple) box, checkbox, radio input ideas implemented. I am hoping to add some multimedia feature as well. Like an input box for image, sound etc and also playback of the media content.
Benchmark
It is tested on WTk monitor output that shows low object instantiation.
Caveats
It is using document parser from kxml project. The document and elements there uses vectors and it makes the parsing little slower. I am looking for some alternative to this.
Thinking forward
I think this is a step forward to social features. The next thing to do is to write web application to represent information from social sites. I am now looking for any kind of reusable component for this. I mean I am not trying to reinvent. And it is hard to maintain too. If you think you have nice idea or have something to say please feel free post comment or email me directly.
Additionally it has a IM framework to develop end to end application too.
Please consider testing MiniIM in your mobile.
Thursday, June 19, 2008
KXML skip SubTree skip Depth
KXML is just the name of XML parsing in J2ME. As I am using it in MiniIM, parsing XMPP and even special markup, I found it useful to skip upto a specific depth of XML tree. Note, the skipSubTree() method in KXMLParser / XMLPullParser API is useful. But it needs that you call it at tag start otherwise it will throw exception. So I introduce skipDepth(depth) idea. You just set your depth upto which you want to skip. It will just eat data upto that.
For example here is a small part of stream,
Here is the simple code to parse the "stream:features",
And here is the small method I have added in KXMLParser.
I hope it helps :) ..
For example here is a small part of stream,
<?xml version='1.0'?>
<stream:stream xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" id="1523376107" from="jabber.org" version="1.0" xml:lang="en">
...
...
<stream:features>
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
<register xmlns="http://jabber.org/features/iq-register"/>
</stream:features>
...
...
Here is the simple code to parse the "stream:features",
final void readFeatures() throws IOException {
String tagName;
String text;
parser.nextTag();
parser.require(KXmlParser.START_TAG, null, PREFIX_FEATURES);
for (; parser.nextTag() != KXmlParser.END_TAG; parser.skipDepth(3)) { /* The features tag is placed at depth 1 */
/* we are parsing things inside this feature tag */
tagName = parser.getName();
if (tagName == null) {
throw new IllegalStateException("feature is null");
} else if (tagName.equals(STARTTLS)) {
/* set a starttls read command */
SimpleLogger.debug(this, "<" + STARTTLS);
featuresTLS = true;
} else if (tagName.equals(MECHANISMS)) {
/* traverse the mechanisms inside */
SimpleLogger.info(this, "readFeatures()\t\tparsing mechanisms");
/* so while inside the mechanisms */
for (; parser.nextTag() != KXmlParser.END_TAG;parser.skipDepth(5)) {
tagName = parser.getName();
if (tagName.equals(MECHANISM)) {
/* see if the mechanism is PLAIN */
text = expectText();
if (text == null) {
} else if (text.equals(PLAIN)) {
/* say that plain mechanism is found */
SimpleLogger.info(this, "<" + PLAIN);
featuresPlain = true;
} else if(text.equals(DIGEST_MD5)) {
SimpleLogger.info(this, "<" + DIGEST_MD5);
featuresDigestMd5 = true;
}
/* do not break, go on parsing mechanisms */
}
}
} else if (tagName.equals(BIND)) {
SimpleLogger.debug(this, "<" + BIND);
featuresBind = true;
} else if(tagName.equals(COMPRESSION)) {
// QUOTE "the ZLIB compression algorithm is mandatory-to-implement"
featuresZLIB = true;
/* traverse the mechanisms inside */
SimpleLogger.info(this, "readFeatures()\t\tparsing compression");
for (; parser.nextTag() != KXmlParser.END_TAG;parser.skipDepth(5)) {
tagName = parser.getName();
if (tagName.equals(METHOD)) {
String compressionMethod = expectText();
if(compressionMethod != null && compressionMethod.equals(ZLIB)) {
featuresZLIB = true;
}
}
}
} else {
SimpleLogger.debug(this, "<!" + tagName);
/* whatever it is just finish the tag */
}
SimpleLogger.debug(this, "< next");
}
parser.skipDepth(2);
}
}
And here is the small method I have added in KXMLParser.
public void skipDepth(int dep) throws IOException,XmlPullParserException {
int level = getDepth() - dep;
int eventType = getEventType();
if(eventType != KXmlParser.END_TAG) {
level++;
}
while(level > 0) {
eventType = next();
if (eventType == KXmlParser.END_TAG) {
--level;
}
else if (eventType == KXmlParser.START_TAG) {
++level;
}
}
}
I hope it helps :) ..
Labels:
browser,
instant messaging,
markup,
mobile,
xml
Subscribe to:
Posts (Atom)
