final SystemConfiguration sysConfig = getSystemConfiguration();
final String resourceIndexURL = sysConfig.getResourceIndexURL();
File indexFile = new File(resourceIndexURL);
if (!indexFile.exists() || !indexFile.canRead()) {
// try the index as an online resource.
ResolvedResource resolvedResource = c.resolveResource(
ResourceType.RESOURCE_INDEX, resourceIndexURL);
indexFile = resolvedResource.getCacheResourceCopy();
}
final ResourceIndex ri = ResourceIndex.INSTANCE;
ri.loadIndex(indexFile);
final Index index = ri.getIndex();
final List<ResourceLocation> nsr = index.getNamespaceResources();
final Map<String, NamespaceHeader> hvals;
if (hasItems(nsr)) {
hvals = new LinkedHashMap<String, NamespaceHeader>(index
.getNamespaceResources().size());
for (ResourceLocation rl : index.getNamespaceResources()) {
String loc = rl.getResourceLocation();
ResolvedResource nsResource = c.resolveResource(
ResourceType.NAMESPACES, loc);
NamespaceHeader header = p.parseNamespace(loc,
nsResource.getCacheResourceCopy());
hvals.put(loc, header);
}
} else {
hvals = new LinkedHashMap<String, NamespaceHeader>();
}