本文整理匯總了Java中javax.xml.parsers.ParserConfigurationException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java ParserConfigurationException.getMessage方法的具體用法?Java ParserConfigurationException.getMessage怎麽用?Java ParserConfigurationException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.parsers.ParserConfigurationException
的用法示例。
在下文中一共展示了ParserConfigurationException.getMessage方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: InstanceCreator
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public InstanceCreator(InputStream in) {
try {
this.relations = new HashMap<Relation,Set<List<String>>>();
this.atoms = new LinkedHashSet<String>();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
this.document = builder.parse(in);
} catch (SAXException sxe) {
// Error generated during parsing
Exception x = sxe;
if (sxe.getException() != null)
x = sxe.getException();
throw new InstanceCreationException("Error generated during parsing: " + x.getMessage());
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
throw new InstanceCreationException("Parser with specified options cannot be built: " + pce.getMessage());
} catch (IOException ioe) {
// I/O error
throw new InstanceCreationException("I/O error: " + ioe.getMessage());
} finally {
try {
in.close();
} catch (IOException e) {
// ignore
}
}
}
示例2: parse
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public void parse( InputSource source, ContentHandler handler,
ErrorHandler errorHandler, EntityResolver entityResolver )
throws SAXException, IOException {
try {
SAXParser saxParser = allowFileAccess(factory.newSAXParser(), false);
XMLReader reader = new XMLReaderEx(saxParser.getXMLReader());
reader.setContentHandler(handler);
if(errorHandler!=null)
reader.setErrorHandler(errorHandler);
if(entityResolver!=null)
reader.setEntityResolver(entityResolver);
reader.parse(source);
} catch( ParserConfigurationException e ) {
// in practice this won't happen
SAXParseException spe = new SAXParseException(e.getMessage(),null,e);
errorHandler.fatalError(spe);
throw spe;
}
}
示例3: XmlDoc
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* Create a new XML doc with root element.
*
* @param rootName - the tagName of the root element
*/
public XmlDoc( String rootName )
{
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance( );
DocumentBuilder db = null;
try
{
db = dbf.newDocumentBuilder( );
}
catch ( ParserConfigurationException e )
{
logger.log(""+e);
throw new TestCaseFailure(e.getMessage());
}
Doc = db.newDocument( );
final Element root = Doc.createElement( rootName );
Doc.appendChild( root );
}
示例4: newXMLDocument
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* 初始化一個空Document對象返回。
*
* @return a Document
*/
public static Document newXMLDocument() {
try {
return newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e.getMessage());
}
}
示例5: createDocument
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* @return New XML document from the default document builder factory.
*/
private static Document createDocument()
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try
{
builder = factory.newDocumentBuilder();
}
catch (ParserConfigurationException e)
{
throw new RuntimeException(e.getMessage(), e);
}
return builder.newDocument();
}
示例6: DSchemaBuilderImpl
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
public DSchemaBuilderImpl() {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
this.dom = dbf.newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
// impossible
throw new InternalError(e.getMessage());
}
}
示例7: parse
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* Parses the given document and add it to the DOM forest.
*
* @return null if there was a parse error. otherwise non-null.
*/
private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{
Document dom = documentBuilder.newDocument();
systemId = normalizeSystemId(systemId);
// put into the map before growing a tree, to
// prevent recursive reference from causing infinite loop.
core.put(systemId, dom);
dom.setDocumentURI(systemId);
if (root)
rootDocuments.add(systemId);
try {
XMLReader reader = createReader(dom);
InputStream is = null;
if(inputSource.getByteStream() == null){
inputSource = entityResolver.resolveEntity(null, systemId);
}
reader.parse(inputSource);
Element doc = dom.getDocumentElement();
if (doc == null) {
return null;
}
NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema");
for (int i = 0; i < schemas.getLength(); i++) {
inlinedSchemaElements.add((Element) schemas.item(i));
}
} catch (ParserConfigurationException e) {
errorReceiver.error(e);
throw new SAXException(e.getMessage());
}
resolvedCache.put(systemId, dom.getDocumentURI());
return dom;
}
示例8: createDocument
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* @return New XML document from the default document builder factory.
*/
private static Document createDocument() {
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e.getMessage(), e);
}
return builder.newDocument();
}
示例9: processSheet
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
/**
* Parses and shows the content of one sheet using the specified styles and
* shared-strings tables.
*
* @param styles
* @param strings
* @param sheetInputStream
*/
public void processSheet(StylesTable styles, ReadOnlySharedStringsTable strings, SheetContentsHandler sheetHandler,
InputStream sheetInputStream) throws IOException, ParserConfigurationException, SAXException {
DataFormatter formatter = new DataFormatter();
InputSource sheetSource = new InputSource(sheetInputStream);
try {
XMLReader sheetParser = SAXHelper.newXMLReader();
ContentHandler handler = new XSSFSheetXMLHandler(styles, null, strings, sheetHandler, formatter, false);
sheetParser.setContentHandler(handler);
sheetParser.parse(sheetSource);
} catch (ParserConfigurationException e) {
throw new RuntimeException("SAX parser appears to be broken - " + e.getMessage());
}
}
示例10: objectToElement
import javax.xml.parsers.ParserConfigurationException; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> Element objectToElement(Object objeto, Class<T> classe, String qName ) throws CteException {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
JAXB.marshal(new JAXBElement(new QName(qName), classe, objeto), new DOMResult(document));
return document.getDocumentElement();
} catch (ParserConfigurationException e) {
throw new CteException("Erro Ao Converter Objeto em Elemento: "+e.getMessage());
}
}