* Q: type conversion with Gdome [not found] <200807161713.23716.yang.shx@fltrp.com> @ 2008-07-16 9:13 ` Yang Shouxun 2008-07-16 9:44 ` [Caml-list] " Claudio Sacerdoti Coen 1 sibling, 0 replies; 3+ messages in thread From: Yang Shouxun @ 2008-07-16 9:13 UTC (permalink / raw) To: caml-list Hello everyone, I've been using Gdome for some time now and I always find it difficult to deal with the type system. Here is the issue: The document class has a method getElementsByTagName : tagname:Gdome.domString -> Gdome.nodeList and from a nodeList object I can only get Gdome.node objects, while we know they should be Gdome.element objects. My question is how to convert from Gdome.node to Gdome.element? P.S. Gdome.element can be converted to Gdome.node, but not in the other direction as far as I know. TIA, shouxun ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Q: type conversion with Gdome [not found] <200807161713.23716.yang.shx@fltrp.com> 2008-07-16 9:13 ` Q: type conversion with Gdome Yang Shouxun @ 2008-07-16 9:44 ` Claudio Sacerdoti Coen [not found] ` <200807170942.45470.yang.shx@fltrp.com> 1 sibling, 1 reply; 3+ messages in thread From: Claudio Sacerdoti Coen @ 2008-07-16 9:44 UTC (permalink / raw) To: Yang Shouxun; +Cc: caml-list Dear Yang, not every node is an element. Thus you need to use dinamic cast: let node = ... in (* next line may raise GdomeInit.DOMCastException *) let element = Gdome.element_of_node node in ... Cheers, C.S.C. On Wed, 2008-07-16 at 17:13 +0800, Yang Shouxun wrote: > Hello everyone, > > I've been using Gdome for some time now and I always find it difficult to deal > with the type system. Here is the issue: > > The document class has a > method getElementsByTagName : > tagname:Gdome.domString -> Gdome.nodeList > and from a nodeList object I can only get Gdome.node objects, while we know > they should be Gdome.element objects. > > My question is how to convert from Gdome.node to Gdome.element? > > P.S. Gdome.element can be converted to Gdome.node, but not in the other > direction as far as I know. > > TIA, > > shouxun > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- ---------------------------------------------------------------- Real name: Claudio Sacerdoti Coen Doctor in Computer Science, University of Bologna E-mail: sacerdot@cs.unibo.it http://www.cs.unibo.it/~sacerdot ---------------------------------------------------------------- ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <200807170942.45470.yang.shx@fltrp.com>]
* Re: [Caml-list] Q: type conversion with Gdome [not found] ` <200807170942.45470.yang.shx@fltrp.com> @ 2008-07-17 1:42 ` Yang Shouxun 0 siblings, 0 replies; 3+ messages in thread From: Yang Shouxun @ 2008-07-17 1:42 UTC (permalink / raw) To: caml-list On Wednesday 16 July 2008 17:44:18 Claudio Sacerdoti Coen wrote: > Dear Yang, > > not every node is an element. Thus you need to use dinamic cast: > > let node = ... in > (* next line may raise GdomeInit.DOMCastException *) > let element = Gdome.element_of_node node in > ... Thank you very much. I haven't noticed element_of_node. As Gdome.element_of_node is a class and there is no equivalent function, thus my final version is like is: let element = new Gdnome.element_of_node node in > Cheers, > C.S.C. > On Wed, 2008-07-16 at 17:13 +0800, Yang Shouxun wrote: > > Hello everyone, > > > > I've been using Gdome for some time now and I always find it difficult to > > deal with the type system. Here is the issue: > > > > The document class has a > > method getElementsByTagName : > > tagname:Gdome.domString -> Gdome.nodeList > > and from a nodeList object I can only get Gdome.node objects, while we > > know they should be Gdome.element objects. > > > > My question is how to convert from Gdome.node to Gdome.element? > > > > P.S. Gdome.element can be converted to Gdome.node, but not in the other > > direction as far as I know. > > > > TIA, > > > > shouxun ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-17 1:37 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <200807161713.23716.yang.shx@fltrp.com> 2008-07-16 9:13 ` Q: type conversion with Gdome Yang Shouxun 2008-07-16 9:44 ` [Caml-list] " Claudio Sacerdoti Coen [not found] ` <200807170942.45470.yang.shx@fltrp.com> 2008-07-17 1:42 ` Yang Shouxun
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox