473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DocumentBuilder .parse returns DeferredDocumen tImpl???

Hi,

According to the API specification,
javax.xml.parse rs.DocumentBuil der.parse should return an
org.w3c.dom.Doc ument. However, when I use the following code:

DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();
factory.setVali dating(false);
factory.setName spaceAware(fals e);
DocumentBuilder builder = factory.newDocu mentBuilder();
ByteArrayInputS tream xmlIs = new
ByteArrayInputS tream(polisLijs t.getBytes());
Object parseReturn = builder.parse(x mlIs);
System.out.prin tln("######## ["+parseReturn.g etClass().getNa me()+"]
######");
Document xmlDoc = (Document) parseReturn;

the println prints:

######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######

and the final statement gives an exception:

[java.lang.Class CastException]
[org.apache.xerc es.dom.Deferred DocumentImpl]
stack-trace=[java.lang.Class CastException: ...

Why do I get an DeferredDocumen tImpl when I should get a Document? Am
I doing something wrong? Or else: how do I create a Document from this
mysterious DeferredDocumen tImpl?

Regards,
Edwin
Jul 17 '05 #1
3 15384
org.w3c.dom.Doc ument is an interface. While I haven't checked out
DeferredDocumen tImpl, it most likely implements this interface.

My guess is that there is another class Document from a different package.
Try using the fully qualified class name:

org.w3c.dom.Doc ument xmlDoc = (org.w3c.dom.Do cument)parseRet urn;

On Tue, 24 Jun 2003 05:11:49 -0700, edwinek wrote:
Hi,

According to the API specification,
javax.xml.parse rs.DocumentBuil der.parse should return an
org.w3c.dom.Doc ument. However, when I use the following code:

DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();
factory.setVali dating(false);
factory.setName spaceAware(fals e);
DocumentBuilder builder = factory.newDocu mentBuilder();
ByteArrayInputS tream xmlIs = new
ByteArrayInputS tream(polisLijs t.getBytes()); Object parseReturn =
builder.parse(x mlIs); System.out.prin tln("########
["+parseReturn.g etClass().getNa me()+"] ######");
Document xmlDoc = (Document) parseReturn;

the println prints:

######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######

and the final statement gives an exception:

[java.lang.Class CastException]
[org.apache.xerc es.dom.Deferred DocumentImpl]
stack-trace=[java.lang.Class CastException: ...

Why do I get an DeferredDocumen tImpl when I should get a Document? Am I
doing something wrong? Or else: how do I create a Document from this
mysterious DeferredDocumen tImpl?

Regards,
Edwin


--
Keep American Families united! Support H.R. 539 and H.R. 832
For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml

Jul 17 '05 #2
No, that wasn't it. I tried, but get the same exception.

"Ingo Pakleppa" <in************ *@kkeane.com> wrote in message news:<pa******* *************** ******@kkeane.c om>...
org.w3c.dom.Doc ument is an interface. While I haven't checked out
DeferredDocumen tImpl, it most likely implements this interface.

My guess is that there is another class Document from a different package.
Try using the fully qualified class name:

org.w3c.dom.Doc ument xmlDoc = (org.w3c.dom.Do cument)parseRet urn;

On Tue, 24 Jun 2003 05:11:49 -0700, edwinek wrote:
Hi,

According to the API specification,
javax.xml.parse rs.DocumentBuil der.parse should return an
org.w3c.dom.Doc ument. However, when I use the following code:

DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();
factory.setVali dating(false);
factory.setName spaceAware(fals e);
DocumentBuilder builder = factory.newDocu mentBuilder();
ByteArrayInputS tream xmlIs = new
ByteArrayInputS tream(polisLijs t.getBytes()); Object parseReturn =
builder.parse(x mlIs); System.out.prin tln("########
["+parseReturn.g etClass().getNa me()+"] ######");
Document xmlDoc = (Document) parseReturn;

the println prints:

######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######

and the final statement gives an exception:

[java.lang.Class CastException]
[org.apache.xerc es.dom.Deferred DocumentImpl]
stack-trace=[java.lang.Class CastException: ...

Why do I get an DeferredDocumen tImpl when I should get a Document? Am I
doing something wrong? Or else: how do I create a Document from this
mysterious DeferredDocumen tImpl?

Regards,
Edwin

Jul 17 '05 #3
That would be very strange indeed, because the compiler should have
complained about that when they developed the library. Can you use
reflection to get the prototype of parse from the builder class (use
builder.getClas s().getMethods( ) )? Can you use reflection to find out all
the base classes and interfaces from the DeferredDocumen tImpl class (hint:
use getClass().getI nterfaces()).

On Tue, 24 Jun 2003 22:59:07 -0700, edwinek wrote:
Sadly the DeferredDocumen tImpl class doesn't implement the Document
interface. There is no way to cast it to Document. So why does a method
that according to the API should return a Document return something
entirely different?

"Ingo Pakleppa" <in************ *@kkeane.com> wrote in message
news:<pa******* *************** ******@kkeane.c om>...
org.w3c.dom.Doc ument is an interface. While I haven't checked out
DeferredDocumen tImpl, it most likely implements this interface.

My guess is that there is another class Document from a different
package. Try using the fully qualified class name:

org.w3c.dom.Doc ument xmlDoc = (org.w3c.dom.Do cument)parseRet urn;

On Tue, 24 Jun 2003 05:11:49 -0700, edwinek wrote:
> Hi,
>
> According to the API specification,
> javax.xml.parse rs.DocumentBuil der.parse should return an
> org.w3c.dom.Doc ument. However, when I use the following code:
>
> DocumentBuilder Factory factory =
> DocumentBuilder Factory.newInst ance(); factory.setVali dating(false);
> factory.setName spaceAware(fals e);
> DocumentBuilder builder = factory.newDocu mentBuilder();
> ByteArrayInputS tream xmlIs = new
> ByteArrayInputS tream(polisLijs t.getBytes()); Object parseReturn =
> builder.parse(x mlIs); System.out.prin tln("########
> ["+parseReturn.g etClass().getNa me()+"] ######"); Document xmlDoc =
> (Document) parseReturn;
>
> the println prints:
>
> ######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######
>
> and the final statement gives an exception:
>
> [java.lang.Class CastException]
> [org.apache.xerc es.dom.Deferred DocumentImpl]
> stack-trace=[java.lang.Class CastException: ...
>
> Why do I get an DeferredDocumen tImpl when I should get a Document? Am
> I doing something wrong? Or else: how do I create a Document from
> this mysterious DeferredDocumen tImpl?
>
> Regards,
> Edwin


--
Keep American Families united! Support H.R. 539 and H.R. 832
For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9708
by: Dave Kuhlman | last post by:
Suppose that I have content that looks like what I've included at the end of this message. Is there something in the standard Python library that will help me parse it, break into the parts separated by the boundary strings, extract headers from each sub-part, etc? Do I need to add something like the following to the beginning? ...
9
3165
by: ThunderMusic | last post by:
Hi, I'm using the timespan's Parse method to build my timespan from a string. here's the line I use : m_Delay.Parse(RegKey.GetValue("Delay", "01:00:00")) the value I get from the RegKey is 00:00:30, so it should give a timespan of 30 seconds, but when I do msgbox(m_Delay.ToString), it displays 00:00:00. Am I doing something wrong?
3
35067
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
14
3657
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style of date formatting (RFC 822). I have been using a variation of RFC 1123 (just change the time zone to an offset, i.e. "-0800"). It seems to be...
3
4011
by: GP | last post by:
Decimal.Parse("100,5") returns 1005 when it should throw an InvalidFormatException. The locale is US therefore the "," is a thousand separator. Even if the parser confused it for the decimal separator it should return 100.5. Maybe this bug is already logged but I couldn't find it on MSDN. -- Best regards, Gianluca Pivato --
1
64063
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this article “How to Parse a File in C++”, we are actually mostly lexing a file which is the breaking down of a stream in to its component parts,...
1
2323
by: schaf | last post by:
Hi NG! I have a little question about the localization of a double. If I use the CultureInfo "en-US" I have the following behavior: 1.) If I enter the value 2.5 into a textbox the double.Parse(text1.Text) returns 2.5 as expected. 2.) If I enter the value 2,5 into a textbox the double.Parse(text1.Text) returns 25...why 25 and not 2500....
11
3515
by: Peter Pei | last post by:
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which returns a elementtree, on which you can then apply xpath; 2) To parse a string (xml section), you can call XML or fromstring, but both return element...
4
6627
by: =?Utf-8?B?ZGF2ZWJ5dGhlc2Vh?= | last post by:
Hi folks, Boolean.Parse("true") returns true, but what if you need to parse something such as - Boolean.Parse("(false && false) || (false || (true && true))"); Does something exist in the .NET framework to Parse this kind of string to one final boolean result?
0
7896
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8184
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7936
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8195
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.