getLogger().debug("Base URI: null");
else
getLogger().debug("Base URI: " + current_xmlbase_uri.getSystemId());
}
Source url = null;
String suffix;
try {
int index = href.indexOf('#');
if (index < 0) {
if(current_xmlbase_uri == null)
url = this.resolver.resolve(href);
else
url = this.resolver.resolve(current_xmlbase_uri.getSystemId() + href);
suffix = "";
} else {
if(current_xmlbase_uri == null)
url = this.resolver.resolve(href.substring(0,index));
else
url = this.resolver.resolve(current_xmlbase_uri.getSystemId() + href.substring(0,index));
suffix = href.substring(index+1);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("URL: "+url+"\nSuffix: "+suffix);
}
if (parse.equals("text")) {
getLogger().debug("Parse type is text");
InputStream input = url.getInputStream();
Reader reader = new BufferedReader(new InputStreamReader(input));
int read;
char ary[] = new char[1024];
if (reader != null) {
while ((read = reader.read(ary)) != -1) {
super.characters(ary,0,read);
}
reader.close();
}
} else if (parse.equals("xml")) {
getLogger().debug("Parse type is XML");
Parser parser = null;
try {
parser = (Parser)manager.lookup(Parser.ROLE);
InputSource input = url.getInputSource();
if (suffix.startsWith("xpointer(") && suffix.endsWith(")")) {
String xpath = suffix.substring(9,suffix.length()-1);
getLogger().debug("XPath is "+xpath);
Document document = parser.parseDocument(input);
NodeList list = processor.selectNodeList(document,xpath);
DOMStreamer streamer = new DOMStreamer(super.contentHandler,super.lexicalHandler);
int length = list.getLength();
for (int i=0; i<length; i++) {
streamer.stream(list.item(i));
}
} else {
IncludeXMLConsumer xinclude_handler = new IncludeXMLConsumer(super.contentHandler,super.lexicalHandler);
xinclude_handler.setLogger(getLogger());
parser.setConsumer(xinclude_handler);
parser.parse(input);
}
} catch(SAXException e) {
getLogger().error("Error in processXIncludeElement", e);
throw e;
} catch(ProcessingException e) {
getLogger().error("Error in processXIncludeElement", e);
throw e;
} catch(MalformedURLException e) {
getLogger().error("Error in processXIncludeElement", e);
throw e;
} catch(IOException e) {
getLogger().error("Error in processXIncludeElement", e);
throw e;
} catch(ComponentException e) {
getLogger().error("Error in processXIncludeElement", e);
throw new SAXException(e);
} finally {
if(parser != null) this.manager.release(parser);
}
}
} finally {
if (url != null) url.recycle();
}
}