/**
 * 
 */
package eu.fusepool.rdfizer.marec.xslt;

import java.io.IOException;


import org.apache.xerces.util.XMLCatalogResolver;
import org.apache.xml.resolver.tools.ResolvingXMLReader;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;

/**
 * @author giorgio
 *
 */
public class MarecXMLReader extends ResolvingXMLReader {

    
    XMLCatalogResolver resolver ;
    
    /**
     * @throws Exception 
     * @throws SAXNotRecognizedException 
     * 
     */
    public MarecXMLReader() throws SAXNotRecognizedException, Exception {
        super();
        String [] catalogs = {"file:///" + CatalogBuilder.getCatalogPath()};
        // Create catalog resolver and set a catalog list.
        resolver = new XMLCatalogResolver();
        resolver.setPreferPublic(true);
        resolver.setCatalogList(catalogs);
        
    }

    /* (non-Javadoc)
     * @see org.apache.xml.resolver.tools.ResolvingXMLFilter#resolveEntity(java.lang.String, java.lang.String)
     */
    @Override
    public InputSource resolveEntity(String publicId, String systemId) {
        try {
            //System.out.println("<public publicId=\""+publicId+"\"" + " uri=\""+systemId+"\" />");
            InputSource is = resolver.resolveEntity(publicId, systemId);
            if(is==null) {
                //System.out.println("############ NOT FOUND #########<public publicId=\""+publicId+"\"" + " uri=\""+systemId+"\" />");
            }
            return is ;
        } catch (SAXException e) {
            e.printStackTrace();
            return null ;
        } catch (IOException e) {
            e.printStackTrace();
            return null ;
        }
    }


    
    
    
}

@@ -628,19 +628,16 @@
 ring
- %5B%5D
  catalog
 s = 
@@ -636,26 +636,19 @@
 alog
-s = %7B%22file:///%22 + 
+Path = File
 Cata
@@ -674,16 +674,72 @@
 ogPath()
+;%0A        String %5B%5D catalogs = %7B%22file:///%22 + catalogPath
 %7D;%0A     
@@ -1181,34 +1181,32 @@
 y %7B%0A            
-//
 System.out.print
@@ -1225,33 +1225,35 @@
 publicId=%5C%22%22
-+
+ + 
 publicId
 +%22%5C%22%22 + %22 ur
@@ -1232,33 +1232,35 @@
 d=%5C%22%22 + publicId
-+
+ + 
 %22%5C%22%22 + %22 uri=%5C%22%22
@@ -1255,33 +1255,35 @@
  + %22 uri=%5C%22%22
-+
+ + 
 systemId
 +%22%5C%22 /%3E%22);%0A 
@@ -1262,33 +1262,35 @@
 i=%5C%22%22 + systemId
-+
+ + 
 %22%5C%22 /%3E%22);%0A      
@@ -1377,10 +1377,12 @@
 f(is
+ 
 ==
+ 
 null
@@ -1401,18 +1401,16 @@
         
-//
 System.o

use FileCatalogBuilder instead of CatalogBuilder