1 16 17 package org.apache.xerces.impl; 18 19 import java.io.IOException ; 20 21 import org.apache.xerces.util.SymbolTable; 22 import org.apache.xerces.util.XML11Char; 23 import org.apache.xerces.util.XMLChar; 24 import org.apache.xerces.util.XMLStringBuffer; 25 import org.apache.xerces.xni.XMLString; 26 import org.apache.xerces.xni.XNIException; 27 28 53 public class XML11DTDScannerImpl 54 extends XMLDTDScannerImpl { 55 56 57 private String [] fStrings = new String [3]; 58 59 60 private XMLString fString = new XMLString(); 61 62 63 private XMLStringBuffer fStringBuffer = new XMLStringBuffer(); 64 65 66 private XMLStringBuffer fStringBuffer2 = new XMLStringBuffer(); 67 private XMLStringBuffer fStringBuffer3 = new XMLStringBuffer(); 68 69 73 74 public XML11DTDScannerImpl() {super();} 76 77 public XML11DTDScannerImpl(SymbolTable symbolTable, 78 XMLErrorReporter errorReporter, XMLEntityManager entityManager) { 79 super(symbolTable, errorReporter, entityManager); 80 } 81 82 86 112 protected boolean scanPubidLiteral(XMLString literal) 113 throws IOException , XNIException 114 { 115 int quote = fEntityScanner.scanChar(); 116 if (quote != '\'' && quote != '"') { 117 reportFatalError("QuoteRequiredInPublicID", null); 118 return false; 119 } 120 121 fStringBuffer.clear(); 122 boolean skipSpace = true; 124 boolean dataok = true; 125 while (true) { 126 int c = fEntityScanner.scanChar(); 127 if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) { 129 if (!skipSpace) { 130 fStringBuffer.append(' '); 132 skipSpace = true; 133 } 134 } 135 else if (c == quote) { 136 if (skipSpace) { 137 fStringBuffer.length--; 139 } 140 literal.setValues(fStringBuffer); 141 break; 142 } 143 else if (XMLChar.isPubid(c)) { 144 fStringBuffer.append((char)c); 145 skipSpace = false; 146 } 147 else if (c == -1) { 148 reportFatalError("PublicIDUnterminated", null); 149 return false; 150 } 151 else { 152 dataok = false; 153 reportFatalError("InvalidCharInPublicID", 154 new Object []{Integer.toHexString(c)}); 155 } 156 } 157 return dataok; 158 } 159 160 164 protected void normalizeWhitespace(XMLString value) { 165 int end = value.offset + value.length; 166 for (int i = value.offset; i < end; ++i) { 167 int c = value.ch[i]; 168 if (XMLChar.isSpace(c)) { 169 value.ch[i] = ' '; 170 } 171 } 172 } 173 174 178 protected void normalizeWhitespace(XMLString value, int fromIndex) { 179 int end = value.offset + value.length; 180 for (int i = value.offset + fromIndex; i < end; ++i) { 181 int c = value.ch[i]; 182 if (XMLChar.isSpace(c)) { 183 value.ch[i] = ' '; 184 } 185 } 186 } 187 188 195 protected int isUnchangedByNormalization(XMLString value) { 196 int end = value.offset + value.length; 197 for (int i = value.offset; i < end; ++i) { 198 int c = value.ch[i]; 199 if (XMLChar.isSpace(c)) { 200 return i - value.offset; 201 } 202 } 203 return -1; 204 } 205 206 protected boolean isInvalid(int value) { 210 return (!XML11Char.isXML11Valid(value)); 211 } 213 protected boolean isInvalidLiteral(int value) { 217 return (!XML11Char.isXML11ValidLiteral(value)); 218 } 220 protected boolean isValidNameChar(int value) { 224 return (XML11Char.isXML11Name(value)); 225 } 227 protected boolean isValidNameStartChar(int value) { 231 return (XML11Char.isXML11NameStart(value)); 232 } 234 protected boolean isValidNCName(int value) { 238 return (XML11Char.isXML11NCName(value)); 239 } 241 protected boolean isValidNameStartHighSurrogate(int value) { 246 return XML11Char.isXML11NameHighSurrogate(value); 247 } 249 protected boolean versionSupported(String version) { 253 return version.equals("1.1") || version.equals ("1.0"); 254 } 256 protected String getVersionNotSupportedKey () { 260 return "VersionNotSupported11"; 261 } 263 } | Popular Tags |