本文整理汇总了Java中org.apache.xerces.xni.parser.XMLInputSource.getPublicId方法的典型用法代码示例。如果您正苦于以下问题:Java XMLInputSource.getPublicId方法的具体用法?Java XMLInputSource.getPublicId怎么用?Java XMLInputSource.getPublicId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xni.parser.XMLInputSource
的用法示例。
在下文中一共展示了XMLInputSource.getPublicId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveExternalSubsetAndRead
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
* <p>Attempt to locate an external subset for a document that does not otherwise
* have one. If an external subset is located, then it is scanned.</p>
*/
protected void resolveExternalSubsetAndRead()
throws IOException, XNIException {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
fDTDDescription.setRootName(fElementQName.rawname);
XMLInputSource src = fExternalSubsetResolver.getExternalSubset(fDTDDescription);
if (src != null) {
fDoctypeName = fElementQName.rawname;
fDoctypePublicId = src.getPublicId();
fDoctypeSystemId = src.getSystemId();
// call document handler
if (fDocumentHandler != null) {
// This inserts a doctypeDecl event into the stream though no
// DOCTYPE existed in the instance document.
fDocumentHandler.doctypeDecl(fDoctypeName, fDoctypePublicId, fDoctypeSystemId, null);
}
try {
if (fValidationManager == null || !fValidationManager.isCachedDTD()) {
fDTDScanner.setInputSource(src);
while (fDTDScanner.scanDTDExternalSubset(true));
}
else {
// This sends startDTD and endDTD calls down the pipeline.
fDTDScanner.setInputSource(null);
}
}
finally {
fEntityManager.setEntityHandler(XMLDocumentScannerMMImpl.this);
}
}
}
示例2: resolveExternalSubsetAndRead
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
* <p>Attempt to locate an external subset for a document that does not otherwise
* have one. If an external subset is located, then it is scanned.</p>
*/
protected void resolveExternalSubsetAndRead()
throws IOException, XNIException {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
fDTDDescription.setRootName(fElementQName.rawname);
XMLInputSource src = fExternalSubsetResolver.getExternalSubset(fDTDDescription);
if (src != null) {
fDoctypeName = fElementQName.rawname;
fDoctypePublicId = src.getPublicId();
fDoctypeSystemId = src.getSystemId();
// call document handler
if (fDocumentHandler != null) {
// This inserts a doctypeDecl event into the stream though no
// DOCTYPE existed in the instance document.
fDocumentHandler.doctypeDecl(fDoctypeName, fDoctypePublicId, fDoctypeSystemId, null);
}
try {
if (fValidationManager == null || !fValidationManager.isCachedDTD()) {
fDTDScanner.setInputSource(src);
while (fDTDScanner.scanDTDExternalSubset(true));
}
else {
// This sends startDTD and endDTD calls down the pipeline.
fDTDScanner.setInputSource(null);
}
}
finally {
fEntityManager.setEntityHandler(XMLDocumentScannerImpl.this);
}
}
}
示例3: loadGrammar
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
* Returns a Grammar object by parsing the contents of the
* entity pointed to by source.
*
* @param source the location of the entity which forms
* the starting point of the grammar to be constructed.
* @throws IOException When a problem is encountered reading the entity
* XNIException When a condition arises (such as a FatalError) that requires parsing
* of the entity be terminated.
*/
public Grammar loadGrammar(XMLInputSource source)
throws IOException, XNIException {
reset();
// First chance checking strict URI
String eid = XMLEntityManager.expandSystemId(source.getSystemId(), source.getBaseSystemId(), fStrictURI);
XMLDTDDescription desc = new XMLDTDDescription(source.getPublicId(), source.getSystemId(), source.getBaseSystemId(), eid, null);
if (!fBalanceSyntaxTrees) {
fDTDGrammar = new DTDGrammar(fSymbolTable, desc);
}
else {
fDTDGrammar = new BalancedDTDGrammar(fSymbolTable, desc);
}
fGrammarBucket = new DTDGrammarBucket();
fGrammarBucket.setStandalone(false);
fGrammarBucket.setActiveGrammar(fDTDGrammar);
// no reason to use grammar bucket's "put" method--we
// know which grammar it is, and we don't know the root name anyway...
// actually start the parsing!
try {
fDTDScanner.setInputSource(source);
fDTDScanner.scanDTDExternalSubset(true);
} catch (EOFException e) {
// expected behaviour...
}
finally {
// Close all streams opened by the parser.
fEntityManager.closeReaders();
}
if(fDTDGrammar != null && fGrammarPool != null) {
fGrammarPool.cacheGrammars(XMLDTDDescription.XML_DTD, new Grammar[] {fDTDGrammar});
}
return fDTDGrammar;
}
示例4: evaluateInputSource
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
* Immediately evaluates an input source and add the new content (e.g.
* the output written by an embedded script).
*
* @param inputSource The new input source to start evaluating.
* @see #pushInputSource(XMLInputSource)
*/
public void evaluateInputSource(XMLInputSource inputSource) {
final Scanner previousScanner = fScanner;
final short previousScannerState = fScannerState;
final CurrentEntity previousEntity = fCurrentEntity;
final Reader reader = getReader(inputSource);
String encoding = inputSource.getEncoding();
String publicId = inputSource.getPublicId();
String baseSystemId = inputSource.getBaseSystemId();
String literalSystemId = inputSource.getSystemId();
String expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
fCurrentEntity = new CurrentEntity(reader, encoding,
publicId, baseSystemId,
literalSystemId, expandedSystemId);
setScanner(fContentScanner);
setScannerState(STATE_CONTENT);
try {
do {
fScanner.scan(false);
} while (fScannerState != STATE_END_DOCUMENT);
}
catch (final IOException e) {
// ignore
}
setScanner(previousScanner);
setScannerState(previousScannerState);
fCurrentEntity = previousEntity;
}
示例5: setInputSource
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/** Sets the input source. */
public void setInputSource(XMLInputSource source) throws IOException {
// reset state
fElementCount = 0;
fElementDepth = -1;
fByteStream = null;
fCurrentEntityStack.removeAllElements();
fBeginLineNumber = 1;
fBeginColumnNumber = 1;
fBeginCharacterOffset = 0;
fEndLineNumber = fBeginLineNumber;
fEndColumnNumber = fBeginColumnNumber;
fEndCharacterOffset = fBeginCharacterOffset;
// reset encoding information
fIANAEncoding = fDefaultIANAEncoding;
fJavaEncoding = fIANAEncoding;
// get location information
String encoding = source.getEncoding();
String publicId = source.getPublicId();
String baseSystemId = source.getBaseSystemId();
String literalSystemId = source.getSystemId();
String expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
// open stream
Reader reader = source.getCharacterStream();
if (reader == null) {
InputStream inputStream = source.getByteStream();
if (inputStream == null) {
URL url = new URL(expandedSystemId);
inputStream = url.openStream();
}
fByteStream = new PlaybackInputStream(inputStream);
String[] encodings = new String[2];
if (encoding == null) {
fByteStream.detectEncoding(encodings);
}
else {
encodings[0] = encoding;
}
if (encodings[0] == null) {
encodings[0] = fDefaultIANAEncoding;
if (fReportErrors) {
fErrorReporter.reportWarning("HTML1000", null);
}
}
if (encodings[1] == null) {
encodings[1] = EncodingMap.getIANA2JavaMapping(encodings[0].toUpperCase());
if (encodings[1] == null) {
encodings[1] = encodings[0];
if (fReportErrors) {
fErrorReporter.reportWarning("HTML1001", new Object[]{encodings[0]});
}
}
}
fIANAEncoding = encodings[0];
fJavaEncoding = encodings[1];
/* PATCH: Asgeir Asgeirsson */
fIso8859Encoding = fIANAEncoding == null
|| fIANAEncoding.toUpperCase().startsWith("ISO-8859")
|| fIANAEncoding.equalsIgnoreCase(fDefaultIANAEncoding);
encoding = fIANAEncoding;
reader = new InputStreamReader(fByteStream, fJavaEncoding);
}
fCurrentEntity = new CurrentEntity(reader, encoding,
publicId, baseSystemId,
literalSystemId, expandedSystemId);
// set scanner and state
setScanner(fContentScanner);
setScannerState(STATE_START_DOCUMENT);
}
示例6: pushInputSource
import org.apache.xerces.xni.parser.XMLInputSource; //导入方法依赖的package包/类
/**
* Pushes an input source onto the current entity stack. This
* enables the scanner to transparently scan new content (e.g.
* the output written by an embedded script). At the end of the
* current entity, the scanner returns where it left off at the
* time this entity source was pushed.
* <p>
* <strong>Note:</strong>
* This functionality is experimental at this time and is
* subject to change in future releases of NekoHTML.
*
* @param inputSource The new input source to start scanning.
* @see #evaluateInputSource(XMLInputSource)
*/
public void pushInputSource(XMLInputSource inputSource) {
final Reader reader = getReader(inputSource);
fCurrentEntityStack.push(fCurrentEntity);
String encoding = inputSource.getEncoding();
String publicId = inputSource.getPublicId();
String baseSystemId = inputSource.getBaseSystemId();
String literalSystemId = inputSource.getSystemId();
String expandedSystemId = expandSystemId(literalSystemId, baseSystemId);
fCurrentEntity = new CurrentEntity(reader, encoding,
publicId, baseSystemId,
literalSystemId, expandedSystemId);
}