/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2004 The Apache Software Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
*/
/**
* This class is responsible for scanning XML document structure
* and content. The scanner acts as the source for the document
* information which is communicated to the document handler.
* <p>
* This component requires the following features and properties from the
* component manager that uses it:
* <ul>
* <li>http://xml.org/sax/features/namespaces</li>
* <li>http://xml.org/sax/features/validation</li>
* </ul>
*
* @xerces.internal
*
* @author Glenn Marcy, IBM
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
* @author Eric Ye, IBM
*
* @version $Id: XML11DocumentScannerImpl.java,v 1.5 2010/08/04 20:59:09 joehw Exp $
*/
public class XML11DocumentScannerImpl
extends XMLDocumentScannerImpl {
/** String buffer. */
//
// Constructors
//
/** Default constructor. */
//
// overridden methods
//
// XMLDocumentFragmentImpl methods
/**
* Scans element content.
*
* @return Returns the next character on the stream.
*/
if (c == '\r' || c == 0x85 || c == 0x2028) {
// happens when there is the character reference
// but scanContent doesn't do entity expansions...
// is this *really* necessary??? - NG
c = -1;
}
/*if (fDocumentHandler != null && content.length > 0) {
fDocumentHandler.characters(content, null);
} */
if (c == ']') {
// remember where we are in case we get an endEntity before we
// could flush the buffer out - this happens when we're parsing an
// entity which ends with a ]
fInScanContent = true;
//
// We work on a single character basis to handle cases such as:
// ']]]>' which we might otherwise miss.
//
}
}
}
/*if (fDocumentHandler != null && fStringBuffer.length != 0) {
fDocumentHandler.characters(fStringBuffer, null);
}*/
fInScanContent = false;
c = -1;
}
return c;
} // scanContent():int
/**
* Scans an attribute value and normalizes whitespace converting all
* whitespace characters to space characters.
*
* [10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"
*
* @param value The XMLString to fill in with the value.
* @param nonNormalizedValue The XMLString to fill in with the
* non-normalized value.
* @param atName The name of the attribute being parsed (for error msgs).
* @param checkEntities true if undeclared entities should be reported as VC violation,
* false if undeclared entities should be reported as WFC violation.
* @param eleName The name of element to which this attribute belongs.
*
* @return true if the non-normalized and normalized value are the same
*
* <strong>Note:</strong> This method uses fStringBuffer2, anything in it
* at the time of calling is lost.
**/
throws IOException, XNIException
{
// quote
}
int entityDepth = fEntityDepth;
if (DEBUG_ATTR_NORMALIZATION) {
}
int fromIndex = 0;
/** Both the non-normalized and normalized attribute values are equal. **/
}
return true;
}
if (DEBUG_ATTR_NORMALIZATION) {
}
if (c != quote) {
fScanningAttribute = true;
do {
if (DEBUG_ATTR_NORMALIZATION) {
}
if (c == '&') {
if (entityDepth == fEntityDepth) {
}
if (entityDepth == fEntityDepth) {
}
if (ch != -1) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
}
else {
if (entityName == null) {
}
else if (entityDepth == fEntityDepth) {
}
reportFatalError("SemicolonRequiredInReference",
new Object []{entityName});
}
else if (entityDepth == fEntityDepth) {
}
if (entityName == fAmpSymbol) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
else if (entityName == fAposSymbol) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
else if (entityName == fLtSymbol) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
else if (entityName == fGtSymbol) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
else if (entityName == fQuotSymbol) {
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
else {
reportFatalError("ReferenceToExternalEntity",
new Object[] { entityName });
}
else {
//WFC & VC: Entity Declared
if (checkEntities) {
if (fValidation) {
"EntityNotDeclared",
new Object[]{entityName},
}
}
else {
reportFatalError("EntityNotDeclared",
new Object[]{entityName});
}
}
}
}
}
}
else if (c == '<') {
reportFatalError("LessthanInAttValue",
if (entityDepth == fEntityDepth) {
fStringBuffer2.append((char)c);
}
}
else if (c == '%' || c == ']') {
fStringBuffer.append((char)c);
if (entityDepth == fEntityDepth) {
fStringBuffer2.append((char)c);
}
if (DEBUG_ATTR_NORMALIZATION) {
}
}
// note that none of these characters should ever get through
// XML11EntityScanner. Not sure why
// this check was originally necessary. - NG
else if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
if (entityDepth == fEntityDepth) {
}
}
if (scanSurrogates(fStringBuffer3)) {
if (entityDepth == fEntityDepth) {
}
if (DEBUG_ATTR_NORMALIZATION) {
+ "\"");
}
}
}
else if (c != -1 && isInvalidLiteral(c)) {
reportFatalError("InvalidCharInAttValue",
if (entityDepth == fEntityDepth) {
fStringBuffer2.append((char)c);
}
}
if (entityDepth == fEntityDepth) {
}
if (DEBUG_ATTR_NORMALIZATION) {
}
fScanningAttribute = false;
}
// quote
}
} // scanAttributeValue()
//
// XMLScanner methods
//
// NOTE: this is a carbon copy of the code in XML11DTDScannerImpl;
// we need to override these methods in both places.
// this needs to be refactored!!! - NG
/**
* 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.
*
* <strong>Note:</strong> This method uses fStringBuffer, anything in it at
* the time of calling is lost.
*/
throws IOException, XNIException
{
return false;
}
// skip leading whitespace
boolean skipSpace = true;
boolean dataok = true;
while (true) {
int c = fEntityScanner.scanChar();
// REVISIT: none of these except \n and 0x20 should make it past the entity scanner
if (c == ' ' || c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
if (!skipSpace) {
// take the first whitespace as a space and skip the others
skipSpace = true;
}
}
else if (c == quote) {
if (skipSpace) {
// if we finished on a space let's trim it
}
break;
}
fStringBuffer.append((char)c);
skipSpace = false;
}
else if (c == -1) {
return false;
}
else {
dataok = false;
reportFatalError("InvalidCharInPublicID",
}
}
return dataok;
}
/**
* Normalize whitespace in an XMLString converting all whitespace
* characters to space characters.
*/
}
}
}
/**
* Normalize whitespace in an XMLString converting all whitespace
* characters to space characters.
*/
}
}
}
/**
* 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.
*/
}
}
return -1;
}
// returns true if the given character is not
// valid with respect to the version of
// XML understood by this scanner.
} // isInvalid(int): boolean
// returns true if the given character is not
// valid or may not be used outside a character reference
// with respect to the version of XML understood by this scanner.
} // isInvalidLiteral(int): boolean
// returns true if the given character is
// a valid nameChar with respect to the version of
// XML understood by this scanner.
} // isValidNameChar(int): boolean
// returns true if the given character is
// a valid nameStartChar with respect to the version of
// XML understood by this scanner.
} // isValidNameStartChar(int): boolean
// returns true if the given character is
// a valid NCName character with respect to the version of
// XML understood by this scanner.
} // isValidNCName(int): boolean
// returns true if the given character is
// a valid high surrogate for a nameStartChar
// with respect to the version of XML understood
// by this scanner.
} // isValidNameStartHighSurrogate(int): boolean
} // versionSupported(String): boolean
// returns the error message key for unsupported
// versions of XML with respect to the version of
// XML understood by this scanner.
return "VersionNotSupported11";
} // getVersionNotSupportedKey: String
} // class XML11DocumentScannerImpl