org.xml.sax.Parser.parse()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.xml.sax.Parser.parse()方法的一些代码示例,展示了Parser.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()方法的具体详情如下:
包路径:org.xml.sax.Parser
类名称:Parser
方法名:parse

Parser.parse介绍

[英]Parse an XML document from a system identifier (URI).

This method is a shortcut for the common case of reading a document from a system identifier. It is the exact equivalent of the following:

parse(new InputSource(systemId));

If the system identifier is a URL, it must be fully resolved by the application before it is passed to the parser.
[中]从系统标识符(URI)解析XML文档。
此方法是从系统标识符读取文档的常见情况的快捷方式。它完全等同于以下内容:

parse(new InputSource(systemId));

如果系统标识符是URL,则在将其传递给解析器之前,应用程序必须对其进行完全解析。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Parse an XML document.
 *
 * @param input An input source for the document.
 * @exception java.io.IOException If there is a problem reading
 *            the raw content of the document.
 * @exception SAXException If there is a problem
 *            processing the document.
 * @see #parse(java.lang.String)
 * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
 */
public void parse (InputSource input)
throws IOException, SAXException
{
if (parsing) {
  throw new SAXException("Parser is already in use");
}
setupParser();
parsing = true;
try {
  parser.parse(input);
} finally {
  parsing = false;
}
parsing = false;
}

代码示例来源:origin: org.apache.ant/ant

parser.setErrorHandler(hb);
  parser.setDTDHandler(hb);
  parser.parse(inputSource);
} catch (SAXParseException exc) {
  Location location = new Location(exc.getSystemId(), exc.getLineNumber(), exc

代码示例来源:origin: robovm/robovm

parser.setDTDHandler(hb);
parser.parse(is);

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Starts parsing document, that can be localized by means of uri parameter
 * @param validate 
 * @param uri adress of document, that will be parsed
 * @throws ParserConfigurationException 
 * @throws IOException 
 * @throws SAXException  */        
public void parseXML(String uri, boolean validate) throws IOException, SAXException, ParserConfigurationException, FactoryConfigurationError {
  Parser parser = getParser(validate);
  parser.parse(uri);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Starts parsing document - if you have document`s InputStream
 * @param validate 
 * @param is document`s InputStream
 * @throws ParserConfigurationException 
 * @throws IOException 
 * @throws SAXException  */                
public void parseXML(InputStream is, boolean validate) throws IOException, SAXException, ParserConfigurationException, FactoryConfigurationError {
  InputSource iSource = new InputSource(is);
  Parser parser = getParser(validate);
  parser.parse(iSource);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Starts parsing document, that can be localized by means of uri parameter
 * @param validate 
 * @param uri adress of document, that will be parsed
 * @throws ParserConfigurationException 
 * @throws IOException 
 * @throws SAXException  */        
public void parseXML(String uri, boolean validate) throws IOException, SAXException, ParserConfigurationException, FactoryConfigurationError {
  Parser parser = getParser(validate);
  parser.parse(uri);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Starts parsing document - if you have document`s InputStream
 * @param validate 
 * @param is document`s InputStream
 * @throws ParserConfigurationException 
 * @throws IOException 
 * @throws SAXException  */                
public void parseXML(InputStream is, boolean validate) throws IOException, SAXException, ParserConfigurationException, FactoryConfigurationError {
  InputSource iSource = new InputSource(is);
  Parser parser = getParser(validate);
  parser.parse(iSource);
}

代码示例来源:origin: org.w3c.jigsaw/jigsaw

XMLParser(InputStream in) 
  throws IOException, SAXException 
{
  state = IN_NOTHING;
  value = new StringBuffer();
  try {
  parser = getParser();
  parser.setDocumentHandler(this);
  } catch (Exception e) {
  e.printStackTrace();
  throw new SAXException("can't create parser ");
  }
  parser.parse(new InputSource(in));
}

代码示例来源:origin: org.w3c.jigsaw/jigsaw

protected void parse() 
throws SAXException, IOException
{
parser.setDocumentHandler(this);
parser.setErrorHandler(this);
parser.parse(new InputSource(reader));
}

代码示例来源:origin: org.w3c.jigsaw/jigsaw

protected void parse() 
throws SAXException, IOException
{
try {
  parser.setDocumentHandler(this);
  parser.setErrorHandler(this);
  parser.parse(new InputSource(reader));
} catch (IOException ex) {
  try { reader.close(); } catch (IOException ioex) {}
  throw ex;
} catch (SAXException sex) {
  try { reader.close(); } catch (IOException ioex) {}
  throw sex;
}
}

代码示例来源:origin: com.sun.org.apache.xml.internal/resolver

/** SAX Parser API.
 *
 * @see #parse(InputSource)
 */
public void parse(String systemId)
 throws IOException,
   SAXException {
 setupParse(systemId);
 try {
  parser.parse(systemId);
 } catch (InternalError ie) {
  explain(systemId);
  throw ie;
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri

/** SAX Parser API.
 *
 * @see #parse(InputSource)
 */
public void parse(String systemId)
 throws IOException,
   SAXException {
 setupParse(systemId);
 try {
  parser.parse(systemId);
 } catch (InternalError ie) {
  explain(systemId);
  throw ie;
 }
}

代码示例来源:origin: xml-resolver/xml-resolver

/** SAX Parser API.
 *
 * @see #parse(InputSource)
 */
public void parse(String systemId)
 throws IOException,
   SAXException {
 setupParse(systemId);
 try {
  parser.parse(systemId);
 } catch (InternalError ie) {
  explain(systemId);
  throw ie;
 }
}

代码示例来源:origin: org.codehaus.castor/castor-xml

protected void readSearchDescriptor(Parser parser, InputSource input)
  throws IOException, SAXException {
 SearchDescriptor desc;
 desc = new SearchDescriptor();
 parser.setDocumentHandler(desc);
 parser.parse(input);
 setSearchDescriptor(desc);
}

代码示例来源:origin: org.codehaus.castor/castor-xml

protected void readImportDescriptor(Parser parser, InputSource input)
  throws IOException, SAXException {
 ImportDescriptor desc;
 desc = new ImportDescriptor();
 parser.setDocumentHandler(desc);
 parser.parse(input);
 setImportDescriptor(desc);
}

代码示例来源:origin: org.fudaa.business/fudaa-common-corba

/**
 * Creates a new KOMLParser.
 * Use the system property org.xml.sax.parser to change the parser.
 *
 * @param in an XML inputstream
 */
public void read(InputStream in) 
  throws SAXException, IOException {
getObjectOuputHandler().writeStartDocument();
parser.parse(new InputSource(in));
getObjectOuputHandler().writeEndDocument();
}

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

protected void readSearchDescriptor( Parser parser, InputSource input )
throws IOException, SAXException
{
SearchDescriptor desc;
desc = new SearchDescriptor();
parser.setDocumentHandler( desc );
parser.parse( input );
setSearchDescriptor( desc );
}

代码示例来源:origin: org.codehaus.castor/com.springsource.org.castor

protected void readImportDescriptor( Parser parser, InputSource input )
throws IOException, SAXException
{
ImportDescriptor desc;
desc = new ImportDescriptor();
parser.setDocumentHandler( desc );
parser.parse( input );
setImportDescriptor( desc );
}

代码示例来源:origin: org.codehaus.castor/castor-xml-schema

protected void parseSchema(Parser parser, SchemaUnmarshaller schemaUnmarshaller, URILocation uri,
  String schemaLocation, String reason) throws SchemaException {
 Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
 parser.setDocumentHandler(handler);
 parser.setErrorHandler(handler);
 try {
  InputSource source = new InputSource(uri.getReader());
  source.setSystemId(uri.getAbsoluteURI());
  parser.parse(source);
 } catch (java.io.IOException ioe) {
  throw new SchemaException("Error reading " + reason + " file '" + schemaLocation + "'");
 } catch (org.xml.sax.SAXException sx) {
  throw new SchemaException(sx);
 }
}

代码示例来源:origin: org.codehaus.castor/castor-xml

public void importDocument(Parser parser, InputSource input) throws ImportExportException {
 Consumer consumer;
 consumer = createConsumer();
 parser.setDocumentHandler(consumer);
 try {
  parser.parse(input);
 } catch (SAXException except) {
  throw new ImportExportException(except);
 } catch (IOException except) {
  throw new ImportExportException(except);
 }
 if (consumer.getResults() != null) {
  importEntries(consumer.getResults());
 }
}

相关文章