[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem parsing XML file with Xerces-J

  • To: Michael Kay <mike@s...>
  • Subject: Re: Problem parsing XML file with Xerces-J
  • From: Midsummer Sun <midsummer.sun@g...>
  • Date: Thu, 31 Mar 2005 17:50:12 +0530
  • Cc: xml-dev@l...
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Z2ydJeMLOYFXLDpdRDEmVJFxfq+oZaS8BW2+L5TG5GF98TZDwvBjlyLzCmTmaZWycp2Ct7BfOANpew8NgzwnoO/ihdJyA6R2gA2xmBeUDxFGe0Fy8MwBLLOcBp6qUw4zP/OSopocT1Y2fzOFl1WAD9fOmOX9NV06OU7txMiPF6k=
  • In-reply-to: <424bdf7e.7951e70a.3b2f.7f32SMTPIN_ADDED@m...>
  • References: <bb5e8b8605033103075ab8fe0c@m...> <424bdf7e.7951e70a.3b2f.7f32SMTPIN_ADDED@m...>
  • Reply-to: Midsummer Sun <midsummer.sun@g...>

xml to string java
I am obliged by your help. 

So I have done this change to my Java class (which extends
DefaultHandler) i.e. added this method definition..

public InputSource resolveEntity(java.lang.String publicId,
                                   java.lang.String systemId)
                     throws java.io.IOException, SAXException
 {

    return new InputSource();
 }

I guess that "return new InputSource()" method call will return an
InputSource pointing to an empty DTD(you suggested this workaround).
Please correct me if I am wrong.

But the program is giving error:

XYZ.java:125: resolveEntity(java.lang.String,java.lang.String) in XYZ
cannot override resolveEntity(java.lang.String,java.lang.String) in
org.xml.
sax.helpers.DefaultHandler; overridden method does not throw java.io.IOException

  public InputSource resolveEntity(java.lang.String publicId,
                     ^
1 error

Now this seems to be a Java exception handling problem.. I am good at
Java but not too good!

Please tell the remedy.

Best regards,


On Thu, 31 Mar 2005 12:26:54 +0100, Michael Kay <mike@s...> wrote:
> You need to do two things
> 
> (a) register your EntityResolver with the parser - you've done this
> 
> (b) use your EntityResolver to resolve URI references - you seem to have
> omitted this step.
> 
> This means you need to implement the resolveEntity() method to do something
> useful when presented with the system ID of the external DTD - like
> returning an InputSource pointing to an empty DTD.
> 
> The default implementation of resolveEntity() in DefaultHandler does
> nothing, you need to override it.
> 
> Michael Kay
> http://www.saxonica.com/

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.