FileDocCategorySizeDatePackage
XML11DTDScannerImpl.javaAPI DocApache Xerces 3.0.19622Fri Sep 14 20:33:56 BST 2007org.apache.xerces.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
xerces.internal
author
Arnaud Le Hors, IBM
author
Andy Clark, IBM
author
Glenn Marcy, IBM
author
Eric Ye, IBM
version
$Id: XML11DTDScannerImpl.java 572055 2007-09-02 17:55:43Z mrglavas $

Fields Summary
private final org.apache.xerces.util.XMLStringBuffer
fStringBuffer
String buffer.
Constructors Summary
public XML11DTDScannerImpl()
Default constructor.

    
    //
    // Constructors
    //

       
      super();
public XML11DTDScannerImpl(org.apache.xerces.util.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 intisUnchangedByNormalization(org.apache.xerces.xni.XMLString value)
Checks whether this string would be unchanged by normalization.

return
-1 if the value would be unchanged by normalization, otherwise the index of the first whitespace character which would be transformed.

        int end = value.offset + value.length;
        for (int i = value.offset; i < end; ++i) {
            int c = value.ch[i];
            if (XMLChar.isSpace(c)) {
                return i - value.offset;
            }
        }
        return -1;
    
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(org.apache.xerces.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 voidnormalizeWhitespace(org.apache.xerces.xni.XMLString value, int fromIndex)
Normalize whitespace in an XMLString converting all whitespace characters to space characters.

        int end = value.offset + value.length;
        for (int i = value.offset + fromIndex; i < end; ++i) {
            int c = value.ch[i];
            if (XMLChar.isSpace(c)) {
                value.ch[i] = ' ";
            }
        }
    
protected booleanscanPubidLiteral(org.apache.xerces.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");