1
|
package eu.etaxonomy.cdm.jaxb;
|
2
|
|
3
|
import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
|
4
|
|
5
|
public class CdmNamespacePrefixMapper extends NamespacePrefixMapper {
|
6
|
|
7
|
private static final String CDM_PREFIX = "";
|
8
|
private static final String AGENT_PREFIX = "agent";
|
9
|
private static final String COMMON_PREFIX = "common";
|
10
|
private static final String DESCRIPTION_PREFIX = "description";
|
11
|
private static final String LOCATION_PREFIX = "location";
|
12
|
private static final String MEDIA_PREFIX = "media";
|
13
|
private static final String MOLECULAR_PREFIX = "molecular";
|
14
|
private static final String NAME_PREFIX = "name";
|
15
|
private static final String OCCURRENCE_PREFIX = "occurrence";
|
16
|
private static final String REFERENCE_PREFIX = "reference";
|
17
|
private static final String TAXON_PREFIX = "taxon";
|
18
|
|
19
|
public static final String CDM_NAMESPACE = "http://etaxonomy.eu/cdm/model/1.0";
|
20
|
public static final String AGENT_NAMESPACE = "http://etaxonomy.eu/cdm/model/agent/1.0";
|
21
|
public static final String COMMON_NAMESPACE = "http://etaxonomy.eu/cdm/model/common/1.0";
|
22
|
public static final String DESCRIPTION_NAMESPACE = "http://etaxonomy.eu/cdm/model/description/1.0";
|
23
|
public static final String LOCATION_NAMESPACE = "http://etaxonomy.eu/cdm/model/location/1.0";
|
24
|
public static final String MEDIA_NAMESPACE = "http://etaxonomy.eu/cdm/model/media/1.0";
|
25
|
public static final String MOLECULAR_NAMESPACE = "http://etaxonomy.eu/cdm/model/molecular/1.0";
|
26
|
public static final String NAME_NAMESPACE = "http://etaxonomy.eu/cdm/model/name/1.0";
|
27
|
public static final String OCCURRENCE_NAMESPACE = "http://etaxonomy.eu/cdm/model/occurrence/1.0";
|
28
|
public static final String REFERENCE_NAMESPACE = "http://etaxonomy.eu/cdm/model/reference/1.0";
|
29
|
public static final String TAXON_NAMESPACE = "http://etaxonomy.eu/cdm/model/taxon/1.0";
|
30
|
|
31
|
public String getPreferredPrefix(String namespaceURI, String suggestion, boolean requirePrefix) {
|
32
|
String result = suggestion;
|
33
|
|
34
|
/**
|
35
|
* Returning empty namespace prefix works if a SAXResult is used, but not
|
36
|
* a DOMResult - see http://forums.java.net/jive/thread.jspa?messageID=217155
|
37
|
* This has not been resolved yet, as far as I can tell
|
38
|
*/
|
39
|
|
40
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.CDM_NAMESPACE)) {
|
41
|
return CdmNamespacePrefixMapper.CDM_PREFIX;
|
42
|
}
|
43
|
|
44
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.AGENT_NAMESPACE)) {
|
45
|
return CdmNamespacePrefixMapper.AGENT_PREFIX;
|
46
|
}
|
47
|
|
48
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.COMMON_NAMESPACE)) {
|
49
|
return CdmNamespacePrefixMapper.COMMON_PREFIX;
|
50
|
}
|
51
|
|
52
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.DESCRIPTION_NAMESPACE)) {
|
53
|
return CdmNamespacePrefixMapper.DESCRIPTION_PREFIX;
|
54
|
}
|
55
|
|
56
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.LOCATION_NAMESPACE)) {
|
57
|
return CdmNamespacePrefixMapper.LOCATION_PREFIX;
|
58
|
}
|
59
|
|
60
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.MEDIA_NAMESPACE)) {
|
61
|
return CdmNamespacePrefixMapper.MEDIA_PREFIX;
|
62
|
}
|
63
|
|
64
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.MOLECULAR_NAMESPACE)){
|
65
|
return CdmNamespacePrefixMapper.MOLECULAR_PREFIX;
|
66
|
}
|
67
|
|
68
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.NAME_NAMESPACE)) {
|
69
|
return CdmNamespacePrefixMapper.NAME_PREFIX;
|
70
|
}
|
71
|
|
72
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.OCCURRENCE_NAMESPACE)) {
|
73
|
return CdmNamespacePrefixMapper.OCCURRENCE_PREFIX;
|
74
|
}
|
75
|
|
76
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.REFERENCE_NAMESPACE)) {
|
77
|
return CdmNamespacePrefixMapper.REFERENCE_PREFIX;
|
78
|
}
|
79
|
|
80
|
if(namespaceURI.equals(CdmNamespacePrefixMapper.TAXON_NAMESPACE)) {
|
81
|
return CdmNamespacePrefixMapper.TAXON_PREFIX;
|
82
|
}
|
83
|
|
84
|
return result;
|
85
|
}
|
86
|
|
87
|
}
|