FileDocCategorySizeDatePackage
XML11DTDScannerImpl.javaAPI DocJava SE 5 API10627Fri Aug 26 14:55:44 BST 2005com.sun.org.apache.xerces.internal.impl

XML11DTDScannerImpl

public class XML11DTDScannerImpl extends XMLDTDScannerImpl
This class is responsible for scanning the declarations found in the internal and external subsets of a DTD in an XML document. The scanner acts as the sources for the DTD information which is communicated to the DTD handlers.

This component requires the following features and properties from the component manager that uses it:

  • http://xml.org/sax/features/validation
  • http://apache.org/xml/features/scanner/notify-char-refs
  • http://apache.org/xml/properties/internal/symbol-table
  • http://apache.org/xml/properties/internal/error-reporter
  • http://apache.org/xml/properties/internal/entity-manager
author
Arnaud Le Hors, IBM
author
Andy Clark, IBM
author
Glenn Marcy, IBM
author
Eric Ye, IBM
version
$Id: XML11DTDScannerImpl.java,v 1.10 2004/01/26 19:37:35 mrglavas Exp $

Fields Summary
private String[]
fStrings
Array of 3 strings.
private XMLString
fString
String.
private XMLStringBuffer
fStringBuffer
String buffer.
private XMLStringBuffer
fStringBuffer2
String buffer.
private XMLStringBuffer
fStringBuffer3
Constructors Summary
public XML11DTDScannerImpl()
Default constructor.


    //
    // Constructors
    //

       
      super();
public XML11DTDScannerImpl(SymbolTable symbolTable, XMLErrorReporter errorReporter, XMLEntityManager entityManager)
Constructor for he use of non-XMLComponentManagers.

        super(symbolTable, errorReporter, entityManager);
    
Methods Summary
protected java.lang.StringgetVersionNotSupportedKey()

        return "VersionNotSupported11";
    
protected booleanisInvalid(int value)

        return (!XML11Char.isXML11Valid(value)); 
    
protected booleanisInvalidLiteral(int value)

        return (!XML11Char.isXML11ValidLiteral(value)); 
    
protected booleanisValidNCName(int value)

        return (XML11Char.isXML11NCName(value));
    
protected booleanisValidNameChar(int value)

        return (XML11Char.isXML11Name(value)); 
    
protected booleanisValidNameStartChar(int value)

        return (XML11Char.isXML11NameStart(value)); 
    
protected booleanisValidNameStartHighSurrogate(int value)

        return XML11Char.isXML11NameHighSurrogate(value); 
    
protected voidnormalizeWhitespace(com.sun.org.apache.xerces.internal.xni.XMLString value)
Normalize whitespace in an XMLString converting all whitespace characters to space characters.

        int end = value.offset + value.length;
        for (int i = value.offset; i < end; i++) {
            int c = value.ch[i];
            if (XMLChar.isSpace(c)) {
                value.ch[i] = ' ";
            }
        }
    
protected booleanscanPubidLiteral(com.sun.org.apache.xerces.internal.xni.XMLString literal)
Scans public ID literal. [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'" [13] PubidChar::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] The returned string is normalized according to the following rule, from http://www.w3.org/TR/REC-xml#dt-pubid: Before a match is attempted, all strings of white space in the public identifier must be normalized to single space characters (#x20), and leading and trailing white space must be removed.

param
literal The string to fill in with the public ID literal.
return
True on success. Note: This method uses fStringBuffer, anything in it at the time of calling is lost.

        int quote = fEntityScanner.scanChar();
        if (quote != '\'" && quote != '"") {
            reportFatalError("QuoteRequiredInPublicID", null);
            return false;
        }

        fStringBuffer.clear();
        // skip leading whitespace
        boolean skipSpace = true;
        boolean dataok = true;
        while (true) {
            int c = fEntityScanner.scanChar();
            // REVISIT:  it could really only be \n or 0x20; all else is normalized, no?  - neilg
            if (c == ' " || c == '\n" || c == '\r" || c == 0x85 || c == 0x2028) {
                if (!skipSpace) {
                    // take the first whitespace as a space and skip the others
                    fStringBuffer.append(' ");
                    skipSpace = true;
                }
            }
            else if (c == quote) {
                if (skipSpace) {
                    // if we finished on a space let's trim it
                    fStringBuffer.length--;
                }
                literal.setValues(fStringBuffer);
                break;
            }
            else if (XMLChar.isPubid(c)) {
                fStringBuffer.append((char)c);
                skipSpace = false;
            }
            else if (c == -1) {
                reportFatalError("PublicIDUnterminated", null);
                return false;
            }
            else {
                dataok = false;
                reportFatalError("InvalidCharInPublicID",
                                 new Object[]{Integer.toHexString(c)});
            }
        }
        return dataok;
   
protected booleanversionSupported(java.lang.String version)

        return version.equals("1.1") || version.equals ("1.0");