Project

General

Profile

1
package edu.ucsb.nceas.metacat.index;
2

    
3
import javax.xml.XMLConstants;
4
import javax.xml.namespace.NamespaceContext;
5
import java.util.HashMap;
6
import java.util.Iterator;
7
import java.util.Map;
8

    
9
/**
10
 */
11
public class MCXmlNamespace implements NamespaceContext {
12
	// Namespace prefixes for use in XPath expressions
13
	// The literal values assigned here should be distinct but are not significant -- they
14
	// may equally be "a" "b" "c" etc as long as the symbolic names are used consistently
15
	public static final String E200 = "e200";
16
	public static final String E211 = "e211";
17
	public static final String E210 = "e210";
18
	public static final String E201 = "e201";
19
	public static final String D1 = "d1";
20
	public static final String ORE = "ore";
21
	public static final String DC = "dc";
22
	public static final String DCT = "dct";
23
	public static final String FOAF = "foaf";
24

    
25
	private static final Map<String, String> prefixes;
26
	static {
27
		prefixes = new HashMap<String, String>();
28
		prefixes.put(E200, "eml://ecoinformatics.org/eml-2.0.0");
29
		prefixes.put(E201, "eml://ecoinformatics.org/eml-2.0.1");
30
		prefixes.put(E210, "eml://ecoinformatics.org/eml-2.1.0");
31
		prefixes.put(E211, "eml://ecoinformatics.org/eml-2.1.1");
32
		prefixes.put(D1, "http://ns.dataone.org/service/types/v1");
33
		prefixes.put(ORE, "http://www.openarchives.org/ore/terms/");
34
		prefixes.put(DC, "http://purl.org/dc/elements/1.1/");
35
		prefixes.put(DCT, "http://purl.org/dc/terms/");
36
		prefixes.put(FOAF, "http://xmlns.com/foaf/0.1/");
37
	}
38
	@Override
39
	public String getNamespaceURI(String prefix) {
40
		String ns = prefixes.get(prefix);
41
		return (ns != null) ? ns : XMLConstants.NULL_NS_URI;
42
	}
43
	@Override
44
	public String getPrefix(String namespaceURI) {
45
		throw new UnsupportedOperationException();
46
	}
47
	@Override
48
	public Iterator getPrefixes(String namespaceURI) {
49
		throw new UnsupportedOperationException();
50
	}
51
}
52

    
(10-10/13)