rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
hash = 31 * hash + ch [i];
|
{ hash = 31 * hash + ch[i]; }
|
public String intern (char ch[], int start, int length) { int index = 0; int hash = 0; Object bucket []; // Generate a hash code. This is a widely used string hash, // often attributed to Brian Kernighan. for (int i = start; i < start + length; i++) hash = 31 * hash + ch [i]; hash = (hash & 0x7fffffff) % SYMBOL_TABLE_LENGTH; // Get the bucket -- consists of {array,String} pairs if ((bucket = symbolTable [hash]) == null) { // first string in this bucket bucket = new Object [8]; // Search for a matching tuple, and // return the string if we find one. } else { while (index < bucket.length) { char chFound [] = (char []) bucket [index]; // Stop when we hit an empty entry. if (chFound == null) break; // If they're the same length, check for a match. if (chFound.length == length) { for (int i = 0; i < chFound.length; i++) { // continue search on failure if (ch [start + i] != chFound [i]) { break; } else if (i == length - 1) { // That's it, we have a match! return (String) bucket [index + 1]; } } } index += 2; } // Not found -- we'll have to add it. // Do we have to grow the bucket? bucket = (Object []) extendArray (bucket, bucket.length, index); } symbolTable [hash] = bucket; // OK, add it to the end of the bucket -- "local" interning. // Intern "globally" to let applications share interning benefits. // That is, "!=" and "==" work on our strings, not just equals(). String s = new String (ch, start, length).intern (); bucket [index] = s.toCharArray (); bucket [index + 1] = s; return s; }
|
} else { while (index < bucket.length) { char chFound [] = (char []) bucket [index];
|
} else { while (index < bucket.length) { char[] chFound = (char[]) bucket[index];
|
public String intern (char ch[], int start, int length) { int index = 0; int hash = 0; Object bucket []; // Generate a hash code. This is a widely used string hash, // often attributed to Brian Kernighan. for (int i = start; i < start + length; i++) hash = 31 * hash + ch [i]; hash = (hash & 0x7fffffff) % SYMBOL_TABLE_LENGTH; // Get the bucket -- consists of {array,String} pairs if ((bucket = symbolTable [hash]) == null) { // first string in this bucket bucket = new Object [8]; // Search for a matching tuple, and // return the string if we find one. } else { while (index < bucket.length) { char chFound [] = (char []) bucket [index]; // Stop when we hit an empty entry. if (chFound == null) break; // If they're the same length, check for a match. if (chFound.length == length) { for (int i = 0; i < chFound.length; i++) { // continue search on failure if (ch [start + i] != chFound [i]) { break; } else if (i == length - 1) { // That's it, we have a match! return (String) bucket [index + 1]; } } } index += 2; } // Not found -- we'll have to add it. // Do we have to grow the bucket? bucket = (Object []) extendArray (bucket, bucket.length, index); } symbolTable [hash] = bucket; // OK, add it to the end of the bucket -- "local" interning. // Intern "globally" to let applications share interning benefits. // That is, "!=" and "==" work on our strings, not just equals(). String s = new String (ch, start, length).intern (); bucket [index] = s.toCharArray (); bucket [index + 1] = s; return s; }
|
}
|
private final boolean isWhitespace (char c) { if (c > 0x20) return false; if (c == 0x20 || c == 0x0a || c == 0x09 || c == 0x0d) return true; return false; // illegal ... }
|
|
if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) {
|
if (handler.stringInterning) {
|
private void parseAttDef (String elementName) throws Exception { String name; String type; String enumer = null; // Read the attribute name. name = readNmtoken (true); // Read the attribute type. requireWhitespace (); type = readAttType (); // Get the string of enumerated values if necessary. if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type || "NOTATION" == type) enumer = dataBufferToString (); } else { if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = dataBufferToString (); } // Read the default value. requireWhitespace (); parseDefault (elementName, name, type, enumer); }
|
enumer = dataBufferToString (); } else {
|
{ enumer = dataBufferToString(); } } else {
|
private void parseAttDef (String elementName) throws Exception { String name; String type; String enumer = null; // Read the attribute name. name = readNmtoken (true); // Read the attribute type. requireWhitespace (); type = readAttType (); // Get the string of enumerated values if necessary. if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type || "NOTATION" == type) enumer = dataBufferToString (); } else { if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = dataBufferToString (); } // Read the default value. requireWhitespace (); parseDefault (elementName, name, type, enumer); }
|
enumer = dataBufferToString ();
|
{ enumer = dataBufferToString(); }
|
private void parseAttDef (String elementName) throws Exception { String name; String type; String enumer = null; // Read the attribute name. name = readNmtoken (true); // Read the attribute type. requireWhitespace (); type = readAttType (); // Get the string of enumerated values if necessary. if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type || "NOTATION" == type) enumer = dataBufferToString (); } else { if ("ENUMERATION".equals(type) || "NOTATION".equals(type)) enumer = dataBufferToString (); } // Read the default value. requireWhitespace (); parseDefault (elementName, name, type, enumer); }
|
error ("whitespace required before attribute definition"); parseAttDef (elementName); white = tryWhitespace ();
|
{ error("whitespace required before attribute definition"); } parseAttDef(elementName); white = tryWhitespace();
|
private void parseAttlistDecl () throws Exception { String elementName; requireWhitespace (); elementName = readNmtoken (true); boolean white = tryWhitespace (); while (!tryRead ('>')) { if (!white) error ("whitespace required before attribute definition"); parseAttDef (elementName); white = tryWhitespace (); } }
|
if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if (type == "CDATA" || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE); } } else { if (type.equals("CDATA") || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE);
|
if (handler.stringInterning) { if (type == "CDATA" || type == null) { value = readLiteral(flags); } else { value = readLiteral(flags | LIT_NORMALIZE); } } else { if (type.equals("CDATA") || type == null) { value = readLiteral(flags); } else { value = readLiteral(flags | LIT_NORMALIZE);
|
private void parseAttribute (String name) throws Exception { String aname; String type; String value; int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; // Read the attribute name. aname = readNmtoken (true); type = getAttributeType (name, aname); // Parse '=' parseEq (); // Read the value, normalizing whitespace // unless it is CDATA. if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if (type == "CDATA" || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE); } } else { if (type.equals("CDATA") || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE); } } // WFC: no duplicate attributes for (int i = 0; i < tagAttributePos; i++) if (aname.equals (tagAttributes [i])) error ("duplicate attribute", aname, null); // Inform the handler about the // attribute. handler.attribute (aname, value, true); dataBufferPos = 0; // Note that the attribute has been // specified. if (tagAttributePos == tagAttributes.length) { String newAttrib[] = new String [tagAttributes.length * 2]; System.arraycopy (tagAttributes, 0, newAttrib, 0, tagAttributePos); tagAttributes = newAttrib; } tagAttributes [tagAttributePos++] = aname; }
|
if (aname.equals (tagAttributes [i])) error ("duplicate attribute", aname, null);
|
{ if (aname.equals(tagAttributes [i])) { error("duplicate attribute", aname, null); } }
|
private void parseAttribute (String name) throws Exception { String aname; String type; String value; int flags = LIT_ATTRIBUTE | LIT_ENTITY_REF; // Read the attribute name. aname = readNmtoken (true); type = getAttributeType (name, aname); // Parse '=' parseEq (); // Read the value, normalizing whitespace // unless it is CDATA. if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if (type == "CDATA" || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE); } } else { if (type.equals("CDATA") || type == null) { value = readLiteral (flags); } else { value = readLiteral (flags | LIT_NORMALIZE); } } // WFC: no duplicate attributes for (int i = 0; i < tagAttributePos; i++) if (aname.equals (tagAttributes [i])) error ("duplicate attribute", aname, null); // Inform the handler about the // attribute. handler.attribute (aname, value, true); dataBufferPos = 0; // Note that the attribute has been // specified. if (tagAttributePos == tagAttributes.length) { String newAttrib[] = new String [tagAttributes.length * 2]; System.arraycopy (tagAttributes, 0, newAttrib, 0, tagAttributePos); tagAttributes = newAttrib; } tagAttributes [tagAttributePos++] = aname; }
|
error ("illegal XML character U+" + Integer.toHexString (c));
|
{ error("illegal XML character U+" + Integer.toHexString(c)); }
|
private void parseCharData () throws Exception { char c; int state = 0; boolean pureWhite = false; // assert (dataBufferPos == 0); // are we expecting pure whitespace? it might be dirty... if ((currentElementContent == CONTENT_ELEMENTS) && !isDirtyCurrentElement) pureWhite = true; // always report right out of readBuffer // to minimize (pointless) buffer copies while (true) { int lineAugment = 0; int columnAugment = 0; int i;loop: for (i = readBufferPos; i < readBufferLength; i++) { switch (c = readBuffer [i]) { case '\n': lineAugment++; columnAugment = 0; // pureWhite unmodified break; case '\r': // should not happen!! case '\t': case ' ': // pureWhite unmodified columnAugment++; break; case '&': case '<': columnAugment++; // pureWhite unmodified // CLEAN end of text sequence state = 1; break loop; case ']': // that's not a whitespace char, and // can not terminate pure whitespace either pureWhite = false; if ((i + 2) < readBufferLength) { if (readBuffer [i + 1] == ']' && readBuffer [i + 2] == '>') { // ERROR end of text sequence state = 2; break loop; } } else { // FIXME missing two end-of-buffer cases } columnAugment++; break; default: if ((c < 0x0020 || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // that's not a whitespace char pureWhite = false; columnAugment++; } } // report text thus far if (lineAugment > 0) { line += lineAugment; column = columnAugment; } else { column += columnAugment; } // report characters/whitspace int length = i - readBufferPos; if (length != 0) { if (pureWhite) handler.ignorableWhitespace (readBuffer, readBufferPos, length); else handler.charData (readBuffer, readBufferPos, length); readBufferPos = i; } if (state != 0) break; // fill next buffer from this entity, or // pop stack and continue with previous entity unread (readCh ()); } if (!pureWhite) isDirtyCurrentElement = true; // finish, maybe with error if (state != 1) // finish, no error error ("character data may not contain ']]>'"); }
|
handler.ignorableWhitespace (readBuffer,
|
{ handler.ignorableWhitespace(readBuffer,
|
private void parseCharData () throws Exception { char c; int state = 0; boolean pureWhite = false; // assert (dataBufferPos == 0); // are we expecting pure whitespace? it might be dirty... if ((currentElementContent == CONTENT_ELEMENTS) && !isDirtyCurrentElement) pureWhite = true; // always report right out of readBuffer // to minimize (pointless) buffer copies while (true) { int lineAugment = 0; int columnAugment = 0; int i;loop: for (i = readBufferPos; i < readBufferLength; i++) { switch (c = readBuffer [i]) { case '\n': lineAugment++; columnAugment = 0; // pureWhite unmodified break; case '\r': // should not happen!! case '\t': case ' ': // pureWhite unmodified columnAugment++; break; case '&': case '<': columnAugment++; // pureWhite unmodified // CLEAN end of text sequence state = 1; break loop; case ']': // that's not a whitespace char, and // can not terminate pure whitespace either pureWhite = false; if ((i + 2) < readBufferLength) { if (readBuffer [i + 1] == ']' && readBuffer [i + 2] == '>') { // ERROR end of text sequence state = 2; break loop; } } else { // FIXME missing two end-of-buffer cases } columnAugment++; break; default: if ((c < 0x0020 || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // that's not a whitespace char pureWhite = false; columnAugment++; } } // report text thus far if (lineAugment > 0) { line += lineAugment; column = columnAugment; } else { column += columnAugment; } // report characters/whitspace int length = i - readBufferPos; if (length != 0) { if (pureWhite) handler.ignorableWhitespace (readBuffer, readBufferPos, length); else handler.charData (readBuffer, readBufferPos, length); readBufferPos = i; } if (state != 0) break; // fill next buffer from this entity, or // pop stack and continue with previous entity unread (readCh ()); } if (!pureWhite) isDirtyCurrentElement = true; // finish, maybe with error if (state != 1) // finish, no error error ("character data may not contain ']]>'"); }
|
handler.charData (readBuffer, readBufferPos, length);
|
{ handler.charData(readBuffer, readBufferPos, length); }
|
private void parseCharData () throws Exception { char c; int state = 0; boolean pureWhite = false; // assert (dataBufferPos == 0); // are we expecting pure whitespace? it might be dirty... if ((currentElementContent == CONTENT_ELEMENTS) && !isDirtyCurrentElement) pureWhite = true; // always report right out of readBuffer // to minimize (pointless) buffer copies while (true) { int lineAugment = 0; int columnAugment = 0; int i;loop: for (i = readBufferPos; i < readBufferLength; i++) { switch (c = readBuffer [i]) { case '\n': lineAugment++; columnAugment = 0; // pureWhite unmodified break; case '\r': // should not happen!! case '\t': case ' ': // pureWhite unmodified columnAugment++; break; case '&': case '<': columnAugment++; // pureWhite unmodified // CLEAN end of text sequence state = 1; break loop; case ']': // that's not a whitespace char, and // can not terminate pure whitespace either pureWhite = false; if ((i + 2) < readBufferLength) { if (readBuffer [i + 1] == ']' && readBuffer [i + 2] == '>') { // ERROR end of text sequence state = 2; break loop; } } else { // FIXME missing two end-of-buffer cases } columnAugment++; break; default: if ((c < 0x0020 || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // that's not a whitespace char pureWhite = false; columnAugment++; } } // report text thus far if (lineAugment > 0) { line += lineAugment; column = columnAugment; } else { column += columnAugment; } // report characters/whitspace int length = i - readBufferPos; if (length != 0) { if (pureWhite) handler.ignorableWhitespace (readBuffer, readBufferPos, length); else handler.charData (readBuffer, readBufferPos, length); readBufferPos = i; } if (state != 0) break; // fill next buffer from this entity, or // pop stack and continue with previous entity unread (readCh ()); } if (!pureWhite) isDirtyCurrentElement = true; // finish, maybe with error if (state != 1) // finish, no error error ("character data may not contain ']]>'"); }
|
error ("character data may not contain ']]>'");
|
{ error("character data may not contain ']]>'"); }
|
private void parseCharData () throws Exception { char c; int state = 0; boolean pureWhite = false; // assert (dataBufferPos == 0); // are we expecting pure whitespace? it might be dirty... if ((currentElementContent == CONTENT_ELEMENTS) && !isDirtyCurrentElement) pureWhite = true; // always report right out of readBuffer // to minimize (pointless) buffer copies while (true) { int lineAugment = 0; int columnAugment = 0; int i;loop: for (i = readBufferPos; i < readBufferLength; i++) { switch (c = readBuffer [i]) { case '\n': lineAugment++; columnAugment = 0; // pureWhite unmodified break; case '\r': // should not happen!! case '\t': case ' ': // pureWhite unmodified columnAugment++; break; case '&': case '<': columnAugment++; // pureWhite unmodified // CLEAN end of text sequence state = 1; break loop; case ']': // that's not a whitespace char, and // can not terminate pure whitespace either pureWhite = false; if ((i + 2) < readBufferLength) { if (readBuffer [i + 1] == ']' && readBuffer [i + 2] == '>') { // ERROR end of text sequence state = 2; break loop; } } else { // FIXME missing two end-of-buffer cases } columnAugment++; break; default: if ((c < 0x0020 || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // that's not a whitespace char pureWhite = false; columnAugment++; } } // report text thus far if (lineAugment > 0) { line += lineAugment; column = columnAugment; } else { column += columnAugment; } // report characters/whitspace int length = i - readBufferPos; if (length != 0) { if (pureWhite) handler.ignorableWhitespace (readBuffer, readBufferPos, length); else handler.charData (readBuffer, readBufferPos, length); readBufferPos = i; } if (state != 0) break; // fill next buffer from this entity, or // pop stack and continue with previous entity unread (readCh ()); } if (!pureWhite) isDirtyCurrentElement = true; // finish, maybe with error if (state != 1) // finish, no error error ("character data may not contain ']]>'"); }
|
private void parseConditionalSect (char saved [])
|
private void parseConditionalSect(char[] saved)
|
private void parseConditionalSect (char saved []) throws Exception { skipWhitespace (); if (tryRead ("INCLUDE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); skipWhitespace (); while (!tryRead ("]]>")) { parseMarkupdecl (); skipWhitespace (); } } else if (tryRead ("IGNORE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); int nesting = 1; char c; expandPE = false; for (int nest = 1; nest > 0;) { c = readCh (); switch (c) { case '<': if (tryRead ("![")) { nest++; } case ']': if (tryRead ("]>")) { nest--; } } } expandPE = true; } else { error ("conditional section must begin with INCLUDE or IGNORE"); } }
|
handler.verror ("Illegal Conditional Section/PE nesting"); skipWhitespace (); while (!tryRead ("]]>")) { parseMarkupdecl (); skipWhitespace (); } } else if (tryRead ("IGNORE")) { skipWhitespace (); require ('[');
|
{ handler.verror("Illegal Conditional Section/PE nesting"); } skipWhitespace(); while (!tryRead("]]>")) { parseMarkupdecl(); skipWhitespace(); } } else if (tryRead("IGNORE")) { skipWhitespace(); require('[');
|
private void parseConditionalSect (char saved []) throws Exception { skipWhitespace (); if (tryRead ("INCLUDE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); skipWhitespace (); while (!tryRead ("]]>")) { parseMarkupdecl (); skipWhitespace (); } } else if (tryRead ("IGNORE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); int nesting = 1; char c; expandPE = false; for (int nest = 1; nest > 0;) { c = readCh (); switch (c) { case '<': if (tryRead ("![")) { nest++; } case ']': if (tryRead ("]>")) { nest--; } } } expandPE = true; } else { error ("conditional section must begin with INCLUDE or IGNORE"); } }
|
handler.verror ("Illegal Conditional Section/PE nesting");
|
{ handler.verror("Illegal Conditional Section/PE nesting"); }
|
private void parseConditionalSect (char saved []) throws Exception { skipWhitespace (); if (tryRead ("INCLUDE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); skipWhitespace (); while (!tryRead ("]]>")) { parseMarkupdecl (); skipWhitespace (); } } else if (tryRead ("IGNORE")) { skipWhitespace (); require ('['); // VC: Proper Conditional Section/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Conditional Section/PE nesting"); int nesting = 1; char c; expandPE = false; for (int nest = 1; nest > 0;) { c = readCh (); switch (c) { case '<': if (tryRead ("![")) { nest++; } case ']': if (tryRead ("]>")) { nest--; } } } expandPE = true; } else { error ("conditional section must begin with INCLUDE or IGNORE"); } }
|
handler.getDeclHandler ().elementDecl (name, "EMPTY");
|
{ handler.getDeclHandler().elementDecl(name, "EMPTY"); }
|
private void parseContentspec (String name) throws Exception {// FIXME: move elementDecl() into setElement(), pass EMTPY/ANY ... if (tryRead ("EMPTY")) { setElement (name, CONTENT_EMPTY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "EMPTY"); return; } else if (tryRead ("ANY")) { setElement (name, CONTENT_ANY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "ANY"); return; } else { String model; char saved []; require ('('); saved = readBuffer; dataBufferAppend ('('); skipWhitespace (); if (tryRead ("#PCDATA")) { dataBufferAppend ("#PCDATA"); parseMixed (saved); model = dataBufferToString (); setElement (name, CONTENT_MIXED, model, null); } else { parseElements (saved); model = dataBufferToString (); setElement (name, CONTENT_ELEMENTS, model, null); } if (!skippedPE) handler.getDeclHandler ().elementDecl (name, model); } }
|
handler.getDeclHandler ().elementDecl (name, "ANY");
|
{ handler.getDeclHandler().elementDecl(name, "ANY"); }
|
private void parseContentspec (String name) throws Exception {// FIXME: move elementDecl() into setElement(), pass EMTPY/ANY ... if (tryRead ("EMPTY")) { setElement (name, CONTENT_EMPTY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "EMPTY"); return; } else if (tryRead ("ANY")) { setElement (name, CONTENT_ANY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "ANY"); return; } else { String model; char saved []; require ('('); saved = readBuffer; dataBufferAppend ('('); skipWhitespace (); if (tryRead ("#PCDATA")) { dataBufferAppend ("#PCDATA"); parseMixed (saved); model = dataBufferToString (); setElement (name, CONTENT_MIXED, model, null); } else { parseElements (saved); model = dataBufferToString (); setElement (name, CONTENT_ELEMENTS, model, null); } if (!skippedPE) handler.getDeclHandler ().elementDecl (name, model); } }
|
char saved [];
|
char[] saved;
|
private void parseContentspec (String name) throws Exception {// FIXME: move elementDecl() into setElement(), pass EMTPY/ANY ... if (tryRead ("EMPTY")) { setElement (name, CONTENT_EMPTY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "EMPTY"); return; } else if (tryRead ("ANY")) { setElement (name, CONTENT_ANY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "ANY"); return; } else { String model; char saved []; require ('('); saved = readBuffer; dataBufferAppend ('('); skipWhitespace (); if (tryRead ("#PCDATA")) { dataBufferAppend ("#PCDATA"); parseMixed (saved); model = dataBufferToString (); setElement (name, CONTENT_MIXED, model, null); } else { parseElements (saved); model = dataBufferToString (); setElement (name, CONTENT_ELEMENTS, model, null); } if (!skippedPE) handler.getDeclHandler ().elementDecl (name, model); } }
|
handler.getDeclHandler ().elementDecl (name, model);
|
{ handler.getDeclHandler().elementDecl(name, model); }
|
private void parseContentspec (String name) throws Exception {// FIXME: move elementDecl() into setElement(), pass EMTPY/ANY ... if (tryRead ("EMPTY")) { setElement (name, CONTENT_EMPTY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "EMPTY"); return; } else if (tryRead ("ANY")) { setElement (name, CONTENT_ANY, null, null); if (!skippedPE) handler.getDeclHandler ().elementDecl (name, "ANY"); return; } else { String model; char saved []; require ('('); saved = readBuffer; dataBufferAppend ('('); skipWhitespace (); if (tryRead ("#PCDATA")) { dataBufferAppend ("#PCDATA"); parseMixed (saved); model = dataBufferToString (); setElement (name, CONTENT_MIXED, model, null); } else { parseElements (saved); model = dataBufferToString (); setElement (name, CONTENT_ELEMENTS, model, null); } if (!skippedPE) handler.getDeclHandler ().elementDecl (name, model); } }
|
if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) {
|
if (handler.stringInterning) {
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
} else {
|
} } else {
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
} else { error ("illegal keyword for attribute default value");
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
|
} else value = readLiteral (flags);
|
else { error("illegal keyword for attribute default value"); } } else { value = readLiteral(flags); }
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) {
|
setAttribute(elementName, name, type, enumer, value, valueType); if (handler.stringInterning) {
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value);
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
|
if (!skippedPE) { handler.getDeclHandler().attributeDecl(elementName, name, type, defaultType, value); } }
|
private void parseDefault ( String elementName, String name, String type, String enumer ) throws Exception { int valueType = ATTRIBUTE_DEFAULT_SPECIFIED; String value = null; int flags = LIT_ATTRIBUTE; boolean saved = expandPE; String defaultType = null; // LIT_ATTRIBUTE forces '<' checks now (ASAP) and turns whitespace // chars to spaces (doesn't matter when that's done if it doesn't // interfere with char refs expanding to whitespace). if (!skippedPE) { flags |= LIT_ENTITY_REF; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("CDATA" != type) flags |= LIT_NORMALIZE; } else { if (!"CDATA".equals(type)) flags |= LIT_NORMALIZE; } } expandPE = false; if (tryRead ('#')) { if (tryRead ("FIXED")) { defaultType = "#FIXED"; valueType = ATTRIBUTE_DEFAULT_FIXED; requireWhitespace (); value = readLiteral (flags); } else if (tryRead ("REQUIRED")) { defaultType = "#REQUIRED"; valueType = ATTRIBUTE_DEFAULT_REQUIRED; } else if (tryRead ("IMPLIED")) { defaultType = "#IMPLIED"; valueType = ATTRIBUTE_DEFAULT_IMPLIED; } else { error ("illegal keyword for attribute default value"); } } else value = readLiteral (flags); expandPE = saved; setAttribute (elementName, name, type, enumer, value, valueType); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("ENUMERATION" == type) type = enumer; else if ("NOTATION" == type) type = "NOTATION " + enumer; } else { if ("ENUMERATION".equals(type)) type = enumer; else if ("NOTATION".equals(type)) type = "NOTATION " + enumer; } if (!skippedPE) handler.getDeclHandler () .attributeDecl (elementName, name, type, defaultType, value); }
|
|
String rootName, ids[];
|
String rootName; ExternalIdentifiers ids;
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
handler.doctypeDecl (rootName, ids [0], ids [1]);
|
handler.doctypeDecl(rootName, ids.publicId, ids.systemId);
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ());
|
if (ids.systemId == null) { subset = handler.getExternalSubset(rootName, handler.getSystemId()); }
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
if (ids [1] != null || subset != null) { pushString (null, ">");
|
} if (ids.systemId != null || subset != null) { pushString(null, ">");
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (),
|
if (ids.systemId != null) { pushURL(true, "[dtd]", ids, null, null, null, true); } else { handler.warn("modifying document by adding external subset"); pushURL(true, "[dtd]", new ExternalIdentifiers(subset.getPublicId(), subset.getSystemId(), null), subset.getCharacterStream(), subset.getByteStream(), subset.getEncoding(),
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
if (inputStack.size () != 1) error ("external subset has unmatched '>'");
|
if (inputStack.size() != 1) { error("external subset has unmatched '>'"); }
|
private void parseDoctypedecl () throws Exception { String rootName, ids[]; // Read the document type name. requireWhitespace (); rootName = readNmtoken (true); // Read the External subset's IDs skipWhitespace (); ids = readExternalIds (false, true); // report (a) declaration of name, (b) lexical info (ids) handler.doctypeDecl (rootName, ids [0], ids [1]); // Internal subset is parsed first, if present skipWhitespace (); if (tryRead ('[')) { // loop until the subset ends while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead (']')) { break; // end of subset } else { // WFC, PEs in internal subset (only between decls) peIsError = expandPE = true; parseMarkupdecl (); peIsError = expandPE = false; } } } skipWhitespace (); require ('>'); // Read the external subset, if any InputSource subset; if (ids [1] == null) subset = handler.getExternalSubset (rootName, handler.getSystemId ()); else subset = null; if (ids [1] != null || subset != null) { pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) if (ids [1] != null) pushURL (true, "[dtd]", ids, null, null, null, true); else { handler.warn ("modifying document by adding external subset"); pushURL (true, "[dtd]", new String [] { subset.getPublicId (), subset.getSystemId (), null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); } // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); } // done dtd handler.endDoctype (); expandPE = false; doReport = true; }
|
Object element [];
|
ElementDecl element;
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (),
|
pushURL(true, "[dtd]", new ExternalIdentifiers(publicId, systemId, null), subset.getCharacterStream(), subset.getByteStream(), subset.getEncoding(),
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
if (inputStack.size () != 1) error ("external subset has unmatched '>'");
|
if (inputStack.size() != 1) { error("external subset has unmatched '>'"); }
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY);
|
element = (ElementDecl) elementInfo.get(gi); currentElementContent = getContentType(element, CONTENT_ANY);
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh ();
|
{ error("need whitespace between attributes"); } parseAttribute(gi); white = tryWhitespace(); c = readCh();
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
Enumeration atts = declaredAttributes (element); if (atts != null) {
|
Iterator atts = declaredAttributes(element); if (atts != null) {
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
while (atts.hasMoreElements ()) { aname = (String) atts.nextElement ();
|
while (atts.hasNext()) { aname = (String) atts.next();
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
handler.attribute (aname, value, false);
|
} handler.attribute(aname, value, false);
|
private void parseElement (boolean maybeGetSubset) throws Exception { String gi; char c; int oldElementContent = currentElementContent; String oldElement = currentElement; Object element []; // This is the (global) counter for the // array of specified attributes. tagAttributePos = 0; // Read the element type name. gi = readNmtoken (true); // If we saw no DTD, and this is the document root element, // let the application modify the input stream by providing one. if (maybeGetSubset) { InputSource subset = handler.getExternalSubset (gi, handler.getSystemId ()); if (subset != null) { String publicId = subset.getPublicId (); String systemId = subset.getSystemId (); handler.warn ("modifying document by adding DTD"); handler.doctypeDecl (gi, publicId, systemId); pushString (null, ">"); // NOTE: [dtd] is so we say what SAX2 expects, // though it's misleading (subset, not entire dtd) pushURL (true, "[dtd]", new String [] { publicId, systemId, null }, subset.getCharacterStream (), subset.getByteStream (), subset.getEncoding (), false); // Loop until we end up back at '>' while (true) { doReport = expandPE = true; skipWhitespace (); doReport = expandPE = false; if (tryRead ('>')) { break; } else { expandPE = true; parseMarkupdecl (); expandPE = false; } } // the ">" string isn't popped yet if (inputStack.size () != 1) error ("external subset has unmatched '>'"); handler.endDoctype (); } } // Determine the current content type. currentElement = gi; element = (Object []) elementInfo.get (gi); currentElementContent = getContentType (element, CONTENT_ANY); // Read the attributes, if any. // After this loop, "c" is the closing delimiter. boolean white = tryWhitespace (); c = readCh (); while (c != '/' && c != '>') { unread (c); if (!white) error ("need whitespace between attributes"); parseAttribute (gi); white = tryWhitespace (); c = readCh (); } // Supply any defaulted attributes. Enumeration atts = declaredAttributes (element); if (atts != null) { String aname;loop: while (atts.hasMoreElements ()) { aname = (String) atts.nextElement (); // See if it was specified. for (int i = 0; i < tagAttributePos; i++) { if (tagAttributes [i] == aname) { continue loop; } } // ... or has a default String value = getAttributeDefaultValue (gi, aname); if (value == null) continue; handler.attribute (aname, value, false); } } // Figure out if this is a start tag // or an empty element, and dispatch an // event accordingly. switch (c) { case '>': handler.startElement (gi); parseContent (); break; case '/': require ('>'); handler.startElement (gi); handler.endElement (gi); break; } // Restore the previous state. currentElement = oldElement; currentElementContent = oldElementContent; }
|
private void parseElements (char saved [])
|
private void parseElements(char[] saved)
|
private void parseElements (char saved []) throws Exception { char c; char sep; // Parse the first content particle skipWhitespace (); parseCp (); // Check for end or for a separator. skipWhitespace (); c = readCh (); switch (c) { case ')': // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (')'); c = readCh (); switch (c) { case '*': case '+': case '?': dataBufferAppend (c); break; default: unread (c); } return; case ',': // Register the separator. case '|': sep = c; dataBufferAppend (c); break; default: error ("bad separator in content model", c, null); return; } // Parse the rest of the content model. while (true) { skipWhitespace (); parseCp (); skipWhitespace (); c = readCh (); if (c == ')') { // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (')'); break; } else if (c != sep) { error ("bad separator in content model", c, null); return; } else { dataBufferAppend (c); } } // Check for the occurrence indicator. c = readCh (); switch (c) { case '?': case '*': case '+': dataBufferAppend (c); return; default: unread (c); return; } }
|
handler.verror ("Illegal Group/PE nesting");
|
{ handler.verror("Illegal Group/PE nesting"); }
|
private void parseElements (char saved []) throws Exception { char c; char sep; // Parse the first content particle skipWhitespace (); parseCp (); // Check for end or for a separator. skipWhitespace (); c = readCh (); switch (c) { case ')': // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (')'); c = readCh (); switch (c) { case '*': case '+': case '?': dataBufferAppend (c); break; default: unread (c); } return; case ',': // Register the separator. case '|': sep = c; dataBufferAppend (c); break; default: error ("bad separator in content model", c, null); return; } // Parse the rest of the content model. while (true) { skipWhitespace (); parseCp (); skipWhitespace (); c = readCh (); if (c == ')') { // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (')'); break; } else if (c != sep) { error ("bad separator in content model", c, null); return; } else { dataBufferAppend (c); } } // Check for the occurrence indicator. c = readCh (); switch (c) { case '?': case '*': case '+': dataBufferAppend (c); return; default: unread (c); return; } }
|
error ("Illegal character(':') in entity name ", name, null); if (peFlag) {
|
{ error("Illegal character(':') in entity name ", name, null); } if (peFlag) {
|
private void parseEntityDecl () throws Exception { boolean peFlag = false; int flags = 0; // Check for a parameter entity. expandPE = false; requireWhitespace (); if (tryRead ('%')) { peFlag = true; requireWhitespace (); } expandPE = true; // Read the entity name, and prepend // '%' if necessary. String name = readNmtoken (true); //NE08 if (name.indexOf(':') >= 0) error ("Illegal character(':') in entity name ", name, null); if (peFlag) { name = "%" + name; } // Read the entity value. requireWhitespace (); char c = readCh (); unread (c); if (c == '"' || c == '\'') { // Internal entity ... replacement text has expanded refs // to characters and PEs, but not to general entities String value = readLiteral (flags); setInternalEntity (name, value); } else { // Read the external IDs String ids [] = readExternalIds (false, false); // Check for NDATA declaration. boolean white = tryWhitespace (); if (!peFlag && tryRead ("NDATA")) { if (!white) error ("whitespace required before NDATA"); requireWhitespace (); String notationName = readNmtoken (true); if (!skippedPE) { setExternalEntity (name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl (name, ids, notationName); } } else if (!skippedPE) { setExternalEntity (name, ENTITY_TEXT, ids, null); handler.getDeclHandler () .externalEntityDecl (name, ids [0], handler.resolveURIs () // FIXME: ASSUMES not skipped // "false" forces error on bad URI ? handler.absolutize (ids [2], ids [1], false) : ids [1]); } } // Finish the declaration. skipWhitespace (); require ('>'); }
|
String ids [] = readExternalIds (false, false);
|
ExternalIdentifiers ids = readExternalIds(false, false);
|
private void parseEntityDecl () throws Exception { boolean peFlag = false; int flags = 0; // Check for a parameter entity. expandPE = false; requireWhitespace (); if (tryRead ('%')) { peFlag = true; requireWhitespace (); } expandPE = true; // Read the entity name, and prepend // '%' if necessary. String name = readNmtoken (true); //NE08 if (name.indexOf(':') >= 0) error ("Illegal character(':') in entity name ", name, null); if (peFlag) { name = "%" + name; } // Read the entity value. requireWhitespace (); char c = readCh (); unread (c); if (c == '"' || c == '\'') { // Internal entity ... replacement text has expanded refs // to characters and PEs, but not to general entities String value = readLiteral (flags); setInternalEntity (name, value); } else { // Read the external IDs String ids [] = readExternalIds (false, false); // Check for NDATA declaration. boolean white = tryWhitespace (); if (!peFlag && tryRead ("NDATA")) { if (!white) error ("whitespace required before NDATA"); requireWhitespace (); String notationName = readNmtoken (true); if (!skippedPE) { setExternalEntity (name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl (name, ids, notationName); } } else if (!skippedPE) { setExternalEntity (name, ENTITY_TEXT, ids, null); handler.getDeclHandler () .externalEntityDecl (name, ids [0], handler.resolveURIs () // FIXME: ASSUMES not skipped // "false" forces error on bad URI ? handler.absolutize (ids [2], ids [1], false) : ids [1]); } } // Finish the declaration. skipWhitespace (); require ('>'); }
|
error ("whitespace required before NDATA"); requireWhitespace (); String notationName = readNmtoken (true); if (!skippedPE) { setExternalEntity (name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl (name, ids, notationName); } } else if (!skippedPE) { setExternalEntity (name, ENTITY_TEXT, ids, null); handler.getDeclHandler () .externalEntityDecl (name, ids [0], handler.resolveURIs ()
|
{ error("whitespace required before NDATA"); } requireWhitespace(); String notationName = readNmtoken(true); if (!skippedPE) { setExternalEntity(name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl(name, ids.publicId, ids.systemId, ids.baseUri, notationName); } } else if (!skippedPE) { setExternalEntity(name, ENTITY_TEXT, ids, null); handler.getDeclHandler() .externalEntityDecl(name, ids.publicId, handler.resolveURIs()
|
private void parseEntityDecl () throws Exception { boolean peFlag = false; int flags = 0; // Check for a parameter entity. expandPE = false; requireWhitespace (); if (tryRead ('%')) { peFlag = true; requireWhitespace (); } expandPE = true; // Read the entity name, and prepend // '%' if necessary. String name = readNmtoken (true); //NE08 if (name.indexOf(':') >= 0) error ("Illegal character(':') in entity name ", name, null); if (peFlag) { name = "%" + name; } // Read the entity value. requireWhitespace (); char c = readCh (); unread (c); if (c == '"' || c == '\'') { // Internal entity ... replacement text has expanded refs // to characters and PEs, but not to general entities String value = readLiteral (flags); setInternalEntity (name, value); } else { // Read the external IDs String ids [] = readExternalIds (false, false); // Check for NDATA declaration. boolean white = tryWhitespace (); if (!peFlag && tryRead ("NDATA")) { if (!white) error ("whitespace required before NDATA"); requireWhitespace (); String notationName = readNmtoken (true); if (!skippedPE) { setExternalEntity (name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl (name, ids, notationName); } } else if (!skippedPE) { setExternalEntity (name, ENTITY_TEXT, ids, null); handler.getDeclHandler () .externalEntityDecl (name, ids [0], handler.resolveURIs () // FIXME: ASSUMES not skipped // "false" forces error on bad URI ? handler.absolutize (ids [2], ids [1], false) : ids [1]); } } // Finish the declaration. skipWhitespace (); require ('>'); }
|
? handler.absolutize (ids [2], ids [1], false) : ids [1]);
|
? handler.absolutize(ids.baseUri, ids.systemId, false) : ids.systemId);
|
private void parseEntityDecl () throws Exception { boolean peFlag = false; int flags = 0; // Check for a parameter entity. expandPE = false; requireWhitespace (); if (tryRead ('%')) { peFlag = true; requireWhitespace (); } expandPE = true; // Read the entity name, and prepend // '%' if necessary. String name = readNmtoken (true); //NE08 if (name.indexOf(':') >= 0) error ("Illegal character(':') in entity name ", name, null); if (peFlag) { name = "%" + name; } // Read the entity value. requireWhitespace (); char c = readCh (); unread (c); if (c == '"' || c == '\'') { // Internal entity ... replacement text has expanded refs // to characters and PEs, but not to general entities String value = readLiteral (flags); setInternalEntity (name, value); } else { // Read the external IDs String ids [] = readExternalIds (false, false); // Check for NDATA declaration. boolean white = tryWhitespace (); if (!peFlag && tryRead ("NDATA")) { if (!white) error ("whitespace required before NDATA"); requireWhitespace (); String notationName = readNmtoken (true); if (!skippedPE) { setExternalEntity (name, ENTITY_NDATA, ids, notationName); handler.unparsedEntityDecl (name, ids, notationName); } } else if (!skippedPE) { setExternalEntity (name, ENTITY_TEXT, ids, null); handler.getDeclHandler () .externalEntityDecl (name, ids [0], handler.resolveURIs () // FIXME: ASSUMES not skipped // "false" forces error on bad URI ? handler.absolutize (ids [2], ids [1], false) : ids [1]); } } // Finish the declaration. skipWhitespace (); require ('>'); }
|
handler.skippedEntity (name); } else error (message);
|
{ handler.skippedEntity(name); } } else { error(message); }
|
private void parseEntityRef (boolean externalAllowed) throws SAXException, IOException { String name; name = readNmtoken (true); require (';'); switch (getEntityType (name)) { case ENTITY_UNDECLARED: // NOTE: XML REC describes amazingly convoluted handling for // this case. Nothing as meaningful as being a WFness error // unless the processor might _legitimately_ not have seen a // declaration ... which is what this implements. String message; message = "reference to undeclared general entity " + name; if (skippedPE && !docIsStandalone) { handler.verror (message); // we don't know this entity, and it might be external... if (externalAllowed) handler.skippedEntity (name); } else error (message); break; case ENTITY_INTERNAL: pushString (name, getEntityValue (name)); //workaround for possible input pop before marking //the buffer reading position char t = readCh (); unread (t); int bufferPosMark = readBufferPos; int end = readBufferPos + getEntityValue (name).length(); for(int k = readBufferPos; k < end; k++){ t = readCh (); if (t == '&'){ t = readCh (); if (t == '#'){ //try to match a character ref tryReadCharRef (); //everything has been read if (readBufferPos >= end) break; k = readBufferPos; continue; } else if (Character.isLetter(t)){ //looks like an entity ref unread (t); readNmtoken (true); require (';'); //everything has been read if (readBufferPos >= end) break; k = readBufferPos; continue; } error(" malformed entity reference"); } } readBufferPos = bufferPosMark; break; case ENTITY_TEXT: if (externalAllowed) { pushURL (false, name, getEntityIds (name), null, null, null, true); } else { error ("reference to external entity in attribute value.", name, null); } break; case ENTITY_NDATA: if (externalAllowed) { error ("unparsed entity reference in content", name, null); } else { error ("reference to external entity in attribute value.", name, null); } break; default: throw new RuntimeException (); } }
|
char saved [] = null;
|
char[] saved = null;
|
private void parseMarkupdecl () throws Exception { char saved [] = null; boolean savedPE = expandPE; // prevent "<%foo;" and ensures saved entity is right require ('<'); unread ('<'); expandPE = false; if (tryRead ("<!ELEMENT")) { saved = readBuffer; expandPE = savedPE; parseElementDecl (); } else if (tryRead ("<!ATTLIST")) { saved = readBuffer; expandPE = savedPE; parseAttlistDecl (); } else if (tryRead ("<!ENTITY")) { saved = readBuffer; expandPE = savedPE; parseEntityDecl (); } else if (tryRead ("<!NOTATION")) { saved = readBuffer; expandPE = savedPE; parseNotationDecl (); } else if (tryRead (startDelimPI)) { saved = readBuffer; expandPE = savedPE; parsePI (); } else if (tryRead (startDelimComment)) { saved = readBuffer; expandPE = savedPE; parseComment (); } else if (tryRead ("<![")) { saved = readBuffer; expandPE = savedPE; if (inputStack.size () > 0) parseConditionalSect (saved); else error ("conditional sections illegal in internal subset"); } else { error ("expected markup declaration"); } // VC: Proper Decl/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Declaration/PE nesting"); }
|
if (inputStack.size () > 0) parseConditionalSect (saved);
|
if (inputStack.size() > 0) { parseConditionalSect(saved); }
|
private void parseMarkupdecl () throws Exception { char saved [] = null; boolean savedPE = expandPE; // prevent "<%foo;" and ensures saved entity is right require ('<'); unread ('<'); expandPE = false; if (tryRead ("<!ELEMENT")) { saved = readBuffer; expandPE = savedPE; parseElementDecl (); } else if (tryRead ("<!ATTLIST")) { saved = readBuffer; expandPE = savedPE; parseAttlistDecl (); } else if (tryRead ("<!ENTITY")) { saved = readBuffer; expandPE = savedPE; parseEntityDecl (); } else if (tryRead ("<!NOTATION")) { saved = readBuffer; expandPE = savedPE; parseNotationDecl (); } else if (tryRead (startDelimPI)) { saved = readBuffer; expandPE = savedPE; parsePI (); } else if (tryRead (startDelimComment)) { saved = readBuffer; expandPE = savedPE; parseComment (); } else if (tryRead ("<![")) { saved = readBuffer; expandPE = savedPE; if (inputStack.size () > 0) parseConditionalSect (saved); else error ("conditional sections illegal in internal subset"); } else { error ("expected markup declaration"); } // VC: Proper Decl/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Declaration/PE nesting"); }
|
error ("conditional sections illegal in internal subset"); } else { error ("expected markup declaration");
|
{ error("conditional sections illegal in internal subset"); } } else { error("expected markup declaration");
|
private void parseMarkupdecl () throws Exception { char saved [] = null; boolean savedPE = expandPE; // prevent "<%foo;" and ensures saved entity is right require ('<'); unread ('<'); expandPE = false; if (tryRead ("<!ELEMENT")) { saved = readBuffer; expandPE = savedPE; parseElementDecl (); } else if (tryRead ("<!ATTLIST")) { saved = readBuffer; expandPE = savedPE; parseAttlistDecl (); } else if (tryRead ("<!ENTITY")) { saved = readBuffer; expandPE = savedPE; parseEntityDecl (); } else if (tryRead ("<!NOTATION")) { saved = readBuffer; expandPE = savedPE; parseNotationDecl (); } else if (tryRead (startDelimPI)) { saved = readBuffer; expandPE = savedPE; parsePI (); } else if (tryRead (startDelimComment)) { saved = readBuffer; expandPE = savedPE; parseComment (); } else if (tryRead ("<![")) { saved = readBuffer; expandPE = savedPE; if (inputStack.size () > 0) parseConditionalSect (saved); else error ("conditional sections illegal in internal subset"); } else { error ("expected markup declaration"); } // VC: Proper Decl/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Declaration/PE nesting"); }
|
handler.verror ("Illegal Declaration/PE nesting");
|
{ handler.verror("Illegal Declaration/PE nesting"); }
|
private void parseMarkupdecl () throws Exception { char saved [] = null; boolean savedPE = expandPE; // prevent "<%foo;" and ensures saved entity is right require ('<'); unread ('<'); expandPE = false; if (tryRead ("<!ELEMENT")) { saved = readBuffer; expandPE = savedPE; parseElementDecl (); } else if (tryRead ("<!ATTLIST")) { saved = readBuffer; expandPE = savedPE; parseAttlistDecl (); } else if (tryRead ("<!ENTITY")) { saved = readBuffer; expandPE = savedPE; parseEntityDecl (); } else if (tryRead ("<!NOTATION")) { saved = readBuffer; expandPE = savedPE; parseNotationDecl (); } else if (tryRead (startDelimPI)) { saved = readBuffer; expandPE = savedPE; parsePI (); } else if (tryRead (startDelimComment)) { saved = readBuffer; expandPE = savedPE; parseComment (); } else if (tryRead ("<![")) { saved = readBuffer; expandPE = savedPE; if (inputStack.size () > 0) parseConditionalSect (saved); else error ("conditional sections illegal in internal subset"); } else { error ("expected markup declaration"); } // VC: Proper Decl/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Declaration/PE nesting"); }
|
private void parseMixed (char saved [])
|
private void parseMixed(char[] saved)
|
private void parseMixed (char saved []) throws Exception { // Check for PCDATA alone. skipWhitespace (); if (tryRead (')')) { // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (")*"); tryRead ('*'); return; } // Parse mixed content. skipWhitespace (); while (!tryRead (")")) { require ('|'); dataBufferAppend ('|'); skipWhitespace (); dataBufferAppend (readNmtoken (true)); skipWhitespace (); } // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); require ('*'); dataBufferAppend (")*"); }
|
handler.verror ("Illegal Group/PE nesting");
|
{ handler.verror("Illegal Group/PE nesting"); }
|
private void parseMixed (char saved []) throws Exception { // Check for PCDATA alone. skipWhitespace (); if (tryRead (')')) { // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); dataBufferAppend (")*"); tryRead ('*'); return; } // Parse mixed content. skipWhitespace (); while (!tryRead (")")) { require ('|'); dataBufferAppend ('|'); skipWhitespace (); dataBufferAppend (readNmtoken (true)); skipWhitespace (); } // VC: Proper Group/PE Nesting if (readBuffer != saved) handler.verror ("Illegal Group/PE nesting"); require ('*'); dataBufferAppend (")*"); }
|
String nname, ids[];
|
String nname; ExternalIdentifiers ids;
|
private void parseNotationDecl () throws Exception { String nname, ids[]; requireWhitespace (); nname = readNmtoken (true); //NE08 if (nname.indexOf(':') >= 0) error ("Illegal character(':') in notation name ", nname, null); requireWhitespace (); // Read the external identifiers. ids = readExternalIds (true, false); // Register the notation. setNotation (nname, ids); skipWhitespace (); require ('>'); }
|
error ("Illegal character(':') in notation name ", nname, null); requireWhitespace ();
|
{ error("Illegal character(':') in notation name ", nname, null); } requireWhitespace();
|
private void parseNotationDecl () throws Exception { String nname, ids[]; requireWhitespace (); nname = readNmtoken (true); //NE08 if (nname.indexOf(':') >= 0) error ("Illegal character(':') in notation name ", nname, null); requireWhitespace (); // Read the external identifiers. ids = readExternalIds (true, false); // Register the notation. setNotation (nname, ids); skipWhitespace (); require ('>'); }
|
pushString (name, getEntityValue (name));
|
{ pushString(name, getEntityValue(name)); }
|
private void parsePEReference () throws SAXException, IOException { String name; name = "%" + readNmtoken (true); require (';'); switch (getEntityType (name)) { case ENTITY_UNDECLARED: // VC: Entity Declared handler.verror ("reference to undeclared parameter entity " + name); // we should disable handling of all subsequent declarations // unless this is a standalone document (info discarded) break; case ENTITY_INTERNAL: if (inLiteral) pushString (name, getEntityValue (name)); else pushString (name, ' ' + getEntityValue (name) + ' '); break; case ENTITY_TEXT: if (!inLiteral) pushString (null, " "); pushURL (true, name, getEntityIds (name), null, null, null, true); if (!inLiteral) pushString (null, " "); break; } }
|
pushString (name, ' ' + getEntityValue (name) + ' ');
|
{ pushString(name, ' ' + getEntityValue(name) + ' '); }
|
private void parsePEReference () throws SAXException, IOException { String name; name = "%" + readNmtoken (true); require (';'); switch (getEntityType (name)) { case ENTITY_UNDECLARED: // VC: Entity Declared handler.verror ("reference to undeclared parameter entity " + name); // we should disable handling of all subsequent declarations // unless this is a standalone document (info discarded) break; case ENTITY_INTERNAL: if (inLiteral) pushString (name, getEntityValue (name)); else pushString (name, ' ' + getEntityValue (name) + ' '); break; case ENTITY_TEXT: if (!inLiteral) pushString (null, " "); pushURL (true, name, getEntityIds (name), null, null, null, true); if (!inLiteral) pushString (null, " "); break; } }
|
pushString (null, " "); pushURL (true, name, getEntityIds (name), null, null, null, true);
|
{ pushString(null, " "); } pushURL(true, name, getEntityIds(name), null, null, null, true);
|
private void parsePEReference () throws SAXException, IOException { String name; name = "%" + readNmtoken (true); require (';'); switch (getEntityType (name)) { case ENTITY_UNDECLARED: // VC: Entity Declared handler.verror ("reference to undeclared parameter entity " + name); // we should disable handling of all subsequent declarations // unless this is a standalone document (info discarded) break; case ENTITY_INTERNAL: if (inLiteral) pushString (name, getEntityValue (name)); else pushString (name, ' ' + getEntityValue (name) + ' '); break; case ENTITY_TEXT: if (!inLiteral) pushString (null, " "); pushURL (true, name, getEntityIds (name), null, null, null, true); if (!inLiteral) pushString (null, " "); break; } }
|
pushString (null, " ");
|
{ pushString(null, " "); }
|
private void parsePEReference () throws SAXException, IOException { String name; name = "%" + readNmtoken (true); require (';'); switch (getEntityType (name)) { case ENTITY_UNDECLARED: // VC: Entity Declared handler.verror ("reference to undeclared parameter entity " + name); // we should disable handling of all subsequent declarations // unless this is a standalone document (info discarded) break; case ENTITY_INTERNAL: if (inLiteral) pushString (name, getEntityValue (name)); else pushString (name, ' ' + getEntityValue (name) + ' '); break; case ENTITY_TEXT: if (!inLiteral) pushString (null, " "); pushURL (true, name, getEntityIds (name), null, null, null, true); if (!inLiteral) pushString (null, " "); break; } }
|
error ("Illegal character(':') in processing instruction name ", name, null); if ("xml".equalsIgnoreCase (name)) error ("Illegal processing instruction target", name, null); if (!tryRead (endDelimPI)) { requireWhitespace (); parseUntil (endDelimPI);
|
{ error("Illegal character(':') in processing instruction name ", name, null); } if ("xml".equalsIgnoreCase(name)) { error("Illegal processing instruction target", name, null); } if (!tryRead(endDelimPI)) { requireWhitespace(); parseUntil(endDelimPI);
|
private void parsePI () throws SAXException, IOException { String name; boolean saved = expandPE; expandPE = false; name = readNmtoken (true); //NE08 if (name.indexOf(':') >= 0) error ("Illegal character(':') in processing instruction name ", name, null); if ("xml".equalsIgnoreCase (name)) error ("Illegal processing instruction target", name, null); if (!tryRead (endDelimPI)) { requireWhitespace (); parseUntil (endDelimPI); } expandPE = saved; handler.processingInstruction (name, dataBufferToString ()); }
|
setupDecoding (encodingName); skipWhitespace (); require ("?>");
|
{ setupDecoding(encodingName); } skipWhitespace(); require("?>");
|
private String parseTextDecl (boolean ignoreEncoding) throws SAXException, IOException { String encodingName = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; // Read an optional version. if (tryRead ("version")) { String version; parseEq (); checkLegalVersion (version = readLiteral (flags)); if (version.equals ("1.1")){ if (xmlVersion == XML_10){ error ("external subset has later version number.", "1.0", version); } handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else if(!version.equals ("1.0")) { error("illegal XML version", version, "1.0 or 1.1"); } requireWhitespace (); } // Read the encoding. require ("encoding"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); skipWhitespace (); require ("?>"); return encodingName; }
|
error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags);
|
{ error("whitespace required before 'encoding='"); } parseEq(); encodingName = readLiteral(flags);
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
setupDecoding (encodingName);
|
{ setupDecoding(encodingName); }
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
white = tryWhitespace (); if (tryRead ("standalone")) {
|
{ white = tryWhitespace(); } if (tryRead("standalone")) {
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone))
|
{ error("whitespace required before 'standalone='"); } parseEq(); standalone = readLiteral(flags); if ("yes".equals(standalone)) {
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'");
|
} else if (!"no".equals(standalone)) { error("standalone flag must be 'yes' or 'no'"); }
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
handler.xmlDecl(version, encodingName, "yes".equals(standalone),
|
handler.xmlDecl(version, encodingName, docIsStandalone,
|
private String parseXMLDecl (boolean ignoreEncoding) throws SAXException, IOException { String version; String encodingName = null; String standalone = null; int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF; String inputEncoding = null; switch (this.encoding) { case ENCODING_EXTERNAL: case ENCODING_UTF_8: inputEncoding = "UTF-8"; break; case ENCODING_ISO_8859_1: inputEncoding = "ISO-8859-1"; break; case ENCODING_UCS_2_12: inputEncoding = "UTF-16BE"; break; case ENCODING_UCS_2_21: inputEncoding = "UTF-16LE"; break; } // Read the version. require ("version"); parseEq (); checkLegalVersion (version = readLiteral (flags)); if (!version.equals ("1.0")){ if(version.equals ("1.1")){ handler.warn ("expected XML version 1.0, not: " + version); xmlVersion = XML_11; }else { error("illegal XML version", version, "1.0 or 1.1"); } } else xmlVersion = XML_10; // Try reading an encoding declaration. boolean white = tryWhitespace (); if (tryRead ("encoding")) { if (!white) error ("whitespace required before 'encoding='"); parseEq (); encodingName = readLiteral (flags); if (!ignoreEncoding) setupDecoding (encodingName); } // Try reading a standalone declaration if (encodingName != null) white = tryWhitespace (); if (tryRead ("standalone")) { if (!white) error ("whitespace required before 'standalone='"); parseEq (); standalone = readLiteral (flags); if ("yes".equals (standalone)) docIsStandalone = true; else if (!"no".equals (standalone)) error ("standalone flag must be 'yes' or 'no'"); } skipWhitespace (); require ("?>"); if (inputEncoding == null) { inputEncoding = encodingName; } handler.xmlDecl(version, encodingName, "yes".equals(standalone), inputEncoding); return encodingName; }
|
String ename = (String) entityStack.pop ();
|
String ename = (String) entityStack.removeLast();
|
private void popInput () throws SAXException, IOException { String ename = (String) entityStack.pop (); if (ename != null && doReport) dataBufferFlush (); switch (sourceType) { case INPUT_STREAM: handler.endExternalEntity (ename); is.close (); break; case INPUT_READER: handler.endExternalEntity (ename); reader.close (); break; case INPUT_INTERNAL: if (ename != null && doReport) handler.endInternalEntity (ename); break; } // Throw an EOFException if there // is nothing else to pop. if (inputStack.isEmpty ()) { throw new EOFException ("no more input"); } Object input [] = (Object[]) inputStack.pop (); sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11]; }
|
dataBufferFlush (); switch (sourceType) {
|
{ dataBufferFlush(); } switch (sourceType) {
|
private void popInput () throws SAXException, IOException { String ename = (String) entityStack.pop (); if (ename != null && doReport) dataBufferFlush (); switch (sourceType) { case INPUT_STREAM: handler.endExternalEntity (ename); is.close (); break; case INPUT_READER: handler.endExternalEntity (ename); reader.close (); break; case INPUT_INTERNAL: if (ename != null && doReport) handler.endInternalEntity (ename); break; } // Throw an EOFException if there // is nothing else to pop. if (inputStack.isEmpty ()) { throw new EOFException ("no more input"); } Object input [] = (Object[]) inputStack.pop (); sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11]; }
|
handler.endInternalEntity (ename);
|
{ handler.endInternalEntity(ename); }
|
private void popInput () throws SAXException, IOException { String ename = (String) entityStack.pop (); if (ename != null && doReport) dataBufferFlush (); switch (sourceType) { case INPUT_STREAM: handler.endExternalEntity (ename); is.close (); break; case INPUT_READER: handler.endExternalEntity (ename); reader.close (); break; case INPUT_INTERNAL: if (ename != null && doReport) handler.endInternalEntity (ename); break; } // Throw an EOFException if there // is nothing else to pop. if (inputStack.isEmpty ()) { throw new EOFException ("no more input"); } Object input [] = (Object[]) inputStack.pop (); sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11]; }
|
Object input [] = (Object[]) inputStack.pop ();
|
Input input = (Input) inputStack.removeLast();
|
private void popInput () throws SAXException, IOException { String ename = (String) entityStack.pop (); if (ename != null && doReport) dataBufferFlush (); switch (sourceType) { case INPUT_STREAM: handler.endExternalEntity (ename); is.close (); break; case INPUT_READER: handler.endExternalEntity (ename); reader.close (); break; case INPUT_INTERNAL: if (ename != null && doReport) handler.endInternalEntity (ename); break; } // Throw an EOFException if there // is nothing else to pop. if (inputStack.isEmpty ()) { throw new EOFException ("no more input"); } Object input [] = (Object[]) inputStack.pop (); sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11]; }
|
sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11];
|
sourceType = input.sourceType; externalEntity = input.externalEntity; readBuffer = input.readBuffer; readBufferPos = input.readBufferPos; readBufferLength = input.readBufferLength; line = input.line; encoding = input.encoding; readBufferOverflow = input.readBufferOverflow; is = input.is; currentByteCount = input.currentByteCount; column = input.column; reader = input.reader;
|
private void popInput () throws SAXException, IOException { String ename = (String) entityStack.pop (); if (ename != null && doReport) dataBufferFlush (); switch (sourceType) { case INPUT_STREAM: handler.endExternalEntity (ename); is.close (); break; case INPUT_READER: handler.endExternalEntity (ename); reader.close (); break; case INPUT_INTERNAL: if (ename != null && doReport) handler.endInternalEntity (ename); break; } // Throw an EOFException if there // is nothing else to pop. if (inputStack.isEmpty ()) { throw new EOFException ("no more input"); } Object input [] = (Object[]) inputStack.pop (); sourceType = ((Integer) input [0]).intValue (); externalEntity = (URLConnection) input [1]; readBuffer = (char[]) input [2]; readBufferPos = ((Integer) input [3]).intValue (); readBufferLength = ((Integer) input [4]).intValue (); line = ((Integer) input [5]).intValue (); encoding = ((Integer) input [6]).intValue (); readBufferOverflow = ((Integer) input [7]).intValue (); is = (InputStream) input [8]; currentByteCount = ((Integer) input [9]).intValue (); column = ((Integer) input [10]).intValue (); reader = (Reader) input [11]; }
|
error ("unfinished XML or encoding declaration");
|
{ error("unfinished XML or encoding declaration"); }
|
private void prefetchASCIIEncodingDecl () throws SAXException, IOException { int ch; readBufferPos = readBufferLength = 0; is.mark (readBuffer.length); while (true) { ch = is.read (); readBuffer [readBufferLength++] = (char) ch; switch (ch) { case (int) '>': return; case -1: error ("file ends before end of XML or encoding declaration.", null, "?>"); } if (readBuffer.length == readBufferLength) error ("unfinished XML or encoding declaration"); } }
|
private void pushCharArray (String ename, char ch[], int start, int length)
|
private void pushCharArray(String ename, char[] ch, int start, int length)
|
private void pushCharArray (String ename, char ch[], int start, int length) throws SAXException { // Push the existing status pushInput (ename); if (ename != null && doReport) { dataBufferFlush (); handler.startInternalEntity (ename); } sourceType = INPUT_INTERNAL; readBuffer = ch; readBufferPos = start; readBufferLength = length; readBufferOverflow = -1; }
|
if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null);
|
if (ename != null) { Iterator entities = entityStack.iterator(); while (entities.hasNext()) { String e = (String) entities.next(); if (e != null && e == ename) { error("recursive reference to entity", ename, null);
|
private void pushInput (String ename) throws SAXException { // Check for entity recursion. if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null); } } } entityStack.push (ename); // Don't bother if there is no current input. if (sourceType == INPUT_NONE) { return; } // Set up a snapshot of the current // input source. Object input[] = new Object [12]; input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader; // Push it onto the stack. inputStack.push (input); }
|
entityStack.push (ename);
|
entityStack.addLast(ename);
|
private void pushInput (String ename) throws SAXException { // Check for entity recursion. if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null); } } } entityStack.push (ename); // Don't bother if there is no current input. if (sourceType == INPUT_NONE) { return; } // Set up a snapshot of the current // input source. Object input[] = new Object [12]; input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader; // Push it onto the stack. inputStack.push (input); }
|
Object input[] = new Object [12];
|
Input input = new Input();
|
private void pushInput (String ename) throws SAXException { // Check for entity recursion. if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null); } } } entityStack.push (ename); // Don't bother if there is no current input. if (sourceType == INPUT_NONE) { return; } // Set up a snapshot of the current // input source. Object input[] = new Object [12]; input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader; // Push it onto the stack. inputStack.push (input); }
|
input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader;
|
input.sourceType = sourceType; input.externalEntity = externalEntity; input.readBuffer = readBuffer; input.readBufferPos = readBufferPos; input.readBufferLength = readBufferLength; input.line = line; input.encoding = encoding; input.readBufferOverflow = readBufferOverflow; input.is = is; input.currentByteCount = currentByteCount; input.column = column; input.reader = reader;
|
private void pushInput (String ename) throws SAXException { // Check for entity recursion. if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null); } } } entityStack.push (ename); // Don't bother if there is no current input. if (sourceType == INPUT_NONE) { return; } // Set up a snapshot of the current // input source. Object input[] = new Object [12]; input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader; // Push it onto the stack. inputStack.push (input); }
|
inputStack.push (input);
|
inputStack.addLast(input);
|
private void pushInput (String ename) throws SAXException { // Check for entity recursion. if (ename != null) { Enumeration entities = entityStack.elements (); while (entities.hasMoreElements ()) { String e = (String) entities.nextElement (); if (e != null && e == ename) { error ("recursive reference to entity", ename, null); } } } entityStack.push (ename); // Don't bother if there is no current input. if (sourceType == INPUT_NONE) { return; } // Set up a snapshot of the current // input source. Object input[] = new Object [12]; input [0] = new Integer (sourceType); input [1] = externalEntity; input [2] = readBuffer; input [3] = new Integer (readBufferPos); input [4] = new Integer (readBufferLength); input [5] = new Integer (line); input [6] = new Integer (encoding); input [7] = new Integer (readBufferOverflow); input [8] = is; input [9] = new Integer (currentByteCount); input [10] = new Integer (column); input [11] = reader; // Push it onto the stack. inputStack.push (input); }
|
char ch[] = s.toCharArray (); pushCharArray (ename, ch, 0, ch.length);
|
char[] ch = s.toCharArray(); pushCharArray(ename, ch, 0, ch.length);
|
private void pushString (String ename, String s) throws SAXException { char ch[] = s.toCharArray (); pushCharArray (ename, ch, 0, ch.length); }
|
String ids [],
|
ExternalIdentifiers ids,
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]);
|
{ dataBufferFlush(); } scratch.setPublicId(ids.publicId); scratch.setSystemId(ids.systemId);
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename);
|
source = handler.resolveEntity(isPE, ename, scratch, ids.baseUri); if (source == null) { handler.warn("skipping entity: " + ename); handler.skippedEntity(ename);
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1];
|
handler.warn ("missing system ID, using " + ids.systemId); systemId = ids.systemId;
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId,
|
systemId = ids.systemId; if (handler.stringInterning) { handler.startExternalEntity(ename, systemId,
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (),
|
{ stream = source.getByteStream(); } else { try { reader = new InputStreamReader(source.getByteStream(),
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
} catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null);
|
} catch (IOException e) { stream = source.getByteStream(); } } } else if (systemId == null) { error("InputSource has no URI!"); } scratch.setCharacterStream(null); scratch.setByteStream(null); scratch.setEncoding(null);
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
else {
|
} else {
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1);
|
if ((temp = encoding.indexOf(';')) > 0) { encoding = encoding.substring(0, temp); } if ((temp = encoding.indexOf('=', temp + 7)) > 0) { encoding = encoding.substring(temp + 1);
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp);
|
if ((temp = encoding.indexOf('(')) > 0) { encoding = encoding.substring(0, temp); }
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: "
|
if ((temp = encoding.indexOf('"')) > 0) { encoding = encoding.substring(temp + 1, encoding.indexOf('"', temp + 2)); } encoding.trim(); } else { handler.warn("ignoring illegal MIME attribute: "
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
is.reset ();
|
} is.reset();
|
private void pushURL ( boolean isPE, String ename, String ids [], // public, system, baseURI Reader reader, InputStream stream, String encoding, boolean doResolve ) throws SAXException, IOException { boolean ignoreEncoding; String systemId; InputSource source; if (!isPE) dataBufferFlush (); scratch.setPublicId (ids [0]); scratch.setSystemId (ids [1]); // See if we should skip or substitute the entity. // If we're not skipping, resolving reports startEntity() // and updates the (handler's) stack of URIs. if (doResolve) { // assert (stream == null && reader == null && encoding == null) source = handler.resolveEntity (isPE, ename, scratch, ids [2]); if (source == null) { handler.warn ("skipping entity: " + ename); handler.skippedEntity (ename); if (isPE) skippedPE = true; return; } // we might be using alternate IDs/encoding systemId = source.getSystemId (); // The following warning and setting systemId was deleted bcause // the application has the option of not setting systemId // provided that it has set the characte/byte stream. /* if (systemId == null) { handler.warn ("missing system ID, using " + ids [1]); systemId = ids [1]; } */ } else { // "[document]", or "[dtd]" via getExternalSubset() scratch.setCharacterStream (reader); scratch.setByteStream (stream); scratch.setEncoding (encoding); source = scratch; systemId = ids [1]; if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { handler.startExternalEntity (ename, systemId, "[document]" == ename); } else { handler.startExternalEntity (ename, systemId, "[document]".equals(ename)); } } // we may have been given I/O streams directly if (source.getCharacterStream () != null) { if (source.getByteStream () != null) error ("InputSource has two streams!"); reader = source.getCharacterStream (); } else if (source.getByteStream () != null) { encoding = source.getEncoding (); if (encoding == null) stream = source.getByteStream (); else try { reader = new InputStreamReader ( source.getByteStream (), encoding); } catch (IOException e) { stream = source.getByteStream (); } } else if (systemId == null) error ("InputSource has no URI!"); scratch.setCharacterStream (null); scratch.setByteStream (null); scratch.setEncoding (null); // Push the existing status. pushInput (ename); // Create a new read buffer. // (Note the four-character margin) readBuffer = new char [READ_BUFFER_MAX + 4]; readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; is = null; line = 1; column = 0; currentByteCount = 0; // If there's an explicit character stream, just // ignore encoding declarations. if (reader != null) { sourceType = INPUT_READER; this.reader = reader; tryEncodingDecl (true); return; } // Else we handle the conversion, and need to ensure // it's done right. sourceType = INPUT_STREAM; if (stream != null) { is = stream; } else { // We have to open our own stream to the URL. URL url = new URL (systemId); externalEntity = url.openConnection (); externalEntity.connect (); is = externalEntity.getInputStream (); } // If we get to here, there must be // an InputStream available. if (!is.markSupported ()) { is = new BufferedInputStream (is); } // Get any external encoding label. if (encoding == null && externalEntity != null) { // External labels can be untrustworthy; filesystems in // particular often have the wrong default for content // that wasn't locally originated. Those we autodetect. if (!"file".equals (externalEntity.getURL ().getProtocol ())) { int temp; // application/xml;charset=something;otherAttr=... // ... with many variants on 'something' encoding = externalEntity.getContentType (); // MHK code (fix for Saxon 5.5.1/007): // protect against encoding==null if (encoding==null) { temp = -1; } else { temp = encoding.indexOf ("charset"); } // RFC 2376 sez MIME text defaults to ASCII, but since the // JDK will create a MIME type out of thin air, we always // autodetect when there's no explicit charset attribute. if (temp < 0) encoding = null; // autodetect else { // only this one attribute if ((temp = encoding.indexOf (';')) > 0) encoding = encoding.substring (0, temp); if ((temp = encoding.indexOf ('=', temp + 7)) > 0) { encoding = encoding.substring (temp + 1); // attributes can have comment fields (RFC 822) if ((temp = encoding.indexOf ('(')) > 0) encoding = encoding.substring (0, temp); // ... and values may be quoted if ((temp = encoding.indexOf ('"')) > 0) encoding = encoding.substring (temp + 1, encoding.indexOf ('"', temp + 2)); encoding.trim (); } else { handler.warn ("ignoring illegal MIME attribute: " + encoding); encoding = null; } } } } // if we got an external encoding label, use it ... if (encoding != null) { this.encoding = ENCODING_EXTERNAL; setupDecoding (encoding); ignoreEncoding = true; // ... else autodetect from first bytes. } else { detectEncoding (); ignoreEncoding = false; } // Read any XML or text declaration. // If we autodetected, it may tell us the "real" encoding. try { tryEncodingDecl (ignoreEncoding); } catch (UnsupportedEncodingException x) { encoding = x.getMessage (); // if we don't handle the declared encoding, // try letting a JVM InputStreamReader do it try { if (sourceType != INPUT_STREAM) throw x; is.reset (); readBufferPos = 0; readBufferLength = 0; readBufferOverflow = -1; line = 1; currentByteCount = column = 0; sourceType = INPUT_READER; this.reader = new InputStreamReader (is, encoding); is = null; tryEncodingDecl (true); } catch (IOException e) { error ("unsupported text encoding", encoding, null); } } }
|
} else { String typeString = readNmtoken (true); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("NOTATION" == typeString) { parseNotationType ();
|
} else { String typeString = readNmtoken(true); if (handler.stringInterning) { if ("NOTATION" == typeString) { parseNotationType();
|
private String readAttType () throws Exception { if (tryRead ('(')) { parseEnumeration (false); return "ENUMERATION"; } else { String typeString = readNmtoken (true); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("NOTATION" == typeString) { parseNotationType (); return typeString; } else if ("CDATA" == typeString || "ID" == typeString || "IDREF" == typeString || "IDREFS" == typeString || "ENTITY" == typeString || "ENTITIES" == typeString || "NMTOKEN" == typeString || "NMTOKENS" == typeString) return typeString; } else { if ("NOTATION".equals(typeString)) { parseNotationType (); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; } error ("illegal attribute type", typeString, null); return null; } }
|
} else { if ("NOTATION".equals(typeString)) { parseNotationType ();
|
} } else { if ("NOTATION".equals(typeString)) { parseNotationType();
|
private String readAttType () throws Exception { if (tryRead ('(')) { parseEnumeration (false); return "ENUMERATION"; } else { String typeString = readNmtoken (true); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("NOTATION" == typeString) { parseNotationType (); return typeString; } else if ("CDATA" == typeString || "ID" == typeString || "IDREF" == typeString || "IDREFS" == typeString || "ENTITY" == typeString || "ENTITIES" == typeString || "NMTOKEN" == typeString || "NMTOKENS" == typeString) return typeString; } else { if ("NOTATION".equals(typeString)) { parseNotationType (); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; } error ("illegal attribute type", typeString, null); return null; } }
|
error ("illegal attribute type", typeString, null);
|
} error("illegal attribute type", typeString, null);
|
private String readAttType () throws Exception { if (tryRead ('(')) { parseEnumeration (false); return "ENUMERATION"; } else { String typeString = readNmtoken (true); if (handler.getFeature (SAXDriver.FEATURE + "string-interning")) { if ("NOTATION" == typeString) { parseNotationType (); return typeString; } else if ("CDATA" == typeString || "ID" == typeString || "IDREF" == typeString || "IDREFS" == typeString || "ENTITY" == typeString || "ENTITIES" == typeString || "NMTOKEN" == typeString || "NMTOKENS" == typeString) return typeString; } else { if ("NOTATION".equals(typeString)) { parseNotationType (); return typeString; } else if ("CDATA".equals(typeString) || "ID".equals(typeString) || "IDREF".equals(typeString) || "IDREFS".equals(typeString) || "ENTITY".equals(typeString) || "ENTITIES".equals(typeString) || "NMTOKEN".equals(typeString) || "NMTOKENS".equals(typeString)) return typeString; } error ("illegal attribute type", typeString, null); return null; } }
|
error ("illegal XML character U+" + Integer.toHexString (c));
|
{ error("illegal XML character U+" + Integer.toHexString(c)); }
|
private char readCh () throws SAXException, IOException { // As long as there's nothing in the // read buffer, try reading more data // (for an external entity) or popping // the entity stack (for either). while (readBufferPos >= readBufferLength) { switch (sourceType) { case INPUT_READER: case INPUT_STREAM: readDataChunk (); while (readBufferLength < 1) { popInput (); if (readBufferLength < 1) { readDataChunk (); } } break; default: popInput (); break; } } char c = readBuffer [readBufferPos++]; if (c == '\n') { line++; column = 0; } else { if (c == '<') { /* the most common return to parseContent () ... NOP */ } else if (((c < 0x0020 && (c != '\t') && (c != '\r')) || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // If we're in the DTD and in a context where PEs get expanded, // do so ... 1/14/2000 errata identify those contexts. There // are also spots in the internal subset where PE refs are fatal // errors, hence yet another flag. else if (c == '%' && expandPE) { if (peIsError) error ("PE reference within decl in internal subset."); parsePEReference (); return readCh (); } column++; } return c; }
|
error ("PE reference within decl in internal subset."); parsePEReference (); return readCh ();
|
{ error("PE reference within decl in internal subset."); } parsePEReference(); return readCh();
|
private char readCh () throws SAXException, IOException { // As long as there's nothing in the // read buffer, try reading more data // (for an external entity) or popping // the entity stack (for either). while (readBufferPos >= readBufferLength) { switch (sourceType) { case INPUT_READER: case INPUT_STREAM: readDataChunk (); while (readBufferLength < 1) { popInput (); if (readBufferLength < 1) { readDataChunk (); } } break; default: popInput (); break; } } char c = readBuffer [readBufferPos++]; if (c == '\n') { line++; column = 0; } else { if (c == '<') { /* the most common return to parseContent () ... NOP */ } else if (((c < 0x0020 && (c != '\t') && (c != '\r')) || c > 0xFFFD) || ((c >= 0x007f) && (c <= 0x009f) && (c != 0x0085) && xmlVersion == XML_11)) error ("illegal XML character U+" + Integer.toHexString (c)); // If we're in the DTD and in a context where PEs get expanded, // do so ... 1/14/2000 errata identify those contexts. There // are also spots in the internal subset where PE refs are fatal // errors, hence yet another flag. else if (c == '%' && expandPE) { if (peIsError) error ("PE reference within decl in internal subset."); parsePEReference (); return readCh (); } column++; } return c; }
|
filterCR (count >= 0);
|
{ filterCR(count >= 0); }
|
private void readDataChunk () throws SAXException, IOException { int count; // See if we have any overflow (filterCR sets for CR at end) if (readBufferOverflow > -1) { readBuffer [0] = (char) readBufferOverflow; readBufferOverflow = -1; readBufferPos = 1; sawCR = true; } else { readBufferPos = 0; sawCR = false; } // input from a character stream. if (sourceType == INPUT_READER) { count = reader.read (readBuffer, readBufferPos, READ_BUFFER_MAX - readBufferPos); if (count < 0) readBufferLength = readBufferPos; else readBufferLength = readBufferPos + count; if (readBufferLength > 0) filterCR (count >= 0); sawCR = false; return; } // Read as many bytes as possible into the raw buffer. count = is.read (rawReadBuffer, 0, READ_BUFFER_MAX); // Dispatch to an encoding-specific reader method to populate // the readBuffer. In most parser speed profiles, these routines // show up at the top of the CPU usage chart. if (count > 0) { switch (encoding) { // one byte builtins case ENCODING_ASCII: copyIso8859_1ReadBuffer (count, (char) 0x0080); break; case ENCODING_UTF_8: copyUtf8ReadBuffer (count); break; case ENCODING_ISO_8859_1: copyIso8859_1ReadBuffer (count, (char) 0); break; // two byte builtins case ENCODING_UCS_2_12: copyUcs2ReadBuffer (count, 8, 0); break; case ENCODING_UCS_2_21: copyUcs2ReadBuffer (count, 0, 8); break; // four byte builtins case ENCODING_UCS_4_1234: copyUcs4ReadBuffer (count, 24, 16, 8, 0); break; case ENCODING_UCS_4_4321: copyUcs4ReadBuffer (count, 0, 8, 16, 24); break; case ENCODING_UCS_4_2143: copyUcs4ReadBuffer (count, 16, 24, 0, 8); break; case ENCODING_UCS_4_3412: copyUcs4ReadBuffer (count, 8, 0, 24, 16); break; } } else readBufferLength = readBufferPos; readBufferPos = 0; // Filter out all carriage returns if we've seen any // (including any saved from a previous read) if (sawCR) { filterCR (count >= 0); sawCR = false; // must actively report EOF, lest some CRs get lost. if (readBufferLength == 0 && count >= 0) readDataChunk (); } if (count > 0) currentByteCount += count; }
|
} else
|
} else {
|
private void readDataChunk () throws SAXException, IOException { int count; // See if we have any overflow (filterCR sets for CR at end) if (readBufferOverflow > -1) { readBuffer [0] = (char) readBufferOverflow; readBufferOverflow = -1; readBufferPos = 1; sawCR = true; } else { readBufferPos = 0; sawCR = false; } // input from a character stream. if (sourceType == INPUT_READER) { count = reader.read (readBuffer, readBufferPos, READ_BUFFER_MAX - readBufferPos); if (count < 0) readBufferLength = readBufferPos; else readBufferLength = readBufferPos + count; if (readBufferLength > 0) filterCR (count >= 0); sawCR = false; return; } // Read as many bytes as possible into the raw buffer. count = is.read (rawReadBuffer, 0, READ_BUFFER_MAX); // Dispatch to an encoding-specific reader method to populate // the readBuffer. In most parser speed profiles, these routines // show up at the top of the CPU usage chart. if (count > 0) { switch (encoding) { // one byte builtins case ENCODING_ASCII: copyIso8859_1ReadBuffer (count, (char) 0x0080); break; case ENCODING_UTF_8: copyUtf8ReadBuffer (count); break; case ENCODING_ISO_8859_1: copyIso8859_1ReadBuffer (count, (char) 0); break; // two byte builtins case ENCODING_UCS_2_12: copyUcs2ReadBuffer (count, 8, 0); break; case ENCODING_UCS_2_21: copyUcs2ReadBuffer (count, 0, 8); break; // four byte builtins case ENCODING_UCS_4_1234: copyUcs4ReadBuffer (count, 24, 16, 8, 0); break; case ENCODING_UCS_4_4321: copyUcs4ReadBuffer (count, 0, 8, 16, 24); break; case ENCODING_UCS_4_2143: copyUcs4ReadBuffer (count, 16, 24, 0, 8); break; case ENCODING_UCS_4_3412: copyUcs4ReadBuffer (count, 8, 0, 24, 16); break; } } else readBufferLength = readBufferPos; readBufferPos = 0; // Filter out all carriage returns if we've seen any // (including any saved from a previous read) if (sawCR) { filterCR (count >= 0); sawCR = false; // must actively report EOF, lest some CRs get lost. if (readBufferLength == 0 && count >= 0) readDataChunk (); } if (count > 0) currentByteCount += count; }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.