1 package com.icl.saxon.om; 2 3 4 10 11 public abstract class Name { 12 13 16 17 public static boolean isNCName(String name) { 18 19 22 if (name.length()==0) return false; 23 char first = name.charAt(0); 24 if (!(first=='_' || Character.isLetter(first))) { 25 return false; 26 } 27 for (int i=1; i<name.length(); i++) { 28 char c = name.charAt(i); 29 if (!(c=='_' || c=='.' || c=='-' || Character.isLetter(c) || Character.isDigit(c))) { 30 return false; 31 } 32 } 33 return true; 34 } 35 36 39 40 public static boolean isQName(String name) { 41 int colon = name.indexOf(':'); 42 if (colon<0) return isNCName(name); 43 if (colon==0 || colon==name.length()-1) return false; 44 if (!isNCName(name.substring(0, colon))) return false; 45 if (!isNCName(name.substring(colon+1))) return false; 46 return true; 47 } 48 49 52 53 public final static String getPrefix(String qname) { 54 int colon = qname.indexOf(':'); 55 if (colon<0) { 56 return ""; 57 } 58 return qname.substring(0, colon); 59 } 60 61 64 65 public final static String getLocalName(String qname) { 66 int colon = qname.indexOf(':'); 67 if (colon<0) { 68 return qname; 69 } 70 return qname.substring(colon+1); 71 } 72 73 } 74 75 | Popular Tags |