本文整理了Java中org.xml.sax.Parser.setEntityResolver()
方法的一些代码示例,展示了Parser.setEntityResolver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.setEntityResolver()
方法的具体详情如下:
包路径:org.xml.sax.Parser
类名称:Parser
方法名:setEntityResolver
[英]Allow an application to register a custom entity resolver.
If the application does not register an entity resolver, the SAX parser will resolve system identifiers and open connections to entities itself (this is the default behaviour implemented in HandlerBase).
Applications may register a new or different entity resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.
[中]允许应用程序注册自定义实体解析器。
如果应用程序未注册实体解析器,SAX解析器将解析系统标识符并打开与实体本身的连接(这是HandlerBase中实现的默认行为)。
应用程序可以在解析过程中登记新的或不同的实体解析器,并且SAX解析器必须立即开始使用新的解析器。
代码示例来源:origin: org.apache.ant/ant
HandlerBase hb = new RootHandler(this);
parser.setDocumentHandler(hb);
parser.setEntityResolver(hb);
parser.setErrorHandler(hb);
parser.setDTDHandler(hb);
代码示例来源:origin: robovm/robovm
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: robovm/robovm
if (hb != null) {
parser.setDocumentHandler(hb);
parser.setEntityResolver(hb);
parser.setErrorHandler(hb);
parser.setDTDHandler(hb);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide-loaders
/** Factory SAX parser that can be used to parse XML files.
* The factory is created according to javax.xml.parsers.SAXParserFactory property.
* The parser has set entity resolver to system entity resolver chain.
* @param validate if true validating parser is returned
* @throws FactoryConfigurationError
* @return sax parser or null if no parser can be created
* @deprecated Use {@link XMLUtil#createXMLReader(boolean,boolean ) Util} instead
* setting ns to false.
* For more details see {@link #createParser() createParser}
*/
public static Parser createParser (boolean validate) {
Parser parser = XMLDataObjectImpl.makeParser(validate);
parser.setEntityResolver(getChainingEntityResolver());
return parser;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
代码示例来源:origin: org.apache.xml/com.springsource.org.apache.xml.resolver
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
代码示例来源:origin: xml-resolver/xml-resolver
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
代码示例来源:origin: com.sun.org.apache.xml.internal/resolver
/** Setup for parsing. */
private void setupParse(String systemId) {
allowXMLCatalogPI = true;
parser.setEntityResolver(this);
parser.setDocumentHandler(this);
parser.setDTDHandler(this);
URL cwd = null;
try {
cwd = FileURL.makeURL("basename");
} catch (MalformedURLException mue) {
cwd = null;
}
try {
baseURL = new URL(systemId);
} catch (MalformedURLException mue) {
if (cwd != null) {
try {
baseURL = new URL(cwd, systemId);
} catch (MalformedURLException mue2) {
// give up
baseURL = null;
}
} else {
// give up
baseURL = null;
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
private Parser getParser(boolean validate) throws SAXException, ParserConfigurationException, FactoryConfigurationError {
Parser parser;
parser = new XMLReaderAdapter (XMLUtil.createXMLReader(validate));
// create document handler and register it
//parser.setEntityResolver(entityRes);
parser.setEntityResolver(this);
parser.setDocumentHandler(this);//before new InnerParser() - now this
parser.setErrorHandler(this);
return parser;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
private Parser getParser(boolean validate) throws SAXException, ParserConfigurationException, FactoryConfigurationError {
Parser parser;
parser = new XMLReaderAdapter (XMLUtil.createXMLReader(validate));
// create document handler and register it
//parser.setEntityResolver(entityRes);
parser.setEntityResolver(this);
parser.setDocumentHandler(this);//before new InnerParser() - now this
parser.setErrorHandler(this);
return parser;
}
代码示例来源:origin: ibinti/bugvm
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-rt
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: MobiVM/robovm
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: uk.org.ponder.rsf/rsf-core-ponderutilcore
private Object produceSubtreeInternal(Object rootobj, InputSource i) {
parserstash.setDocumentHandler(this);
parserstash.setEntityResolver(this);
try {
rootobjstash = rootobj;
parserstash.parse(i); // begin to parse at this point, asynchronous events arrive
}
catch (SAXParseException spe) {
throw UniversalRuntimeException.accumulate(spe, "SaxParseException occured at line "
+ spe.getLineNumber()
+ " column number "
+ spe.getColumnNumber());
}
catch (Exception e) {
throw UniversalRuntimeException.accumulate(e, "Error parsing XML document");
}
finally {
saxer.blastState();
if (callback != null) {
callback.parseComplete(callbackindex);
callback = null;
}
}
return rootobjstash;
}
代码示例来源:origin: javax.xml.parsers/jaxp-api
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: com.bugvm/bugvm-rt
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: com.gluonhq/robovm-rt
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: FlexoVM/flexovm
/**
* Initialize the parser before each run.
*/
private void setupParser ()
{
// catch an illegal "nonsense" state.
if (!prefixes && !namespaces)
throw new IllegalStateException ();
nsSupport.reset();
if (uris)
nsSupport.setNamespaceDeclUris (true);
if (entityResolver != null) {
parser.setEntityResolver(entityResolver);
}
if (dtdHandler != null) {
parser.setDTDHandler(dtdHandler);
}
if (errorHandler != null) {
parser.setErrorHandler(errorHandler);
}
parser.setDocumentHandler(this);
locator = null;
}
代码示例来源:origin: MobiVM/robovm
if (hb != null) {
parser.setDocumentHandler(hb);
parser.setEntityResolver(hb);
parser.setErrorHandler(hb);
parser.setDTDHandler(hb);
内容来源于网络,如有侵权,请联系作者删除!