Re: [Simple-support] Object obj = node.getSource() ?
Brought to you by:
niallg
|
From: Niall G. - Y. <Nia...@yi...> - 2013-01-17 00:13:34
|
Different platforms use different XML parsers, for instance Android uses XmlPull, Java 1.5 uses DOM, Javae 1.5 with StAX in the classpath uses StAX. Java 1.6 uses StAX.
From: Jaewoo Lee [mailto:dl...@gm...]
Sent: Wednesday, 16 January 2013 9:02 PM
To: sim...@li...
Subject: Re: [Simple-support] Object obj = node.getSource() ?
I installed Java Platform (JDK) 7u11. And in classpath, there are stax-1.2.0, too.
SOURCE LIST means iterator or linked-list of node.getSource().
The following is my Converter code.
public class SXCMTSConverter implements Converter<SXCMTS>{
@Override
public SXCMTS read(InputNode node) throws Exception {
Object obj = node.getSource();
Element element = (Element)obj; <-- HERE ClassCastException occured.
return new SXCMTS();
}
@Override
public void write(OutputNode node, SXCMTS arg1) throws Exception {
}
}
Error Message :
java.lang.ClassCastException: com.sun.xml.internal.stream.events.StartElementEvent cannot be cast to org.w3c.dom.Element
Am I missing something? or Is there any way to solve this problem?
Thank you for your help, Niall.
2013/1/11 Niall Gallagher <gal...@ya...<mailto:gal...@ya...>>
What is a SOURCE LIST? node.getSource() will product the underlying object, if you are using a JDK 1.6 or above this will be StAX its only DOM by default for 1.5 if you do not have StAX on the classpath. You can force the provider to DOM if you like. To do this take a closer look at the HackJob test case.
Thanks,
Niall
--- On Fri, 11/1/13, Jaewoo Lee <dl...@gm...<mailto:dl...@gm...>> wrote:
> From: Jaewoo Lee <dl...@gm...<mailto:dl...@gm...>>
> Subject: [Simple-support] Object obj = node.getSource() ?
> To: sim...@li...<mailto:sim...@li...>
> Received: Friday, 11 January, 2013, 1:54 AM
> Hi, Niall.
> During using Converter,
> I wanna make a SOURCE LIST of
> InputNode
> So I am referencing
> "HackJobToGrabFloatingTextTest.java".
>
> It's my code that I
> imitate HackJobToGrabFloatingTextTest.
> import
> org.simpleframework.xml.convert.Converter;import
> org.simpleframework.xml.stream.InputNode;
> import
> org.simpleframework.xml.stream.OutputNode;import
> org.w3c.dom.Element;
> public class SXCMTSConverter implements
> Converter<SXCMTS>{
> @Override
> public SXCMTS
> read(InputNode node) throws Exception
> { Object obj =
> node.getSource(); Element
> element = (Element)obj;
> .....
> } .....}
> but Exception popped.
> java.lang.ClassCastException:
> com.sun.xml.internal.stream.events.StartElementEvent cannot
> be cast to org.w3c.dom.Element
>
> Is that code something wrong ? Or
> wrong version of library? If wrong version, could you let me
> know right version of that Library?Or How do I
> make a list of Source List of Input Node?
>
> Thanks for your help.
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> Master HTML5, CSS3, ASP.NET<http://ASP.NET>, MVC, AJAX, Knockout.js, Web API
> and
> much more. Get web development skills now with LearnDevNow
> -
> 350+ hours of step-by-step video tutorials by Microsoft MVPs
> and experts.
> SALE $99.99 this month only -- learn more at:
> http://p.sf.net/sfu/learnmore_122812
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<mailto:Sim...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|