/** * Method that just skims * through structure of internal subset, but without doing any sort * of validation, or parsing of contents. Method may still throw an * exception, if skipping causes EOF or there's an I/O problem. * * @param srcData Link back to the input buffer shared with the owning * stream reader. */ public static void skipInternalSubset(WstxInputData srcData, WstxInputSource input, ReaderConfig cfg) throws XMLStreamException { MinimalDTDReader r = new MinimalDTDReader(input, cfg); // Need to read from same source as the master (owning stream reader) r.copyBufferStateFrom(srcData); try { r.skipInternalSubset(); } finally { /* And then need to restore changes back to srcData (line nrs etc); * effectively means that we'll stop reading internal DTD subset, * if so. */ srcData.copyBufferStateFrom(r); } }
protected void skipComment() throws XMLStreamException { skipCommentContent(); // Now, we may be getting end mark; first need second marker char:. char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c != '>') { throwParseError("String '--' not allowed in comment (missing '>'?)"); } }
while (st.hasMoreTokens()) { String str = st.nextToken(); EntityDecl ent = dtdr.findEntity(str);
private void skipDTDName() throws XMLStreamException { /*int len =*/ skipFullName(getNextChar(getErrorMsg())); /* Should we give an error about missing name? For now, * let's just exit. */ }
protected char dtdNextChar() throws XMLStreamException { return (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextChar(getErrorMsg()); }
protected char dtdNextFromCurr() throws XMLStreamException { return (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextCharFromCurrent(getErrorMsg()); }
int i = getNextAfterWS(); if (i < 0) { throwUnexpectedEOF(SUFFIX_IN_DTD_INTERNAL); skipPE(); continue; char c = getNextSkippingPEs(); if (c == '?') { // xml decl? skipPI(); } else if (c == '!') { // ignore/include, comment, declaration? c = getNextSkippingPEs(); if (c == '[') { skipComment(); } else if (c >= 'A' && c <= 'Z') { skipDeclaration(c); } else { skipDeclaration(c); throwParseError("Encountered int. subset end marker ']]>' in an expanded entity; has to be at main level."); throwUnexpectedChar(i, SUFFIX_IN_DTD_INTERNAL+"; expected a '<' to start a directive, or \"]>\" to end internal subset.");
protected char getNextSkippingPEs() throws XMLStreamException { while (true) { char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextChar(getErrorMsg()); if (c != '%') { return c; } skipPE(); } }
private void skipLiteral(char quoteChar) throws XMLStreamException { while (true) { char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c == '\n' || c == '\r') { skipCRLF(c); } else if (c == quoteChar) { break; } /* No need for specific handling for PE refs, should be ignored * just ok (plus they need to properly nested in any case) */ } }
private void skipPE() throws XMLStreamException { skipDTDName(); /* Should now get semicolon... let's try to find and skip it; but * if none found, let's not throw an exception -- we are just skipping * internal subset here. */ char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c != ';') { --mInputPtr; } }
private void skipDeclaration(char c) throws XMLStreamException { while (c != '>') { c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c == '\n' || c == '\r') { skipCRLF(c); /* No need for specific handling for PE refs; they just have * identifier that'll get properly skipped. */ /* 17-Jul-2004, TSa: But we do need to properly handle literals; * it is possible to add '>' char in entity expansion values. */ } else if (c == '\'' || c == '"') { skipLiteral(c); } } }
/** * What DTD reader returns doesn't really matter, so let's just return * perceived start location (different from what stream readers actually * do) */ public final Location getLocation() { return getStartLocation(); }
int i = getNextAfterWS(); if (i < 0) { throwUnexpectedEOF(SUFFIX_IN_DTD_INTERNAL); skipPE(); continue; char c = getNextSkippingPEs(); if (c == '?') { // xml decl? skipPI(); } else if (c == '!') { // ignore/include, comment, declaration? c = getNextSkippingPEs(); if (c == '[') { skipComment(); } else if (c >= 'A' && c <= 'Z') { skipDeclaration(c); } else { skipDeclaration(c); throwParseError("Encountered int. subset end marker ']]>' in an expanded entity; has to be at main level."); throwUnexpectedChar(i, SUFFIX_IN_DTD_INTERNAL+"; expected a '<' to start a directive, or \"]>\" to end internal subset.");
private void skipDTDName() throws XMLStreamException { /*int len =*/ skipFullName(getNextChar(getErrorMsg())); /* Should we give an error about missing name? For now, * let's just exit. */ }
protected char getNextSkippingPEs() throws XMLStreamException { while (true) { char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextChar(getErrorMsg()); if (c != '%') { return c; } skipPE(); } }
protected void skipCommentContent() throws XMLStreamException { while (true) { char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c == '-') { c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c == '-') { return; } } else if (c == '\n' || c == '\r') { skipCRLF(c); } } }
protected char dtdNextChar() throws IOException, XMLStreamException { return (mInputPtr < mInputLen) ? mInputBuffer[mInputPtr++] : getNextChar(getErrorMsg()); }
protected char dtdNextFromCurr() throws XMLStreamException { return (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : getNextCharFromCurrent(getErrorMsg()); }
private void skipPE() throws XMLStreamException { skipDTDName(); /* Should now get semicolon... let's try to find and skip it; but * if none found, let's not throw an exception -- we are just skipping * internal subset here. */ char c = (mInputPtr < mInputEnd) ? mInputBuffer[mInputPtr++] : dtdNextFromCurr(); if (c != ';') { --mInputPtr; } }
/** * What DTD reader returns doesn't really matter, so let's just return * perceived start location (different from what stream readers actually * do) */ @Override public final Location getLocation() { return getStartLocation(); }