lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrzej Bialecki ...@getopt.org>
Subject Re: indexing xml files with relative links to dtds
Date Fri, 14 Feb 2003 21:12:04 GMT
icewind wrote:

>Ok, I used parser.setFeature to turn the validation
>off. This helps, but it turns out there are entity
>references in the XML files as well. These are causing
>the same problems the DTD references were causing
>before...
>
>Any suggestions with regards to this?
>  
>

The solution is relatively simple - you need to implement your own 
EntityResolver, and set the parser to use your resolver instead of the 
built-in one. You need to implement the following method in your 
EntityResolver:

/** This method is called when the parser encounters a reference
 *  to external entity. If this method returns valid InputSource, with
 *  InputStream open, the parser will use it, otherwise it will
 *  try to get the resource itself, opening any connections needed.
 */
public InputSource resolveEntity(String publicId, String systemId) {
   ...
}

It's good to extend DefaultHandler, to avoid implementing methods that 
don't matter to you.

-- 
Best regards,
Andrzej Bialecki

-------------------------------------------------
Software Architect, System Integration Specialist
-------------------------------------------------
FreeBSD developer (http://www.freebsd.org)




---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message