1 16 17 package org.apache.xerces.impl.dv.xs; 18 19 import org.apache.xerces.impl.dv.XSSimpleType; 20 import org.apache.xerces.impl.dv.XSFacets; 21 import org.apache.xerces.util.SymbolHash; 22 import org.apache.xerces.xs.XSConstants; 23 24 34 public class FullDVFactory extends BaseDVFactory { 35 36 static final String URI_SCHEMAFORSCHEMA = "http://www.w3.org/2001/XMLSchema"; 37 38 static SymbolHash fFullTypes = new SymbolHash(89); 40 static { 41 createBuiltInTypes(fFullTypes); 42 } 43 44 55 public XSSimpleType getBuiltInType(String name) { 56 return (XSSimpleType)fFullTypes.get(name); 57 } 58 59 65 public SymbolHash getBuiltInTypes() { 66 return (SymbolHash)fFullTypes.makeClone(); 67 } 68 69 static void createBuiltInTypes(SymbolHash types) { 71 BaseDVFactory.createBuiltInTypes(types); 73 74 final String DOUBLE = "double"; 76 final String DURATION = "duration"; 77 final String ENTITY = "ENTITY"; 78 final String ENTITIES = "ENTITIES"; 79 final String FLOAT = "float"; 80 final String HEXBINARY = "hexBinary"; 81 final String ID = "ID"; 82 final String IDREF = "IDREF"; 83 final String IDREFS = "IDREFS"; 84 final String NAME = "Name"; 85 final String NCNAME = "NCName"; 86 final String NMTOKEN = "NMTOKEN"; 87 final String NMTOKENS = "NMTOKENS"; 88 final String LANGUAGE = "language"; 89 final String NORMALIZEDSTRING = "normalizedString"; 90 final String NOTATION = "NOTATION"; 91 final String QNAME = "QName"; 92 final String STRING = "string"; 93 final String TOKEN = "token"; 94 95 final XSFacets facets = new XSFacets(); 96 97 XSSimpleTypeDecl anySimpleType = XSSimpleTypeDecl.fAnySimpleType; 98 XSSimpleTypeDecl stringDV = (XSSimpleTypeDecl)types.get(STRING); 99 100 types.put(FLOAT, new XSSimpleTypeDecl(anySimpleType, FLOAT, XSSimpleTypeDecl.DV_FLOAT, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.FLOAT_DT)); 101 types.put(DOUBLE, new XSSimpleTypeDecl(anySimpleType, DOUBLE, XSSimpleTypeDecl.DV_DOUBLE, XSSimpleType.ORDERED_PARTIAL, true, true, true, true, XSConstants.DOUBLE_DT)); 102 types.put(DURATION, new XSSimpleTypeDecl(anySimpleType, DURATION, XSSimpleTypeDecl.DV_DURATION, XSSimpleType.ORDERED_PARTIAL, false, false, false, true, XSConstants.DURATION_DT)); 103 types.put(HEXBINARY, new XSSimpleTypeDecl(anySimpleType, HEXBINARY, XSSimpleTypeDecl.DV_HEXBINARY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.HEXBINARY_DT)); 104 types.put(QNAME, new XSSimpleTypeDecl(anySimpleType, QNAME, XSSimpleTypeDecl.DV_QNAME, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.QNAME_DT)); 105 types.put(NOTATION, new XSSimpleTypeDecl(anySimpleType, NOTATION, XSSimpleTypeDecl.DV_NOTATION, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.NOTATION_DT)); 106 107 facets.whiteSpace = XSSimpleType.WS_REPLACE; 108 XSSimpleTypeDecl normalizedDV = new XSSimpleTypeDecl(stringDV, NORMALIZEDSTRING , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NORMALIZEDSTRING_DT); 109 normalizedDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 ); 110 types.put(NORMALIZEDSTRING, normalizedDV); 111 112 facets.whiteSpace = XSSimpleType.WS_COLLAPSE; 113 XSSimpleTypeDecl tokenDV = new XSSimpleTypeDecl(normalizedDV, TOKEN , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.TOKEN_DT); 114 tokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0 ); 115 types.put(TOKEN, tokenDV); 116 117 facets.whiteSpace = XSSimpleType.WS_COLLAPSE; 118 facets.pattern = "([a-zA-Z]{1,8})(-[a-zA-Z0-9]{1,8})*"; 119 XSSimpleTypeDecl languageDV = new XSSimpleTypeDecl(tokenDV, LANGUAGE , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.LANGUAGE_DT); 120 languageDV.applyFacets1(facets, (short)(XSSimpleType.FACET_WHITESPACE | XSSimpleType.FACET_PATTERN) ,(short)0); 121 types.put(LANGUAGE, languageDV); 122 123 facets.whiteSpace = XSSimpleType.WS_COLLAPSE; 124 XSSimpleTypeDecl nameDV = new XSSimpleTypeDecl(tokenDV, NAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NAME_DT); 125 nameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NAME); 126 types.put(NAME, nameDV); 127 128 facets.whiteSpace = XSSimpleType.WS_COLLAPSE; 129 XSSimpleTypeDecl ncnameDV = new XSSimpleTypeDecl(nameDV, NCNAME , URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NCNAME_DT) ; 130 ncnameDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NCNAME); 131 types.put(NCNAME, ncnameDV); 132 133 types.put(ID, new XSSimpleTypeDecl(ncnameDV, ID, XSSimpleTypeDecl.DV_ID, XSSimpleType.ORDERED_FALSE, false, false, false , true, XSConstants.ID_DT)); 134 XSSimpleTypeDecl idrefDV = new XSSimpleTypeDecl(ncnameDV, IDREF , XSSimpleTypeDecl.DV_IDREF, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.IDREF_DT); 135 types.put(IDREF, idrefDV); 136 137 facets.minLength = 1; 138 XSSimpleTypeDecl tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, idrefDV, true, null); 139 XSSimpleTypeDecl idrefsDV = new XSSimpleTypeDecl(tempDV, IDREFS, URI_SCHEMAFORSCHEMA, (short)0, false, null); 140 idrefsDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0); 141 types.put(IDREFS, idrefsDV); 142 143 XSSimpleTypeDecl entityDV = new XSSimpleTypeDecl(ncnameDV, ENTITY , XSSimpleTypeDecl.DV_ENTITY, XSSimpleType.ORDERED_FALSE, false, false, false, true, XSConstants.ENTITY_DT); 144 types.put(ENTITY, entityDV); 145 146 facets.minLength = 1; 147 tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, entityDV, true, null); 148 XSSimpleTypeDecl entitiesDV = new XSSimpleTypeDecl(tempDV, ENTITIES, URI_SCHEMAFORSCHEMA, (short)0, false, null); 149 entitiesDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0); 150 types.put(ENTITIES, entitiesDV); 151 152 153 facets.whiteSpace = XSSimpleType.WS_COLLAPSE; 154 XSSimpleTypeDecl nmtokenDV = new XSSimpleTypeDecl(tokenDV, NMTOKEN, URI_SCHEMAFORSCHEMA, (short)0, false, null, XSConstants.NMTOKEN_DT); 155 nmtokenDV.applyFacets1(facets, XSSimpleType.FACET_WHITESPACE, (short)0, XSSimpleTypeDecl.SPECIAL_PATTERN_NMTOKEN); 156 types.put(NMTOKEN, nmtokenDV); 157 158 facets.minLength = 1; 159 tempDV = new XSSimpleTypeDecl(null, URI_SCHEMAFORSCHEMA, (short)0, nmtokenDV, true, null); 160 XSSimpleTypeDecl nmtokensDV = new XSSimpleTypeDecl(tempDV, NMTOKENS, URI_SCHEMAFORSCHEMA, (short)0, false, null); 161 nmtokensDV.applyFacets1(facets, XSSimpleType.FACET_MINLENGTH, (short)0); 162 types.put(NMTOKENS, nmtokensDV); 163 } 165 } | Popular Tags |