1 22 23 package org.xquark.xpath.datamodel; 24 25 import java.util.HashMap ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 public class ValidationContextProvider 30 implements org.xquark.schema.validation.ValidationContextProvider { 31 public static final String RCSRevision = "$Revision: 1.1 $"; 32 public static final String RCSName = "$Name: $"; 33 34 protected HashMap namespaces; 35 protected HashMap notations; 36 protected String documentBase; 37 protected HashMap reverseNamespaces = null; 38 39 42 public ValidationContextProvider(Map namespaces, HashMap notations, 43 String documentBase) { 44 this.namespaces = new HashMap (namespaces); 45 46 if (notations != null) { 47 this.notations = new HashMap (notations); 48 } 49 50 this.documentBase = documentBase; 51 } 52 53 56 public String getDocumentBase() { 57 return documentBase; 58 } 59 60 63 public Map getNotationDeclarations() { 64 return notations; 65 } 66 67 70 public String getNamespaceURI(String prefix) { 71 return (String ) namespaces.get(prefix); 72 } 73 74 77 public String getPrefix(String uri) { 78 if (reverseNamespaces == null) { 79 reverseNamespaces = new HashMap (namespaces.size()); 80 81 Iterator iterator = namespaces.keySet().iterator(); 82 Object pre; 83 Object name; 84 85 while (iterator.hasNext()) { 86 pre = iterator.next(); 87 name = namespaces.get(pre); 88 reverseNamespaces.put(name, pre); 89 } 90 } 91 92 return (String ) reverseNamespaces.get(uri); 93 } 94 } 95 | Popular Tags |