Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
simple XML parser for GWT
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 47 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
musachy  
View profile  
(10 users)  More options May 18 2006, 11:32 pm
From: "musachy" <musa...@gmail.com>
Date: Fri, 19 May 2006 03:32:41 -0000
Local: Thurs, May 18 2006 11:32 pm
Subject: simple XML parser for GWT
Here is a couple of classes to parse xml with GWT, the js code is taken
(with some modifications) from
ajaxslt(http://goog-ajaxslt.sourceforge.net/) . Here is how to use it:

String xml = "<element att=\"some attribute\">some text</element>";
Document doc = Document.xmlParse(xml);

Node node0 = (Node)doc.getChildren().get(0);
node0.getName(); // "element"
node0.getValue(); // null
node0.getAttribute("att"); // "some attribute"
node0.getType(); // DOM_ELEMENT_NODE

Node node1 = (Node)node.getChildNodes().get(0);
node1.getName(); // #text
node1.getValue(); // "some text"
node1.getType(); // DOM_TEXT_NODE

this GWT is a lot of fun :)

--------------------------------------------------------------------------- --------------

package com.test.client.xml;

import java.util.ArrayList;

import com.google.gwt.core.client.JavaScriptObject;

public class Document {

        private ArrayList childNodes = new ArrayList();
        public static final String DOM_ELEMENT_NODE = "DOM_ELEMENT_NODE";
        public static final String DOM_TEXT_NODE = "DOM_TEXT_NODE";

        Document() {
        }

        /...@com.test.client.xml.Document::newDocument()
        public static Document newDocument() {
                return new Document();
        }

        /...@com.test.client.xml.Document::createNode(Ljava/lang/String;)
        public Node createNode(String name) {
                 return new Node(DOM_ELEMENT_NODE, name, null, this);
        }

        /...@com.test.client.xml.Document::createTextNode(Ljava/lang/String;)
        public Node createTextNode(String value) {
                 return new Node(DOM_TEXT_NODE, "#text", value, this);
        }

        /...@com.test.client.xml.Document::appendChild(Lcom/test/client/xml/Node;)
        public void appendChild(Node child) {
                childNodes.add(child);
        }

        /...@com.test.client.xml.Document::xmlResolveEntities(Ljava/lang/String;)
        public static native JavaScriptObject xmlResolveEntities(String s)
/*-{
                  var parts =
@com.test.client.xml.Document::stringSplit(Ljava/lang/String;Ljava/lang/Str ing;)(s,
'&');
                  var ret = parts[0];
                  for (var i = 1; i < parts.length; ++i) {
                    var rp =
@com.test.client.xml.Document::stringSplit(Ljava/lang/String;Ljava/lang/Str ing;)(parts[i],
';');
                    if (rp.length == 1) {
                      // no entity reference: just a & but no ;
                      ret += parts[i];
                      continue;
                    }

                    var ch;
                    switch (rp[0]) {
                      case 'lt':
                        ch = '<';
                        break;
                      case 'gt':
                        ch = '>';
                        break;
                      case 'amp':
                        ch = '&';
                        break;
                      case 'quot':
                        ch = '"';
                        break;
                      case 'apos':
                        ch = '\'';
                        break;
                      case 'nbsp':
                        ch = String.fromCharCode(160);
                        break;
                      default:
                        // Cool trick: let the DOM do the entity decoding. We assign
                        // the entity text through non-W3C DOM properties and read it
                        // through the W3C DOM. W3C DOM access is specified to
resolve
                        // entities.
                        var span = $wnd.document.createElement('span');
                        span.innerHTML = '&' + rp[0] + '; ';
                        ch = span.childNodes[0].nodeValue.charAt(0);
                    }
                    ret += ch + rp[1];
                  }

                  return ret;
        }-*/
        ;

        /...@com.test.client.xml.Document::stringSplit(Ljava/lang/String;Ljava/lang/Str ing;)
        private static native JavaScriptObject stringSplit(String s, String c)
/*-{
                  var a = s.indexOf(c);
                  if (a == -1) {
                    return [ s ];
                  }

                  var parts = [];
                  parts.push(s.substr(0,a));
                  while (a != -1) {
                    var a1 = s.indexOf(c, a + 1);
                    if (a1 != -1) {
                      parts.push(s.substr(a + 1, a1 - a - 1));
                    } else {
                      parts.push(s.substr(a + 1));
                    }
                    a = a1;
                  }

                  return parts;
        }-*/
        ;

        public static native Document xmlParse(String xml) /*-{
                  var regex_empty = /\/$/;

                  // See also <http://www.w3.org/TR/REC-xml/#sec-common-syn> for
                  // allowed chars in a tag and attribute name. TODO(mesch): the
                  // following is still not completely correct.

                  var regex_tagname = /^([\w:-]*)/;
                  var regex_attribute = /([\w:-]+)\s?=\s?('([^\']*)'|"([^\"]*)")/g;

                  var xmldoc = @com.test.client.xml.Document::newDocument()();
                  var root = xmldoc;

                  // For the record: in Safari, we would create native DOM nodes, but
                  // in Opera that is not possible, because the DOM only allows HTML
                  // element nodes to be created, so we have to do our own DOM nodes.

                  // xmldoc = document.implementation.createDocument('','',null);
                  // root = xmldoc; // .createDocumentFragment();
                  // NOTE(mesch): using the DocumentFragment instead of the Document
                  // crashes my Safari 1.2.4 (v125.12).
                  var stack = [];

                  var parent = root;
                  stack.push(parent);

                  var x =
@com.test.client.xml.Document::stringSplit(Ljava/lang/String;Ljava/lang/Str ing;)(xml,
'<');
                  for (var i = 1; i < x.length; ++i) {
                    var xx =
@com.test.client.xml.Document::stringSplit(Ljava/lang/String;Ljava/lang/Str ing;)(x[i],
'>');
                    var tag = xx[0];
                    var text =
@com.test.client.xml.Document::xmlResolveEntities(Ljava/lang/String;)(xx[1]
|| '');

                    if (tag.charAt(0) == '/') {
                      stack.pop();
                      parent = stack[stack.length-1];

                    } else if (tag.charAt(0) == '?') {
                      // Ignore XML declaration and processing instructions
                    } else if (tag.charAt(0) == '!') {
                      // Ignore notation and comments
                    } else {
                      var empty = tag.match(regex_empty);
                      var tagname = regex_tagname.exec(tag)[1];
                      var node =
xmld...@com.test.client.xml.Document::createNode(Ljava/lang/String;)(tagname);

                      var att;
                      while (att = regex_attribute.exec(tag)) {
                        var val =
@com.test.client.xml.Document::xmlResolveEntities(Ljava/lang/String;)(att[3 ]
|| att[4] || '');

no...@com.test.client.xml.Node::setAttribute(Ljava/lang/String;Ljava/lang/String ;)(att[1],
val);
                      }

                      //TODO polymorphism here would be nice
                      if(parent == xmldoc) {

        xmld...@com.test.client.xml.Document::appendChild(Lcom/test/client/xml/Node;)(node );
                      }
                      else {

        pare...@com.test.client.xml.Node::appendChild(Lcom/test/client/xml/Node;)(node);
                      }

                      if (!empty) {
                        parent = node;
                        stack.push(node);
                      }
                    }

                    if (text && parent != root) {
                      if(parent == xmldoc) {

        xmld...@com.test.client.xml.Document::appendChild(Lcom/test/client/xml/Node;)(xmld...@com.test.client.xml.Document::createTextNode(Ljava/lang/String;)(text));
                      }
                      else {

        pare...@com.test.client.xml.Node::appendChild(Lcom/test/client/xml/Node;)(xmld...@com.test.client.xml.Document::createTextNode(Ljava/lang/String;)(text));
                      }

                    }
                  }

                  return xmldoc;
        }-*/
        ;

        /**
         * @return Returns the childNodes.
         */
        public ArrayList getChildren() {
                return childNodes;
        }

}

package com.test.client.xml;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Node {

        private Map attributes = new HashMap();
        private ArrayList childNodes = new ArrayList();
        private String type;
        private String name;
        private String value;
        private Document document;
        private Node parent;

        Node(String nodeType, String nodeName, String nodeValue, Document
ownerDocument) {
                this.type = nodeType;
                this.name = nodeName;
                this.value = nodeValue;
                this.document = ownerDocument;
        }

        /...@com.test.client.xml.Node::appendChild(Lcom/test/client/xml/Node;)
        public void appendChild(Node child) {
                child.setParent(this);
                childNodes.add(child);
        }

        public String getAttribute(String name) {
                return (String)attributes.get(name);
        }

        /...@com.test.client.xml.Node::appendChild(Ljava/lang/String;Ljava/lang/String; Ljava/lang/String;)
        public void setAttribute(String name, String value) {
                attributes.put(name, value);
        }

        public Node getParent() {
                return parent;
        }

        private void setParent(Node parent) {
                this.parent = parent;
        }

        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }

        public String getType() {
                return type;
        }

        public void setType(String type) {
                this.type = type;
        }

        public String getValue() {
                return value;
        }

        public void setValue(String value) {
                this.value = value;
        }

        public ArrayList getChildNodes() {
                return childNodes;
        }

        public Document getDocument() {
                return document;
        }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henry  
View profile  
 More options May 19 2006, 7:47 am
From: "Henry" <h...@google.com>
Date: Fri, 19 May 2006 04:47:14 -0700
Local: Fri, May 19 2006 7:47 am
Subject: Re: simple XML parser for GWT
Very cool!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 9:49 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 06:49:55 -0700
Local: Mon, May 22 2006 9:49 am
Subject: Re: simple XML parser for GWT
Throw Exception to me =(

[WARN] Exception thrown into JavaScript
java.lang.RuntimeException: JavaScript method
'...@com.mycompany.client.Document::xmlParse(Ljava/lang/String;)' threw an
exception
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java :365)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE 6.java:204)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j ava:103)
        at com.mycompany.client.Document.xmlParse(Document.java:116)
        at
com.mycompany.client.ListUsers$JSONResponseTextHandler.onCompletion(ListUse rs.java:29)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 9)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
com.google.gwt.dev.shell.InstanceJavaDispatch.callMethod(InstanceJavaDispat ch.java:40)
        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:117)
Caused by: com.google.gwt.core.client.JavaScriptException: JavaScript
TypeError exception: O objeto não dá suporte para a propriedade ou
método
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce ssorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru ctorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at
com.google.gwt.dev.shell.ModuleSpace.createJavaScriptException(ModuleSpace. java:267)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.exceptionCaught(ModuleSpaceIE6.j ava:76)
        at
com.google.gwt.dev.shell.JavaScriptHost.exceptionCaught(JavaScriptHost.java :31)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 9)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.j ava:45)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 22 2006, 9:58 am
From: "musachy" <musa...@gmail.com>
Date: Mon, 22 May 2006 13:58:01 -0000
Local: Mon, May 22 2006 9:58 am
Subject: Re: simple XML parser for GWT
If you have the mozilla web dev toolbar addon you will be able to see
what is the error. You can also try posting here the xml to see if it
is a bug in the parser.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:03 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:03:14 -0700
Local: Mon, May 22 2006 10:03 am
Subject: Re: simple XML parser for GWT
Hi!

First Exception

[WARN] Exception thrown into JavaScript
org.eclipse.swt.SWTException: Failed to change Variant type result =
-2147352571
        at org.eclipse.swt.ole.win32.OLE.error(OLE.java:332)
        at org.eclipse.swt.ole.win32.Variant.getDispatch(Variant.java:331)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeHandle(ModuleSpaceIE 6.java:164)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeHandle(JavaScriptHost.j ava:79)
        at com.mycompany.client.Document.xmlResolveEntities(Document.java:38)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:07 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:07:04 -0700
Local: Mon, May 22 2006 10:07 am
Subject: Re: simple XML parser for GWT
Compile errors

Output will be written into
D:\java\workspace_gwt\MyProject\www\com.mycompany.MyApplication
   Analyzing permutation #1
      Errors in
D:\java\workspace_gwt\MyProject\src\com\mycompany\client\Document.java
         [ERROR] Line 111:  Unresolvable native reference to method
'appendChild' in type 'com.mycom
pany.client.Document' (did you mean
'appendChild(Lcom/mycompany/client/Node;)'?)
         [ERROR] Line 111:  Unresolvable native reference to method
'appendChild' in type 'com.mycom
pany.client.Node' (did you mean
'appendChild(Lcom/mycompany/client/Node;)'?)
         [ERROR] Line 111:  Unresolvable native reference to method
'appendChild' in type 'com.mycom
pany.client.Document' (did you mean
'appendChild(Lcom/mycompany/client/Node;)'?)
         [ERROR] Line 111:  Unresolvable native reference to method
'appendChild' in type 'com.mycom
pany.client.Node' (did you mean
'appendChild(Lcom/mycompany/client/Node;)'?)
      [ERROR] Unexpected internal compiler error
[ERROR] Build failed


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 22 2006, 10:10 am
From: "musachy" <musa...@gmail.com>
Date: Mon, 22 May 2006 14:10:36 -0000
Local: Mon, May 22 2006 10:10 am
Subject: Re: simple XML parser for GWT
You need to put the Document and Node classes inside the "client"
package.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:38 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:38:05 -0700
Local: Mon, May 22 2006 10:38 am
Subject: Re: simple XML parser for GWT
but they are on package 'client'

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:38 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:38:51 -0700
Local: Mon, May 22 2006 10:38 am
Subject: Re: simple XML parser for GWT
Document.java

package com.mycompany.client;

import java.util.ArrayList;

import com.google.gwt.core.client.JavaScriptObject;

public class Document {

        private ArrayList childNodes = new ArrayList();

        public static final String DOM_ELEMENT_NODE = "DOM_ELEMENT_NODE";

        public static final String DOM_TEXT_NODE = "DOM_TEXT_NODE";

        Document() {
        }

        // @com.mycompany.client.Document::newDocument()
        public static Document newDocument() {
                return new Document();
        }

        // @com.mycompany.client.Document::createNode(Ljava/lang/String;)
        public Node createNode(String name) {
                return new Node(DOM_ELEMENT_NODE, name, null, this);
        }

        // @com.mycompany.client.Document::createTextNode(Ljava/lang/String;)
        public Node createTextNode(String value) {
                return new Node(DOM_TEXT_NODE, "#text", value, this);
        }

        //
@com.mycompany.client.Document::appendChild(Lcom/test/client/xml/Node;)
        public void appendChild(Node child) {
                childNodes.add(child);
        }

        //
@com.mycompany.client.Document::xmlResolveEntities(Ljava/lang/String;)
        public static native JavaScriptObject xmlResolveEntities(String s)
        /*-{
         var parts =
@com.mycompany.client.Document::stringSplit(Ljava/lang/String;Ljava/lang/St ring;)(s,
'&');
         var ret = parts[0];
         for (var i = 1; i < parts.length; ++i) {
                var rp =
@com.mycompany.client.Document::stringSplit(Ljava/lang/String;Ljava/lang/St ring;)(parts[i],
';');
                 if (rp.length == 1) {
                        // no entity reference: just a & but no ;
                         ret += parts[i];
                         continue;
                 }

         var ch;
         switch (rp[0]) {
                case 'lt':
                        ch = '<';
                        break;
                case 'gt':
                        ch = '>';
                        break;
            case 'amp':
                ch = '&';
                break;
            case 'quot':
                ch = '"';
                break;
            case 'apos':
                ch = '\'';
                break;
            case 'nbsp':
                ch = String.fromCharCode(160);
                break;
            default:
                 // Cool trick: let the DOM do the entity decoding. We assign
                 // the entity text through non-W3C DOM properties and read it
                 // through the W3C DOM. W3C DOM access is specified to  resolve
                  // entities.
                   var span = $wnd.document.createElement('span');
                   span.innerHTML = '&' + rp[0] + '; ';
                   ch = span.childNodes[0].nodeValue.charAt(0);
         }
         ret += ch + rp[1];
         }

         return ret;
         }-*/
        ;

        //
@com.mycompany.client.Document::stringSplit(Ljava/lang/String;Ljava/lang/St ring;)
        private static native JavaScriptObject stringSplit(String s, String c)
        /*-{
         var a = s.indexOf(c);
         if (a == -1) {
           return [ s ];
         }

         var parts = [];
         parts.push(s.substr(0,a));
         while (a != -1) {
          var a1 = s.indexOf(c, a + 1);
          if (a1 != -1) {
           parts.push(s.substr(a + 1, a1 - a - 1));
          } else {
           parts.push(s.substr(a + 1));
          }
          a = a1;
         }

         return parts;
         }-*/
        ;

        public static native Document xmlParse(String xml) /*-{
         var regex_empty = /\/$/;

         // See also <http://www.w3.org/TR/REC-xml/#sec-common-syn> for
         // allowed chars in a tag and attribute name. TODO(mesch): the
         // following is still not completely correct.

         var regex_tagname = /^([\w:-]*)/;
         var regex_attribute = /([\w:-]+)\s?=\s?('([^\']*)'|"([^\"]*)")/g;

         var xmldoc = @com.mycompany.client.Document::newDocument()();
         var root = xmldoc;

         // For the record: in Safari, we would create native DOM nodes, but
         // in Opera that is not possible, because the DOM only allows HTML
         // element nodes to be created, so we have to do our own DOM nodes.

         // xmldoc = document.implementation.createDocument('','',null);
         // root = xmldoc; // .createDocumentFragment();
         // NOTE(mesch): using the DocumentFragment instead of the Document
         // crashes my Safari 1.2.4 (v125.12).
         var stack = [];

         var parent = root;
         stack.push(parent);

         var x =
@com.mycompany.client.Document::stringSplit(Ljava/lang/String;Ljava/lang/St ring;)(xml,
'<');
         for (var i = 1; i < x.length; ++i) {
         var xx =
@com.mycompany.client.Document::stringSplit(Ljava/lang/String;Ljava/lang/St ring;)(x[i],
'>');
         var tag = xx[0];
         var text =

@com.mycompany.client.Document::xmlResolveEntities(Ljava/lang/String;)(xx[1 ]
|| '');

         if (tag.charAt(0) == '/') {
          stack.pop();
          parent = stack[stack.length-1];

         } else if (tag.charAt(0) == '?') {
         // Ignore XML declaration and processing instructions
         } else if (tag.charAt(0) == '!') {
         // Ignore notation and comments
         } else {
         var empty = tag.match(regex_empty);
         var tagname = regex_tagname.exec(tag)[1];
         var node =
xmld...@com.mycompany.client.Document::createNode(Ljava/lang/String;)(tagname);

         var att;
         while (att = regex_attribute.exec(tag)) {
         var val =
@com.mycompany.client.Document::xmlResolveEntities(Ljava/lang/String;)(att[ 3]
|| att[4] || '');

no...@com.mycompany.client.Node::setAttribute(Ljava/lang/String;Ljava/lang/Strin g;)(att[1],
val);
         }

         //TODO polymorphism here would be nice
         if(parent == xmldoc) {

xmld...@com.mycompany.client.Document::appendChild(Lcom/test/client/xml/Node;)(nod e);
         }
         else {

pare...@com.mycompany.client.Node::appendChild(Lcom/test/client/xml/Node;)(node);
         }

         if (!empty) {
         parent = node;
         stack.push(node);
         }
         }

         if (text && parent != root) {
         if(parent == xmldoc) {

xmld...@com.mycompany.client.Document::appendChild(Lcom/test/client/xml/Node;)(xml d...@com.mycompany.client.Document::createTextNode(Ljava/lang/String;)(text));
         }
         else {

pare...@com.mycompany.client.Node::appendChild(Lcom/test/client/xml/Node;)(xmld...@com.mycompany.client.Document::createTextNode(Ljava/lang/String;)(text));
         }

         }
         }

         return xmldoc;
         }-*/
        ;

        /**
         * @return Returns the childNodes.
         */
        public ArrayList getChildren() {
                return childNodes;
        }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:39 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:39:25 -0700
Local: Mon, May 22 2006 10:39 am
Subject: Re: simple XML parser for GWT
Node

package com.mycompany.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Node {

        private Map attributes = new HashMap();

        private ArrayList childNodes = new ArrayList();

        private String type;

        private String name;

        private String value;

        private Document document;

        private Node parent;

        Node(String nodeType, String nodeName, String nodeValue,
                        Document ownerDocument) {
                this.type = nodeType;
                this.name = nodeName;
                this.value = nodeValue;
                this.document = ownerDocument;
        }

        // @com.mycompany.client.Node::appendChild(Lcom/test/client/xml/Node;)
        public void appendChild(Node child) {
                child.setParent(this);
                childNodes.add(child);
        }

        public String getAttribute(String name) {
                return (String) attributes.get(name);
        }

        //
@com.mycompany.client.Node::appendChild(Ljava/lang/String;Ljava/lang/String ;Ljava/lang/String;)
        public void setAttribute(String name, String value) {
                attributes.put(name, value);
        }

        public Node getParent() {
                return parent;
        }

        private void setParent(Node parent) {
                this.parent = parent;
        }

        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }

        public String getType() {
                return type;
        }

        public void setType(String type) {
                this.type = type;
        }

        public String getValue() {
                return value;
        }

        public void setValue(String value) {
                this.value = value;
        }

        public ArrayList getChildNodes() {
                return childNodes;
        }

        public Document getDocument() {
                return document;
        }


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 10:46 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 07:46:17 -0700
Local: Mon, May 22 2006 10:46 am
Subject: Re: simple XML parser for GWT
I changed (Lcom/test/client/xml/Node;)  to
(Lcom/mycompany/client/Node;), but not works...

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 22 2006, 10:49 am
From: "musachy" <musa...@gmail.com>
Date: Mon, 22 May 2006 14:49:33 -0000
Local: Mon, May 22 2006 10:49 am
Subject: Re: simple XML parser for GWT
The thing is that you need to replace all "com/test/client/xml/" with
your own namespace, in your classes you have this:

com.mycompany.client.Document::appendChild(Lcom/test/client/xml/Node;)

it should be something like:

com.mycompany.client.Document::appendChild(Lcom/mycompany/client/Node;)

replace them all and see if it works.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 11:20 am
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 15:20:50 -0000
Local: Mon, May 22 2006 11:20 am
Subject: Re: simple XML parser for GWT
Hi musachy, I send e-mail with my code to us, ok?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 22 2006, 11:36 am
From: "musachy" <musa...@gmail.com>
Date: Mon, 22 May 2006 15:36:37 -0000
Local: Mon, May 22 2006 11:36 am
Subject: Re: simple XML parser for GWT
Hi, I ran your code and it works fine. When you run it in hosted mode
it fails, I forgot to mention that when I posted my code, if you
compile it and run it in the browser it works as expected.

for the GWT folks, this is what we get when running in hosted mode:

[ERROR] Unable to load module entry point class
com.test.client.MyApplication
java.lang.RuntimeException: JavaScript method
'...@com.test.client.xml.Document::xmlParse(Ljava/lang/String;)' threw an
exception
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNative(ModuleSpaceIE6.java :365)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeObject(ModuleSpaceIE 6.java:204)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.j ava:103)
        at com.test.client.xml.Document.xmlParse(Document.java:114)
        at com.test.client.ListUsers.<init>(ListUsers.java:63)
        at
com.test.client.ListUsers$ListUsersHolder.<clinit>(ListUsers.java:96)
        at com.test.client.ListUsers.getInstance(ListUsers.java:92)
        at com.test.client.MyApplication.onModuleLoad(MyApplication.java:38)
        at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:64)
        at
com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java :324)
Caused by: org.eclipse.swt.SWTException: Failed to change Variant type
result = -2147352571
        at org.eclipse.swt.ole.win32.OLE.error(OLE.java:332)
        at org.eclipse.swt.ole.win32.Variant.getDispatch(Variant.java:331)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeHandle(ModuleSpaceIE 6.java:164)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeHandle(JavaScriptHost.j ava:79)
        at com.test.client.xml.Document.xmlResolveEntities(Document.java:36)
        at
com.google.gwt.dev.shell.StaticJavaDispatch.callMethod(StaticJavaDispatch.j ava:45)
        at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:117)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:199)
        at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:108)
        at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pablohstc@gmail.com  
View profile  
 More options May 22 2006, 2:41 pm
From: "pabloh...@gmail.com" <pabloh...@gmail.com>
Date: Mon, 22 May 2006 18:41:03 -0000
Local: Mon, May 22 2006 2:41 pm
Subject: Re: simple XML parser for GWT
Hosted Mode bug? =(

I compile and run Firefox works fine!!!! Thank you

Regards,
Pablo


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eduard.manchado.safont@gm ail.com  
View profile  
 More options May 26 2006, 5:26 am
From: "eduard.manchado.saf...@gmail.com" <eduard.manchado.saf...@gmail.com>
Date: Fri, 26 May 2006 02:26:56 -0700
Local: Fri, May 26 2006 5:26 am
Subject: Re: simple XML parser for GWT
This library is nice but it traits the white-spaces as a node text. Is
it a bug?

BTW in hosted mode dont works well but in firefox/ie works well.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
(1 user)  More options May 26 2006, 12:42 pm
From: "musachy" <musa...@gmail.com>
Date: Fri, 26 May 2006 16:42:44 -0000
Local: Fri, May 26 2006 12:42 pm
Subject: Re: simple XML parser for GWT
Yeah it is probably a bug

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oh~  
View profile  
 More options May 28 2006, 6:36 am
From: "Oh~" <jj_lyn2...@yahoo.com.cn>
Date: Sun, 28 May 2006 03:36:02 -0700
Local: Sun, May 28 2006 6:36 am
Subject: Re: simple XML parser for GWT
can u provide same demo?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pablo Henrique  
View profile  
 More options May 29 2006, 9:24 am
From: "Pablo Henrique" <pabloh...@gmail.com>
Date: Mon, 29 May 2006 10:24:28 -0300
Local: Mon, May 29 2006 9:24 am
Subject: Re: simple XML parser for GWT

Sees here

http://gwt.components.googlepages.com/

On 5/28/06, Oh~ <jj_lyn2...@yahoo.com.cn> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eduard.manchado.safont@gm ail.com  
View profile  
 More options May 31 2006, 9:30 am
From: "eduard.manchado.saf...@gmail.com" <eduard.manchado.saf...@gmail.com>
Date: Wed, 31 May 2006 13:30:00 -0000
Subject: Re: simple XML parser for GWT
will be a version of the library that runs in hosted mode? or is it
technically imposible?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 31 2006, 1:12 pm
From: "musachy" <musa...@gmail.com>
Date: Wed, 31 May 2006 17:12:18 -0000
Local: Wed, May 31 2006 1:12 pm
Subject: Re: simple XML parser for GWT
The guys from google are taking a look at the error, so it will
probably be fixed in a future GWT release.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Scott Blum  
View profile  
 More options May 31 2006, 2:45 pm
From: "Scott Blum" <sco...@google.com>
Date: Wed, 31 May 2006 14:45:58 -0400
Local: Wed, May 31 2006 2:45 pm
Subject: Re: simple XML parser for GWT
Hi musachy,

I tracked this down to a semantic problem in Document.

xmlResolveEntities() is declared to return a JavaScriptObject, but in
fact it returns a string primitive.  Changing the return type of
xmlResolveEntities() to String fixes the problem.  It happens to work
in web mode in this case because you're passing the value directly to
another JSNI method that expects it to really be a string, but
JavaScriptObject is only designed to wrap Object-typed things.

I debugged this by putting "debugger" statements into the JSNI code
and stepping through it with .NET's script debugger on Windows.

Scott

On 5/31/06, musachy <musa...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
musachy  
View profile  
 More options May 31 2006, 8:03 pm
From: "musachy" <musa...@gmail.com>
Date: Thu, 01 Jun 2006 00:03:17 -0000
Local: Wed, May 31 2006 8:03 pm
Subject: Re: simple XML parser for GWT
thanks a lot Scott!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
eduard.manchado.safont@gm ail.com  
View profile  
 More options Jun 1 2006, 7:30 am
From: "eduard.manchado.saf...@gmail.com" <eduard.manchado.saf...@gmail.com>
Date: Thu, 01 Jun 2006 11:30:25 -0000
Local: Thurs, Jun 1 2006 7:30 am
Subject: Re: simple XML parser for GWT
Nice work!

Edu


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pablo Henrique  
View profile  
 More options Jun 5 2006, 1:41 pm
From: "Pablo Henrique" <pabloh...@gmail.com>
Date: Mon, 5 Jun 2006 14:41:57 -0300
Local: Mon, Jun 5 2006 1:41 pm
Subject: Re: simple XML parser for GWT

In GWT Version 1.0.21Beta Hosted Mode, work's fine?

On 6/1/06, eduard.manchado.saf...@gmail.com <


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 47   Newer >
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google