// Prefix already defined
if (nsMap.get(prefix).equals(uri)) {
// duplicate, ignore
}
else {
throw new MalformedQueryException("Multiple namespace declarations for prefix '" + prefix
+ "'");
}
}
else {
nsMap.put(prefix, uri);
}
}
// Use default namespace prefixes when not defined explicitly
if (!nsMap.containsKey("rdf")) {
nsMap.put("rdf", RDF.NAMESPACE);
}
if (!nsMap.containsKey("rdfs")) {
nsMap.put("rdfs", RDFS.NAMESPACE);
}
if (!nsMap.containsKey("xsd")) {
nsMap.put("xsd", XMLSchema.NAMESPACE);
}
if (!nsMap.containsKey("owl")) {
nsMap.put("owl", OWL.NAMESPACE);
}
if (!nsMap.containsKey("sesame")) {
nsMap.put("sesame", SESAME.NAMESPACE);
}
// For backwards compatibility:
Map<String, String> extendedNsMap = new HashMap<String, String>(nsMap);
if (!extendedNsMap.containsKey("serql")) {
extendedNsMap.put("serql", SESAME.NAMESPACE);
}
// Replace all qnames with URIs
QNameProcessor visitor = new QNameProcessor(extendedNsMap);
try {
qc.jjtAccept(visitor, null);
}
catch (VisitorException e) {
throw new MalformedQueryException(e.getMessage(), e);
}
return nsMap;
}