Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:27:56+00:00 2026-06-01T13:27:56+00:00

Xerces claims to allow XML Catalog support to be added to a reader like

  • 0

Xerces claims to allow XML Catalog support to be added to a reader like this:

XMLCatalogResolver resolver = new XMLCatalogResolver();
resolver.setPreferPublic(true);
resolver.setCatalogList(catalogs);

XMLReader reader = XMLReaderFactory.createXMLReader(
    "org.apache.xerces.parsers.SAXParser");
reader.setProperty("http://apache.org/xml/properties/internal/entity-resolver",
    resolver);

But as soon as I do this then any <xs:include/> tags in my schemas are no longer processed. It seems like the XMLCatalogResolver becomes the only go-to place for entity resolution once it’s added, so includes can’t work anymore. Eclipse OTOH successfully validates using the same catalog, so it should be possilbe.

Is there a way around this, or are there any other Java based validators that support catalogs?

Thanks, Dominic.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:27:57+00:00Added an answer on June 1, 2026 at 1:27 pm

    I finally solved this by overriding the XMLCatalogResolver and logging the various calls made to the resolveEntity() method. I observed 3 types of call being made, only one of which made sense to be resolved using the XML catalog. So, I merely returned a FileInputStream directly for the other two call types.

    Here is the code I used inside my custom XMLCatalogResolver class:

    public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
        throws IOException
    {
        if(resourceIdentifier.getExpandedSystemId() != null)
        {
            return new XMLInputSource(resourceIdentifier.getPublicId(),
                resourceIdentifier.getLiteralSystemId(),
                resourceIdentifier.getBaseSystemId(),
                new FileReader(getFile(resourceIdentifier.getExpandedSystemId())),
                "UTF-8");
        }
        else if((resourceIdentifier.getBaseSystemId() != null) &&
            (resourceIdentifier.getNamespace() == null))
        {
            return new XMLInputSource(resourceIdentifier.getPublicId(),
                resourceIdentifier.getLiteralSystemId(),
                resourceIdentifier.getBaseSystemId(),
                new FileReader(getFile(resourceIdentifier.getBaseSystemId())),
                "UTF-8");
        }
        else
        {
            return super.resolveEntity(resourceIdentifier);
        }
    }
    
    private File getFile(String urlString) throws MalformedURLException
    {
        URL url = new URL(urlString);
        return new File(url.toURI());
    }
    

    I’m not sure why this wouldn’t be done by default within Xerces, but hopefully this helps the next person that encounters this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there are some very good Perl XML parsers like XML::Xerces , XML::Parser::Expat
I got some sensible xml data I'd like to parse with Xerces (generated by
I am using Xerces 2.9.1 to perform some XML parsing. The XML contains namespace
Looking for something similar to xerces for parsing an xml file in ruby. I
I want to load an XML document in Xerces-C++ (version 2.8, under Linux), and
I'm trying to run through an example given for the C++ Xerces XML library
Because of transitive dependencies, my wars are getting populated by xml-apis, xerces jars. I
i am using Xerces to do some xml writing. here's a couple of lines
I'm using the Xerces C++ DOM parser to read some XML files in a
I have Xerces and Oracle XML parsers both in my application's classpath (don't ask

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.