Java Code Examples for javax.xml.parsers.ParserConfigurationException
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project BBC-News-Reader, under directory /src/org/mcsoxford/rss/.
Source file: RSSParser.java

/** * Parses input stream as RSS feed. It is the responsibility of the caller to close the RSS feed input stream. * @param feed RSS 2.0 feed input stream * @return in-memory representation of RSS feed * @throws RSSFault if an unrecoverable parse error occurs */ public RSSFeed parse(InputStream feed){ try { final SAXParserFactory factory=SAXParserFactory.newInstance(); factory.setFeature("http://xml.org/sax/features/namespaces",false); factory.setFeature("http://xml.org/sax/features/namespace-prefixes",true); final SAXParser parser=factory.newSAXParser(); return parse(parser,feed); } catch ( ParserConfigurationException e) { throw new RSSFault(e); } catch ( SAXException e) { throw new RSSFault(e); } catch ( IOException e) { throw new RSSFault(e); } }
Example 2
From project addis, under directory /application/src/main/java/org/drugis/addis/imports/.
Source file: PubMedIDRetriever.java

public static Document parse(InputStream is) throws IOException { DocumentBuilderFactory domFactory=DocumentBuilderFactory.newInstance(); domFactory.setValidating(false); domFactory.setNamespaceAware(false); domFactory.setIgnoringElementContentWhitespace(true); DocumentBuilder builder=null; try { builder=domFactory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new RuntimeException(e); } Document ret; try { ret=builder.parse(is); } catch ( SAXException e) { throw new ParseException("Error parsing PubMed response",e); } return ret; }
Example 3
From project adt-maven-plugin, under directory /src/main/java/com/yelbota/plugins/adt/model/.
Source file: AneModel.java

private void parseXml(byte[] s) throws MojoFailureException { DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); try { DocumentBuilder db=dbf.newDocumentBuilder(); Document dom=db.parse(new InputSource(new ByteArrayInputStream(s))); NodeList nl=dom.getDocumentElement().getChildNodes(); for (int i=0; i < nl.getLength(); i++) { Object uel=nl.item(i); if (uel instanceof Element) { Element el=(Element)uel; String nodeName=el.getNodeName(); if (nodeName.equals("id")) id=el.getTextContent(); } } } catch ( ParserConfigurationException e) { throwParseFail(file,e); } catch ( SAXException e) { throwParseFail(file,e); } catch ( IOException e) { throwParseFail(file,e); } }
Example 4
From project agile, under directory /agile-framework/src/main/java/org/apache/catalina/servlets/.
Source file: WebdavServlet.java

/** * Return JAXP document builder instance. */ protected DocumentBuilder getDocumentBuilder() throws ServletException { DocumentBuilder documentBuilder=null; DocumentBuilderFactory documentBuilderFactory=null; try { documentBuilderFactory=DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setExpandEntityReferences(false); documentBuilder=documentBuilderFactory.newDocumentBuilder(); documentBuilder.setEntityResolver(new WebdavResolver(this.getServletContext())); } catch ( ParserConfigurationException e) { throw new ServletException("JAXP initialization failed"); } return documentBuilder; }
Example 5
public void readTerritoriesXML() throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder=dbFactory.newDocumentBuilder(); Document doc; doc=dBuilder.parse(getClass().getResourceAsStream("/got/resource/xml/territory.xml")); doc.getDocumentElement().normalize(); NodeList nList=doc.getElementsByTagName("Territory"); for (int temp=0; temp < nList.getLength(); temp++) { TerritoryInfo ti=new TerritoryInfo(); Node nNode=nList.item(temp); String name=nNode.getAttributes().getNamedItem("Name").getNodeValue(); String mustering=nNode.getAttributes().getNamedItem("Mustering").getNodeValue(); String supply=nNode.getAttributes().getNamedItem("Supply").getNodeValue(); String power=nNode.getAttributes().getNamedItem("Power").getNodeValue(); String port=nNode.getAttributes().getNamedItem("Port").getNodeValue(); String type=nNode.getAttributes().getNamedItem("Type").getNodeValue(); ti.setName(name); ti.setMustering(Integer.valueOf(mustering)); ti.setSupply(Integer.valueOf(supply)); ti.setPower(Integer.valueOf(power)); ti.setType(TerritoryType.values()[Integer.valueOf(type)]); ti.setAction(Action.NONE); for ( Arm arm : Arm.values()) { ti.getConquerArms().put(arm,0); } getTerrMap().put(ti.getName(),ti); getConnTerritories().put(ti.getName(),new ArrayList<String>()); } }
Example 6
From project Airports, under directory /src/com/nadmm/airports/wx/.
Source file: MetarParser.java

public ArrayList<Metar> parse(File xmlFile,ArrayList<String> stationIds) throws ParserConfigurationException, SAXException, IOException { mFetchTime=xmlFile.lastModified(); InputSource input=new InputSource(new FileReader(xmlFile)); SAXParserFactory factory=SAXParserFactory.newInstance(); SAXParser parser=factory.newSAXParser(); MetarHandler handler=new MetarHandler(); XMLReader xmlReader=parser.getXMLReader(); xmlReader.setContentHandler(handler); xmlReader.parse(input); ArrayList<Metar> metars=new ArrayList<Metar>(mMetars.values()); for ( String stationId : stationIds) { if (!mMetars.containsKey(stationId)) { Metar metar=new Metar(); metar.stationId=stationId; metar.fetchTime=mFetchTime; metars.add(metar); } } return metars; }
Example 7
From project amplafi-sworddance, under directory /src/main/java/com/sworddance/util/.
Source file: AbstractXmlParser.java

/** * @return */ protected DocumentBuilder createDocumentBuilder(){ try { return DOCUMENT_BUILDER_FACTORY.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new ApplicationGeneralException(e); } }
Example 8
From project and-bible, under directory /IgnoreAndBibleExperiments/experiments/.
Source file: SwordApi.java

/** * top level method to fetch html from the raw document data * @param book * @param key * @param maxKeyCount * @return * @throws NoSuchKeyException * @throws BookException * @throws IOException * @throws SAXException * @throws URISyntaxException * @throws ParserConfigurationException */ public FormattedDocument readHtmlText(Book book,Key key,int maxKeyCount) throws NoSuchKeyException, BookException, IOException, SAXException, URISyntaxException, ParserConfigurationException { FormattedDocument retVal=new FormattedDocument(); if (!book.contains(key)) { retVal.setHtmlPassage("Not found in document"); } else { if ("OSIS".equals(book.getBookMetaData().getProperty("SourceType")) && "zText".equals(book.getBookMetaData().getProperty("ModDrv"))) { retVal=readHtmlTextOptimizedZTextOsis(book,key,maxKeyCount); } else { retVal=readHtmlTextStandardJSwordMethod(book,key,maxKeyCount); } } return retVal; }
Example 9
From project android-client_1, under directory /src/com/googlecode/asmack/.
Source file: XMLUtils.java

/** * Turn an XML String into a DOM. * @param xml The xml String. * @return A XML Document. * @throws SAXException In case of invalid XML. */ public static Document getDocument(String xml) throws SAXException { try { DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); return documentBuilder.parse(new InputSource(new StringReader(xml))); } catch ( ParserConfigurationException e) { throw new IllegalStateException("Parser not configured",e); } catch ( IOException e) { throw new IllegalStateException("IOException on read-from-memory",e); } }
Example 10
From project android-rackspacecloud, under directory /src/com/rackspace/cloud/servers/api/client/.
Source file: FlavorManager.java

public ArrayList<Flavor> createList(boolean detail,Context context){ CustomHttpClient httpclient=new CustomHttpClient(context); HttpGet get=new HttpGet(Account.getAccount().getServerUrl() + "/flavors/detail.xml?now=cache_time2"); ArrayList<Flavor> flavors=new ArrayList<Flavor>(); get.addHeader("X-Auth-Token",Account.getAccount().getAuthToken()); try { HttpResponse resp=httpclient.execute(get); BasicResponseHandler responseHandler=new BasicResponseHandler(); String body=responseHandler.handleResponse(resp); if (resp.getStatusLine().getStatusCode() == 200 || resp.getStatusLine().getStatusCode() == 203) { FlavorsXMLParser flavorsXMLParser=new FlavorsXMLParser(); SAXParser saxParser=SAXParserFactory.newInstance().newSAXParser(); XMLReader xmlReader=saxParser.getXMLReader(); xmlReader.setContentHandler(flavorsXMLParser); xmlReader.parse(new InputSource(new StringReader(body))); flavors=flavorsXMLParser.getFlavors(); } } catch ( ClientProtocolException cpe) { } catch ( IOException e) { } catch ( ParserConfigurationException e) { } catch ( SAXException e) { } catch ( FactoryConfigurationError e) { } return flavors; }
Example 11
From project android-rss, under directory /src/main/java/org/mcsoxford/rss/.
Source file: RSSParser.java

/** * Parses input stream as RSS feed. It is the responsibility of the caller to close the RSS feed input stream. * @param feed RSS 2.0 feed input stream * @return in-memory representation of RSS feed * @throws RSSFault if an unrecoverable parse error occurs */ @Override public RSSFeed parse(InputStream feed){ try { final SAXParserFactory factory=SAXParserFactory.newInstance(); factory.setFeature("http://xml.org/sax/features/namespaces",false); factory.setFeature("http://xml.org/sax/features/namespace-prefixes",true); final SAXParser parser=factory.newSAXParser(); return parse(parser,feed); } catch ( ParserConfigurationException e) { throw new RSSFault(e); } catch ( SAXException e) { throw new RSSFault(e); } catch ( IOException e) { throw new RSSFault(e); } }
Example 12
From project android-thaiime, under directory /makedict/src/com/android/inputmethod/latin/.
Source file: DictionaryMaker.java

/** * Invoke the right input method according to args. * @param args the parsed command line arguments. * @return the read dictionary. */ private static FusionDictionary readInputFromParsedArgs(final Arguments args) throws IOException, UnsupportedFormatException, ParserConfigurationException, SAXException, FileNotFoundException { if (null != args.mInputBinary) { return readBinaryFile(args.mInputBinary); } else if (null != args.mInputUnigramXml) { return readXmlFile(args.mInputUnigramXml,args.mInputBigramXml); } else { throw new RuntimeException("No input file specified"); } }
Example 13
/** * Instantiates a new xml dom. * @param is Raw XML. * @throws SAXException the SAX exception */ public XmlDom(InputStream is) throws SAXException { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder=factory.newDocumentBuilder(); Document doc=builder.parse(is); this.root=(Element)doc.getDocumentElement(); } catch ( ParserConfigurationException e) { } catch ( IOException e) { throw new SAXException(e); } }
Example 14
From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.
Source file: ServerConfigParser.java

public List load(InputStream ins) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); DocumentBuilder db=dbf.newDocumentBuilder(); Document doc=db.parse(ins); return loadConnectors(doc); }
Example 15
From project android_packages_inputmethods_LatinIME, under directory /tools/makedict/src/com/android/inputmethod/latin/.
Source file: DictionaryMaker.java

/** * Invoke the right input method according to args. * @param args the parsed command line arguments. * @return the read dictionary. */ private static FusionDictionary readInputFromParsedArgs(final Arguments args) throws IOException, UnsupportedFormatException, ParserConfigurationException, SAXException, FileNotFoundException { if (null != args.mInputBinary) { return readBinaryFile(args.mInputBinary); } else if (null != args.mInputUnigramXml) { return readXmlFile(args.mInputUnigramXml,args.mInputBigramXml); } else { throw new RuntimeException("No input file specified"); } }
Example 16
From project any23, under directory /core/src/test/java/org/apache/any23/extractor/html/.
Source file: DomUtilsTest.java

@Test public void testSerializeToXML() throws ParserConfigurationException, TransformerException, IOException { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); DocumentBuilder builder=factory.newDocumentBuilder(); DOMImplementation impl=builder.getDOMImplementation(); Document doc=impl.createDocument(null,null,null); Node n1=doc.createElement("DIV"); Node n2=doc.createElement("SPAN"); Node n3=doc.createElement("P"); n1.setTextContent("Content 1"); n2.setTextContent("Content 2"); n3.setTextContent("Content 3"); n1.appendChild(n2); n2.appendChild(n3); doc.appendChild(n1); Assert.assertEquals("<DIV>Content 1<SPAN>Content 2<P>Content 3</P></SPAN></DIV>",DomUtils.serializeToXML(doc,false)); }
Example 17
private Document readIdeaFile(@NotNull File ideaFile,final String defaultTemplate){ Document result=null; try { DocumentBuilder reader=DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputStream is; if (!env.forceBuild() && ideaFile.exists()) { is=new FileInputStream(ideaFile); } else if (template != null && template.exists()) { is=new FileInputStream(template); } else { is=getClass().getResourceAsStream(defaultTemplate); } result=reader.parse(is); } catch ( ParserConfigurationException e) { env.handle(e); } catch ( IOException e) { env.handle(e); } catch ( SAXException e) { env.handle(e); } return result; }
Example 18
From project apps-for-android, under directory /CLiCkin2DaBeaT/src/com/google/clickin2dabeat/.
Source file: C2B.java

private void loadC2B(String fileUriString){ try { FileInputStream fis=new FileInputStream(fileUriString); DocumentBuilder docBuild; docBuild=DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document c2b=docBuild.parse(fis); runC2B(c2b); } catch ( FileNotFoundException e) { e.printStackTrace(); } catch ( ParserConfigurationException e) { e.printStackTrace(); } catch ( FactoryConfigurationError e) { e.printStackTrace(); } catch ( SAXException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); } }
Example 19
From project aranea, under directory /server/src/main/java/no/dusken/aranea/admin/control/.
Source file: ImportStvMediaController.java

private Document parseXmlFile(File file){ Document dom=null; DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); try { DocumentBuilder db=dbf.newDocumentBuilder(); dom=db.parse(file); } catch ( ParserConfigurationException pce) { pce.printStackTrace(); } catch ( SAXException se) { se.printStackTrace(); } catch ( IOException ioe) { ioe.printStackTrace(); } return dom; }
Example 20
From project Archimedes, under directory /br.org.archimedes.io.xml/src/br/org/archimedes/io/xml/parsers/.
Source file: XMLParser.java

/** * @param xmlInputStream The file to be parsed * @return The document */ private Document getDocument(InputStream xmlInputStream){ DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder=null; try { docBuilder=docBuilderFactory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { e.printStackTrace(); } Document doc=null; try { doc=docBuilder.parse(xmlInputStream); doc.normalize(); } catch ( SAXException e) { } catch ( IOException e) { } return doc; }
Example 21
From project arquillian-extension-persistence, under directory /impl/src/main/java/org/jboss/arquillian/persistence/core/configuration/.
Source file: PersistenceDescriptorParser.java

public String obtainDataSourceName(final String descriptor){ try { final Document document=factory.newDocumentBuilder().parse(new ByteArrayInputStream(descriptor.getBytes())); final NodeList persistenceUnits=document.getElementsByTagName("persistence-unit"); if (persistenceUnits.getLength() > 1) { throw new MultiplePersistenceUnitsException("Multiple persistence units defined. Please specify default data source either in 'arquillian.xml' or by using @DataSource annotation"); } final Node persistenceUnit=persistenceUnits.item(0); Node dataSource=getJtaDataSource(persistenceUnit); if (dataSource == null) { dataSource=getNonJtaDataSource(persistenceUnit); } return dataSource.getTextContent(); } catch ( SAXException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } catch ( IOException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } catch ( ParserConfigurationException e) { throw new PersistenceDescriptorParsingException("Unable to parse descriptor " + descriptor,e); } }
Example 22
From project as3-commons-jasblocks, under directory /src/main/java/org/as3commons/asblocks/impl/.
Source file: SWCResourceRoot.java

public SWCResourceRoot(File path) throws IOException { this.path=path; ZipFile zip=new ZipFile(path.getAbsolutePath()); try { ZipEntry entry=zip.getEntry(CATALOG_FILENAME); if (entry == null) { throw new IllegalArgumentException("No " + CATALOG_FILENAME + " in swc: "+ path.getAbsolutePath()); } qnames=readCatalog(zip.getInputStream(entry)); } catch ( ParserConfigurationException e) { throw new IOException(e.toString()); } catch ( SAXException e) { throw new IOException(e.toString()); } catch ( XPathExpressionException e) { throw new IOException(e.toString()); } finally { zip.close(); } }
Example 23
From project AsmackService, under directory /src/com/googlecode/asmack/.
Source file: XMLUtils.java

/** * Turn an XML String into a DOM. * @param xml The xml String. * @return A XML Document. * @throws SAXException In case of invalid XML. */ public static Document getDocument(String xml) throws SAXException { try { DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); return documentBuilder.parse(new InputSource(new StringReader(xml))); } catch ( ParserConfigurationException e) { throw new IllegalStateException("Parser not configured",e); } catch ( IOException e) { throw new IllegalStateException("IOException on read-from-memory",e); } }
Example 24
From project AudioBox.fm-JavaLib, under directory /audiobox.fm-core/src/main/java/fm/audiobox/configurations/.
Source file: DefaultResponseParser.java

@Override public void parseAsXml(InputStream inputStream,IEntity destEntity) throws ServiceException { try { SAXParserFactory spf=SAXParserFactory.newInstance(); SAXParser sp=spf.newSAXParser(); XMLReader xr=sp.getXMLReader(); xr.setContentHandler(new XmlParser(destEntity)); xr.parse(new InputSource(inputStream)); } catch ( ParserConfigurationException e) { log.error("An error occurred while instantiating XML Parser",e); throw new ServiceException(ServiceException.GENERIC_ERROR,e.getMessage()); } catch ( SAXException e) { log.error("An error occurred while instantiating XML Parser",e); throw new ServiceException(ServiceException.GENERIC_ERROR,e.getMessage()); } catch ( IllegalStateException e) { log.error("An error occurred while parsing response",e); throw new ServiceException(ServiceException.GENERIC_ERROR,e.getMessage()); } catch ( IOException e) { log.error("An error occurred while parsing response",e); throw new ServiceException(ServiceException.GENERIC_ERROR,e.getMessage()); } }
Example 25
From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/coreutils/.
Source file: XMLUtil.java

/** * Loads XML files from disk * @param clazz the class this method is invoked from * @param xmlPath the full path to the file to load * @param xsdPath the full path to the file to validate against */ public static Document loadDoc(Class clazz,String xmlPath,String xsdPath){ DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance(); Document ret=null; try { DocumentBuilder builder=builderFactory.newDocumentBuilder(); ret=builder.parse(new FileInputStream(xmlPath)); } catch ( ParserConfigurationException e) { Logger.getLogger(clazz.getName()).log(Level.SEVERE,"Error loading XML file: can't initialize parser.",e); } catch ( SAXException e) { Logger.getLogger(clazz.getName()).log(Level.SEVERE,"Error loading XML file: can't parse XML.",e); } catch ( IOException e) { Logger.getLogger(clazz.getName()).log(Level.SEVERE,"Error loading XML file: can't read file.",e); } if (!XMLUtil.xmlIsValid(ret,clazz,xsdPath)) { Logger.getLogger(clazz.getName()).log(Level.SEVERE,"Error loading XML file: could not validate against [" + xsdPath + "], results may not be accurate"); } return ret; }
Example 26
From project azure-sdk-for-java-samples, under directory /WAAD.WebSSO.JAVA/java/code/libraries/waad-federation/src/main/java/com/microsoft/samples/federation/.
Source file: SamlTokenValidator.java

private static SignableSAMLObject getSamlTokenFromSamlResponse(String samlResponse) throws ParserConfigurationException, SAXException, IOException, UnmarshallingException { Document document=getDocument(samlResponse); Unmarshaller unmarshaller=Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()); org.opensaml.saml2.core.Response response=(org.opensaml.saml2.core.Response)unmarshaller.unmarshall(document.getDocumentElement()); SignableSAMLObject samlToken=(SignableSAMLObject)response.getAssertions().get(0); return samlToken; }
Example 27
From project bbb-java, under directory /src/main/java/org/mconf/bbb/api/.
Source file: JoinedMeeting.java

public void parse(String str) throws UnsupportedEncodingException, SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); DocumentBuilder db=dbf.newDocumentBuilder(); Document doc=db.parse(new ByteArrayInputStream(str.getBytes("UTF-8"))); doc.getDocumentElement().normalize(); Element nodeResponse=(Element)doc.getElementsByTagName("response").item(0); returncode=ParserUtils.getNodeValue(nodeResponse,"returncode"); if (returncode.equals("SUCCESS")) { fullname=ParserUtils.getNodeValue(nodeResponse,"fullname"); confname=ParserUtils.getNodeValue(nodeResponse,"confname"); meetingID=ParserUtils.getNodeValue(nodeResponse,"meetingID"); externUserID=ParserUtils.getNodeValue(nodeResponse,"externUserID"); role=ParserUtils.getNodeValue(nodeResponse,"role"); conference=ParserUtils.getNodeValue(nodeResponse,"conference"); room=ParserUtils.getNodeValue(nodeResponse,"room"); voicebridge=ParserUtils.getNodeValue(nodeResponse,"voicebridge"); webvoiceconf=ParserUtils.getNodeValue(nodeResponse,"webvoiceconf"); mode=ParserUtils.getNodeValue(nodeResponse,"mode"); record=ParserUtils.getNodeValue(nodeResponse,"record"); welcome=ParserUtils.getNodeValue(nodeResponse,"welcome"); server=ParserUtils.getNodeValue(nodeResponse,"server"); } else { message=ParserUtils.getNodeValue(nodeResponse,"message"); } }
Example 28
From project BDSup2Sub, under directory /src/main/java/bdsup2sub/supstream/bdnxml/.
Source file: SupXml.java

/** * Constructor (for reading) * @param fn file name of Xml file to read * @throws CoreException */ public SupXml(String fn) throws CoreException { this.pathName=FilenameUtils.addSeparator(FilenameUtils.getParent(fn)); this.title=FilenameUtils.removeExtension(FilenameUtils.getName(fn)); SAXParserFactory factory=SAXParserFactory.newInstance(); SAXParser saxParser; try { saxParser=factory.newSAXParser(); DefaultHandler handler=new XmlHandler(); saxParser.parse(new File(fn),handler); } catch ( ParserConfigurationException e) { throw new CoreException(e.getMessage()); } catch ( SAXException e) { throw new CoreException(e.getMessage()); } catch ( IOException e) { throw new CoreException(e.getMessage()); } logger.trace("\nDetected " + numForcedFrames + " forced captions.\n"); }
Example 29
From project beam-third-party, under directory /beam-meris-veg/src/main/java/org/esa/beam/processor/baer/auxdata/.
Source file: AerPhaseLoader.java

/** * Loads the aux data file associated to the aerosol phase function coefficients. */ public void load(String auxPath) throws IOException { Guardian.assertNotNull("auxPath",auxPath); _logger.info("Reading auxiliary data file: '" + auxPath + "'"); _filePath=auxPath; try { parseFile(new URL("file","",auxPath)); } catch ( ParserConfigurationException e) { throw new IOException(e.getMessage()); } catch ( SAXException e) { throw new IOException(e.getMessage()); } _logger.info("... success"); }
Example 30
From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/builder/.
Source file: BELCompileBuilder.java

private SAXParser getParser() throws ParserConfigurationException, SAXException { if (parserFactory == null) { parserFactory=SAXParserFactory.newInstance(); } return parserFactory.newSAXParser(); }
Example 31
From project big-data-plugin, under directory /src/org/pentaho/di/job/.
Source file: JobEntrySerializationHelper.java

/** * Handle reading of the input (object) from the kettle repository by getting the xml from the repository attribute string and then re-hydrate the object with our already existing read method. * @param object * @param rep * @param id_job * @param databases * @param slaveServers * @throws KettleException */ public static void loadRep(Object object,Repository rep,ObjectId id_job,List<DatabaseMeta> databases,List<SlaveServer> slaveServers) throws KettleException { try { String xml=rep.getJobEntryAttributeString(id_job,"job-xml"); ByteArrayInputStream bais=new ByteArrayInputStream(xml.getBytes()); Document doc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); read(object,doc.getDocumentElement()); } catch ( ParserConfigurationException ex) { throw new KettleException(ex.getMessage(),ex); } catch ( SAXException ex) { throw new KettleException(ex.getMessage(),ex); } catch ( IOException ex) { throw new KettleException(ex.getMessage(),ex); } }
Example 32
From project bioclipse.seneca, under directory /plugins/net.bioclipse.seneca/src/org/openscience/cdk/structgen/pubchem/.
Source file: PubchemStructureGenerator.java

public static List<IMolecule> doDownload(String formula,IProgressMonitor monitor) throws TransformerConfigurationException, ParserConfigurationException, IOException, SAXException, FactoryConfigurationError, TransformerFactoryConfigurationError, TransformerException, NodeNotAvailableException { PubchemStructureGenerator request=new PubchemStructureGenerator(); request.submitInitalRequest(formula); worked=0; while (!request.getStatus().isFinished()) { if (monitor.isCanceled()) return null; request.refresh(); worked++; monitor.worked(worked); } request.submitDownloadRequest(); while (!request.getStatusDownload().isFinished()) { if (monitor.isCanceled()) return null; request.refresh(); worked++; monitor.worked(worked); } URLConnection uc=request.getResponseURL().openConnection(); String contentType=uc.getContentType(); int contentLength=uc.getContentLength(); if (contentType.startsWith("text/") || contentLength == -1) { throw new IOException("This is not a binary file."); } InputStream raw=uc.getInputStream(); InputStream in=new BufferedInputStream(raw); List<IMolecule> list=new ArrayList<IMolecule>(); IteratingMDLReader reader=new IteratingMDLReader(in,DefaultChemObjectBuilder.getInstance()); while (reader.hasNext()) { list.add((IMolecule)reader.next()); } return list; }
Example 33
From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/editor/.
Source file: PeakTablePage.java

public void setSpectrumItem(CMLSpectrum spectrumItem) throws ParserConfigurationException, SAXException, IOException { if (spectrumItem != null) { this.spectrumItem=spectrumItem; if (viewer != null) viewer.setSpectrumItem(spectrumItem); this.update(); } }
Example 34
From project blacktie, under directory /jatmibroker-nbf/src/main/java/org/jboss/narayana/blacktie/jatmibroker/nbf/.
Source file: NBFParser.java

public NBFParser(String xsdFilename) throws ConfigurationException { try { SAXParserFactory factory=SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); SchemaFactory schemaFactory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); factory.setFeature("http://apache.org/xml/features/validation/schema",true); File file=new File(xsdFilename); if (file.exists()) { schema=schemaFactory.newSchema(file); } else { throw new ConfigurationException("Could not find " + xsdFilename); } factory.setSchema(schema); saxParser=factory.newSAXParser(); PSVIProvider p=(PSVIProvider)saxParser.getXMLReader(); handler=new NBFHandlers(p); } catch ( SAXException e) { log.error("Could not create a SAXParser: " + e.getMessage(),e); throw new ConfigurationException("Could not create a SAXParser: " + e.getMessage()); } catch ( ParserConfigurationException e) { log.error("Could not create a SAXParser: " + e.getMessage(),e); throw new ConfigurationException("Could not create a SAXParser: " + e.getMessage()); } catch ( Throwable e) { log.error("Could not create a SAXParser: " + e.getMessage(),e); throw new ConfigurationException("Could not create a SAXParser: " + e.getMessage()); } }
Example 35
From project blog_1, under directory /miniprojects/generic-pojo-mappers/src/main/java/net/jakubholy/blog/genericmappers/xml/.
Source file: XmlElements.java

private static Document parseXmlToDocument(String xml) throws RuntimeException { DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); try { DocumentBuilder builder=builderFactory.newDocumentBuilder(); InputSource is=new InputSource(new StringReader(xml)); return builder.parse(is); } catch ( SAXException e) { throw new RuntimeException("Parsing XML failed: " + e + ", xml: "+ xml,e); } catch ( IOException e) { throw new RuntimeException("Parsing XML failed: " + e + ", xml: "+ xml,e); } catch ( ParserConfigurationException e) { throw new RuntimeException("Parsing XML failed: " + e + ", xml: "+ xml,e); } }
Example 36
From project BMach, under directory /src/jsyntaxpane/actions/.
Source file: XmlPrettifyAction.java

public DocumentBuilder getDocBuilder(){ if (docBuilder == null) { try { docBuilder=getDocBuilderFactory().newDocumentBuilder(); } catch ( ParserConfigurationException ex) { throw new IllegalArgumentException("Unable to create document builder",ex); } } return docBuilder; }
Example 37
From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.
Source file: AmazonManager.java

/** * This searches the amazon REST site based on a specific isbn. It proxies through lgsolutions.com.au due to amazon not support mobile devices * @param mIsbn The ISBN to search for * @return The book array */ static public void searchAmazon(String mIsbn,String mAuthor,String mTitle,Bundle bookData,boolean fetchThumbnail){ mAuthor=mAuthor.replace(" ","%20"); mTitle=mTitle.replace(" ","%20"); String path="http://theagiledirector.com/getRest_v3.php"; if (mIsbn.equals("")) { path+="?author=" + mAuthor + "&title="+ mTitle; } else { path+="?isbn=" + mIsbn; } URL url; SAXParserFactory factory=SAXParserFactory.newInstance(); SAXParser parser; SearchAmazonHandler handler=new SearchAmazonHandler(bookData,fetchThumbnail); try { url=new URL(path); parser=factory.newSAXParser(); parser.parse(Utils.getInputStream(url),handler); } catch ( MalformedURLException e) { Logger.logError(e); } catch ( ParserConfigurationException e) { Logger.logError(e); } catch ( ParseException e) { Logger.logError(e); } catch ( SAXException e) { Logger.logError(e); } catch ( Exception e) { Logger.logError(e); } return; }
Example 38
From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/.
Source file: BPELUnitRunner.java

private void initializeXMLParser() throws ConfigurationException { try { BPELUnitUtil.initializeParsing(); } catch ( ParserConfigurationException e) { throw new ConfigurationException("Could not initialize XML Parser Component.",e); } }
Example 39
From project bpm-console, under directory /server/war/src/main/java/org/jboss/bpm/console/server/util/.
Source file: DOMUtils.java

protected DocumentBuilder initialValue(){ try { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setNamespaceAware(true); DocumentBuilder builder=factory.newDocumentBuilder(); setEntityResolver(builder); return builder; } catch ( ParserConfigurationException e) { throw new RuntimeException("Failed to create DocumentBuilder",e); } }
Example 40
From project BukkitUtilities, under directory /src/main/java/name/richardson/james/bukkit/utilities/updater/.
Source file: MavenManifest.java

public MavenManifest(final File file) throws SAXException, IOException, ParserConfigurationException { final DocumentBuilderFactory docBuilderFactory=DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder=docBuilderFactory.newDocumentBuilder(); final Document doc=docBuilder.parse(file); doc.getDocumentElement().normalize(); final NodeList root=doc.getChildNodes(); final Node meta=this.getNode("metadata",root); final Node versioning=this.getNode("versioning",meta.getChildNodes()); final Node versions=this.getNode("versions",versioning.getChildNodes()); final NodeList nodes=versions.getChildNodes(); this.setVersionList(nodes); file.deleteOnExit(); }
Example 41
From project C-Cat, under directory /util/src/main/java/gov/llnl/ontology/text/corpora/.
Source file: NYTDocumentReader.java

/** * Parse the specified file into a DOM Document. * @param file The file to parse. * @return The parsed DOM Document or null if an error occurs. */ private static Document loadValidating(File file){ try { return getDOMObject(file.getAbsolutePath(),true); } catch ( SAXException e) { e.printStackTrace(); System.out.println("Error parsing digital document from nitf file " + file + "."); } catch ( IOException e) { e.printStackTrace(); System.out.println("Error parsing digital document from nitf file " + file + "."); } catch ( ParserConfigurationException e) { e.printStackTrace(); System.out.println("Error parsing digital document from nitf file " + file + "."); } return null; }
Example 42
From project capedwarf-blue, under directory /common/src/main/java/org/jboss/capedwarf/common/config/.
Source file: AppEngineWebXmlParser.java

public static AppEngineWebXml parse(InputStream inputStream) throws IOException { try { return tryParse(inputStream); } catch ( ParserConfigurationException e) { throw new RuntimeException(e); } catch ( SAXException e) { throw new RuntimeException(e); } }
Example 43
From project cascading, under directory /src/xml/cascading/operation/xml/.
Source file: XPathOperation.java

@Override public void prepare(FlowProcess flowProcess,OperationCall<Pair<DocumentBuilder,Tuple>> operationCall){ try { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); operationCall.setContext(new Pair<DocumentBuilder,Tuple>(factory.newDocumentBuilder(),Tuple.size(1))); } catch ( ParserConfigurationException exception) { throw new OperationException("could not create document builder",exception); } }
Example 44
From project CCR-Validator, under directory /src/main/java/org/openhealthdata/validation/.
Source file: CCRV1SchemaValidator.java

private Document parseFile(File source,boolean validating){ try { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setValidating(validating); factory.setNamespaceAware(true); Document doc=factory.newDocumentBuilder().parse(source); return doc; } catch ( SAXException e) { logger.log(Level.SEVERE,"A parsing error occurred; the xml input is not valid",e); e.printStackTrace(); return null; } catch ( ParserConfigurationException e) { logger.log(Level.SEVERE,"A parsing error occurred; the xml input is not valid",e); e.printStackTrace(); return null; } catch ( IOException e) { logger.log(Level.SEVERE,"A parsing error occurred; the xml input is not valid",e); e.printStackTrace(); return null; } }
Example 45
From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/templatecompiler/model/.
Source file: ElementsHandler.java

/** * Default constructor. <p/> It is up to a JAXB provider to decide which DOM implementation to use or how that is configured. */ public ElementsHandler(){ DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance(); try { this.builder=docFactory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new IllegalArgumentException("No documentBuilderFactory"); } }
Example 46
From project ceres, under directory /ceres-site/src/main/java/com/bc/ceres/site/util/.
Source file: ExclusionListBuilder.java

static void addPomToExclusionList(File exclusionList,URL pom) throws ParserConfigurationException, IOException, SAXException { BufferedWriter writer=new BufferedWriter(new FileWriter(exclusionList,true)); try { final DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder(); final Document w3cDoc=builder.parse(pom.openStream()); final DOMBuilder domBuilder=new DOMBuilder(); final org.jdom.Document doc=domBuilder.build(w3cDoc); final Element root=doc.getRootElement(); final Namespace namespace=root.getNamespace(); final List<Element> modules=root.getChildren(MODULES_NODE,namespace); if (modules != null) { final Element modulesNode=modules.get(0); final List<Element> modulesList=(List<Element>)modulesNode.getChildren(MODULE_NAME,namespace); for ( Element module : modulesList) { addModuleToExclusionList(exclusionList,writer,module.getText()); } } } catch ( Exception e) { e.printStackTrace(); } finally { writer.close(); } }
Example 47
From project cilia-workbench, under directory /cilia-workbench-common/src/fr/liglab/adele/cilia/workbench/common/xml/.
Source file: XMLHelpers.java

private static DocumentBuilder getDocumentBuilder() throws CiliaException { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder=factory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new CiliaException("Can't get document builder ",e); } return builder; }
Example 48
From project Cilia_1, under directory /framework/runtime/src/main/java/fr/liglab/adele/cilia/framework/data/.
Source file: XmlTools.java

public static Node streamToNode(InputStream is) throws CiliaException { DocumentBuilderFactory domFactory=DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder builder=null; try { builder=domFactory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { e.printStackTrace(); throw new CiliaException("Unable to create DocumentBuilder in XmlTools: " + e.getMessage()); } Document doc=null; try { doc=builder.parse(is); } catch ( SAXException e) { e.printStackTrace(); throw new CiliaException("Unable to create org.w3c.dom.Node from URL in XmlTools: " + e.getMessage()); } catch ( IOException e) { e.printStackTrace(); throw new CiliaException(e.getMessage()); } return doc; }
Example 49
From project CIShell, under directory /clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/.
Source file: MenuAdapter.java

private void parseXMLFile(String menuFilePath){ DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); documentBuilderFactory.setCoalescing(true); try { DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder(); this.documentObjectModel=documentBuilder.parse(menuFilePath); } catch ( ParserConfigurationException parserConfigurationException) { parserConfigurationException.printStackTrace(); } catch ( SAXException saxException) { saxException.printStackTrace(); } catch ( IOException ioException) { ioException.printStackTrace(); } }
Example 50
From project closure-templates, under directory /java/src/com/google/template/soy/xliffmsgplugin/.
Source file: XliffParser.java

/** * Parses the content of a translated XLIFF file and creates a SoyMsgBundle. * @param xliffContent The XLIFF content to parse. * @return The resulting SoyMsgBundle. * @throws SAXException If there's an error parsing the data. * @throws SoyMsgException If there's an error in parsing the data. */ static SoyMsgBundle parseXliffTargetMsgs(String xliffContent) throws SAXException, SoyMsgException { SAXParserFactory saxParserFactory=SAXParserFactory.newInstance(); SAXParser saxParser; try { saxParser=saxParserFactory.newSAXParser(); } catch ( ParserConfigurationException pce) { throw new AssertionError("Could not get SAX parser for XML."); } XliffSaxHandler xliffSaxHandler=new XliffSaxHandler(); try { saxParser.parse(new InputSource(new StringReader(xliffContent)),xliffSaxHandler); } catch ( IOException e) { throw new AssertionError("Should not fail in reading a string."); } return new SoyMsgBundleImpl(xliffSaxHandler.getTargetLocaleString(),xliffSaxHandler.getMsgs()); }
Example 51
From project Cloud9, under directory /src/dist/edu/umd/hooka/corpora/.
Source file: ParallelCorpusReader.java

public static void parseXMLDocument(String file,PChunkCallback cb){ ParallelCorpusReader pcr=new ParallelCorpusReader(cb); final SAXParserFactory spf=SAXParserFactory.newInstance(); try { final SAXParser sp=spf.newSAXParser(); sp.parse(file,pcr); } catch ( final SAXException se) { se.printStackTrace(); } catch ( final ParserConfigurationException pce) { pce.printStackTrace(); } catch ( final IOException ie) { ie.printStackTrace(); } }
Example 52
From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/utils/.
Source file: AppConfigHelper.java

private static Document readXML(InputSource input){ DocumentBuilderFactory dBF=DocumentBuilderFactory.newInstance(); dBF.setIgnoringComments(true); DocumentBuilder builder=null; try { builder=dBF.newDocumentBuilder(); } catch ( ParserConfigurationException e) { e.printStackTrace(); } Document doc=null; try { doc=builder.parse(input); } catch ( SAXException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); } return doc; }
Example 53
From project cloudify, under directory /esc/src/main/java/org/cloudifysource/esc/driver/provisioning/azure/client/.
Source file: MicrosoftAzureModelUtils.java

private static DocumentBuilder createDocumentBuilder(){ DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); try { dbf.setNamespaceAware(false); return dbf.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new IllegalStateException(e); } }
Example 54
From project code_swarm, under directory /src/org/codeswarm/repository/svn/.
Source file: SVNHistory.java

/** * serializes the log entries */ public void finishLogEntries(){ try { CodeSwarmEventsSerializer serializer=new CodeSwarmEventsSerializer(list); serializer.serialize(getFilePath()); } catch ( ParserConfigurationException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( TransformerConfigurationException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( IOException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( TransformerException ex) { LOGGER.log(Level.SEVERE,null,ex); } }
Example 55
From project code_swarm-gource-my-conf, under directory /src/org/codeswarm/repository/svn/.
Source file: SVNHistory.java

/** * serializes the log entries */ public void finishLogEntries(){ try { CodeSwarmEventsSerializer serializer=new CodeSwarmEventsSerializer(list); serializer.serialize(getFilePath()); } catch ( ParserConfigurationException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( TransformerConfigurationException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( IOException ex) { LOGGER.log(Level.SEVERE,null,ex); } catch ( TransformerException ex) { LOGGER.log(Level.SEVERE,null,ex); } }
Example 56
From project codjo-control, under directory /codjo-control-gui/src/test/java/net/codjo/control/gui/plugin/.
Source file: DefaultQuarantineDetailWindowTest.java

private DetailDataSource getDataSource(int quarantineNb) throws IOException, ParserConfigurationException, SAXException { Result result=new Result(); result.addRow(new Row(Collections.singletonMap("errorType","10"))); ControlGuiContext ctxt=new ControlGuiContext(); DetailDataSource dataSource=new DetailDataSource(ctxt); dataSource.setLoadResult(result); guiData=(QuarantineGuiData)manager.getList().getDataList().toArray()[quarantineNb]; ctxt.putProperty(DefaultQuarantineWindow.QUARANTINE_GUI_DATA,guiData); ctxt.putProperty("TEST_STRUCTURE_READER",getReader()); return dataSource; }
Example 57
From project codjo-segmentation, under directory /codjo-segmentation-server/src/main/java/net/codjo/segmentation/server/plugin/.
Source file: PreferenceGuiHome.java

public String buildResponse(InputSource confFile) throws ParserConfigurationException, TransformerException, IOException, XmlException { DocumentBuilder builder=initFactory(); Document root=builder.getDOMImplementation().createDocument(null,"family-list",null); XmlParser xmlParser=new XmlParser(); RootBuilder reader=new RootBuilder(root); xmlParser.parse(confFile,reader); return domToString(root); }
Example 58
From project Coffee-Framework, under directory /coffeeframework-core/src/main/java/coffee/.
Source file: CoffeeApplicationContext.java

/** * Compiles the resource. For performance improvements it stores earlier compiled resources in a cached factory of components. * @param teplateName * @param coffeeContext * @return IComponent implementation of compiled template * @throws IOException * @throws ParserConfigurationException * @throws SAXException * @throws CloneNotSupportedException * @throws ServletException */ public IComponent compile(String templateName,CoffeeRequestContext context) throws IOException, ParserConfigurationException, SAXException, CloneNotSupportedException, ServletException { if (isCacheEnabled() && resourceCache.containsKey(templateName)) return (IComponent)resourceCache.get(templateName).clone(context); InputStream template=getResourceAsStream(templateName); if (template == null) return null; try { CoffeeTemplateParser parser=new CoffeeTemplateParser(context); IComponent application=parser.parse(template); if (parser.getDoctype() != null) application.setAttribute(Html.DOCTYPE_ATTRIBUTE,parser.getDoctype()); cacheCompiledPage(templateName,application); return application; } catch ( NullPointerException e) { System.err.println("ERROR compiling " + templateName); throw e; } }
Example 59
From project core_1, under directory /common/src/main/java/org/switchyard/common/io/pull/.
Source file: ElementPuller.java

/** * Pulls an Element from an InputSource. * @param source an InputSource of the element * @return the element * @throws IOException if a problem occurred */ public Element pull(InputSource source) throws IOException { DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); factory.setIgnoringComments(_ignoringComments); factory.setNamespaceAware(true); factory.setValidating(false); try { return pull(factory.newDocumentBuilder().parse(source)); } catch ( ParserConfigurationException pce) { throw new IOException(pce); } catch ( SAXException se) { throw new IOException(se); } }
Example 60
From project core_4, under directory /impl/src/main/java/org/richfaces/resource/.
Source file: Xcss2EcssConverter.java

public static void main(String[] args) throws SAXException, ParserConfigurationException, IOException { Handler handler=new Handler(); CreateParser parser=new CreateParser(handler); String filename=args[0]; parser.parse(filename); }
Example 61
From project core_5, under directory /exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/.
Source file: XMLDocumentReader.java

/** * Cleans the string from tags. * @param str the string which contain a text with user's tags. * @return The string cleaned from user's tags and their bodies. */ private String parse(InputStream is){ final SAXParserFactory saxParserFactory=SAXParserFactory.newInstance(); SAXParser saxParser; StringWriter writer=new StringWriter(); DefaultHandler dh=new WriteOutContentHandler(writer); try { saxParser=SecurityHelper.doPrivilegedParserConfigurationOrSAXExceptionAction(new PrivilegedExceptionAction<SAXParser>(){ public SAXParser run() throws Exception { return saxParserFactory.newSAXParser(); } } ); saxParser.parse(is,dh); } catch ( SAXException e) { return ""; } catch ( IOException e) { return ""; } catch ( ParserConfigurationException e) { return ""; } return writer.toString(); }
Example 62
From project Cours-3eme-ann-e, under directory /Java/FerryInpres/src/information_client/.
Source file: MainForm.java

private void envoieButtonActionPerformed(java.awt.event.ActionEvent evt){ if (this.ferryText.getText().isEmpty() || this.voyageurText.getText().isEmpty()) { this.erreurLabel.setText("Veillez ? renseigner les champs Ferry et Nom voyageur"); } else { try { this.erreurLabel.setText(""); Document doc=this.genDocument(); this.sendDocument(doc); } catch ( ClassNotFoundException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,null,ex); } catch ( TransformerConfigurationException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,null,ex); } catch ( IOException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,null,ex); } catch ( ParserConfigurationException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,null,ex); } catch ( TransformerException ex) { Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE,null,ex); } } }
Example 63
From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/.
Source file: DependencyTable.java

public void load() throws IOException, ParserConfigurationException, SAXException { dependencies.clear(); if (dependenciesFile.exists()) { SAXParserFactory factory=SAXParserFactory.newInstance(); factory.setValidating(false); SAXParser parser=factory.newSAXParser(); parser.parse(dependenciesFile,new DependencyTableHandler(this,baseDir)); dirty=false; } }
Example 64
From project danbooru-gallery-android, under directory /src/tw/idv/palatis/danboorugallery/siteapi/.
Source file: DanbooruStyleAPI.java

@Deprecated protected List<Tag> fetchTagsIndexXML(String url_format,int page,String name,int limit){ TreeSet<Tag> ret=new TreeSet<Tag>(new Tag.CompareById()); String keywords[]=new HashSet<String>(Arrays.asList(name.split("\\+"))).toArray(new String[]{}); for ( String keyword : keywords) { keyword=keyword.trim().replace(' ','_'); try { URL fetchUrl=new URL(String.format(url_format,page,keyword,limit)); D.Log.v("DanbooruStyleAPI::fetchTagsIndexXML(): fetching %s",fetchUrl); DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance(); DocumentBuilder db=dbf.newDocumentBuilder(); Document doc=db.parse(new InputSource(fetchUrl.openStream())); doc.getDocumentElement().normalize(); NodeList nodes=doc.getElementsByTagName("tag"); int length=nodes.getLength(); for (int i=0; i < length; ++i) { ret.add(new Tag((Element)nodes.item(i))); if (isCanceled()) return null; } } catch ( UnsupportedEncodingException e) { D.Log.wtf(e); } catch ( IOException e) { D.Log.wtf(e); } catch ( SAXException e) { D.Log.wtf(e); } catch ( ParserConfigurationException e) { D.Log.wtf(e); } } return Arrays.asList(ret.toArray(new Tag[]{})); }
Example 65
From project dawn-isencia, under directory /com.isencia.passerelle.commons.ume/src/main/java/com/isencia/message/extractor/.
Source file: XmlMessageExtractor.java

/** * Creates a new instance */ public XmlMessageExtractor(){ SAXParserFactory saxFactory=SAXParserFactory.newInstance(); try { saxParser=saxFactory.newSAXParser(); } catch ( ParserConfigurationException e) { } catch ( SAXException e) { } }
Example 66
From project dcm4che, under directory /dcm4che-core/src/main/java/org/dcm4che/data/.
Source file: IOD.java

public void parse(String uri) throws IOException { try { SAXParserFactory f=SAXParserFactory.newInstance(); SAXParser parser=f.newSAXParser(); parser.parse(uri,new SAXHandler(this)); } catch ( SAXException e) { throw new IOException("Failed to parse " + uri,e); } catch ( ParserConfigurationException e) { throw new RuntimeException(e); } }
Example 67
From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/chainsaw/.
Source file: LoadXMLAction.java

/** * Creates a new <code>LoadXMLAction</code> instance. * @param aParent the parent frame * @param aModel the model to add events to * @exception SAXException if an error occurs * @throws ParserConfigurationException if an error occurs */ LoadXMLAction(JFrame aParent,MyTableModel aModel) throws SAXException, ParserConfigurationException { mParent=aParent; mHandler=new XMLFileHandler(aModel); mParser=SAXParserFactory.newInstance().newSAXParser().getXMLReader(); mParser.setContentHandler(mHandler); }
Example 68
From project descriptors, under directory /test-util/src/main/java/org/jboss/shrinkwrap/descriptor/test/util/.
Source file: XmlAssert.java

private static Document create(String xml,boolean namespaceAware){ try { DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(namespaceAware); return documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes())); } catch ( final IOException ioe) { throw new RuntimeException(ioe); } catch ( final SAXException se) { throw new RuntimeException(se); } catch ( final ParserConfigurationException pce) { throw new RuntimeException(pce); } }
Example 69
private DocumentBuilder newDocumentBuilder(){ try { DocumentBuilderFactory builderFactory=DocumentBuilderFactory.newInstance(); return builderFactory.newDocumentBuilder(); } catch ( ParserConfigurationException e) { throw new RuntimeException(e); } }
Example 70
From project dolphin, under directory /org.adarsh.jutils/src/org/adarsh/jutils/internal/.
Source file: ConfigurationXMLParser.java

/** * Retrieves the content of the child tag if it's found enclosed by the parent tag. * @param parentTag the name of the parent tag. * @param childTag the name of the child tag. * @return a <tt>String</tt> containing the data. */ public static String retrieveTagContents(String parentTag,String childTag){ DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); String contents=""; try { DocumentBuilder docBuilder=factory.newDocumentBuilder(); InputStream input=ConfigurationXMLParser.class.getResourceAsStream(ConfigurationConstants.DEFAULT_CONFIG_FILE); Document document=docBuilder.parse(input); NodeList parentNodeList=document.getElementsByTagName(parentTag); Element parentElement=(Element)parentNodeList.item(0); NodeList childNodeList=parentElement.getElementsByTagName(childTag); Element childElement=(Element)childNodeList.item(0); contents=childElement.getFirstChild().getNodeValue(); input.close(); } catch ( ParserConfigurationException e) { Logger.error("Error parsing configuration XML",e); } catch ( SAXException e) { Logger.error("Error parsing configuration XML",e); } catch ( IOException e) { Logger.error("Error parsing configuration XML",e); } return contents.trim() + "\n"; }
Example 71
From project dozer, under directory /core/src/main/java/org/dozer/loader/xml/.
Source file: XMLParserFactory.java

public DocumentBuilder createParser(){ DocumentBuilderFactory factory=createDocumentBuilderFactory(); try { return createDocumentBuilder(factory); } catch ( ParserConfigurationException e) { throw new MappingException("Failed to create XML Parser !",e); } }
Example 72
From project dreamDroid, under directory /src/net/reichholf/dreamdroid/parsers/.
Source file: GenericSaxParser.java

@Override public boolean parse(String input){ try { mError=false; mErrorText=null; ByteArrayInputStream bais=new ByteArrayInputStream(input.getBytes()); InputSource is=new InputSource(); is.setByteStream(bais); SAXParserFactory spf=SAXParserFactory.newInstance(); spf.setValidating(false); SAXParser sp=spf.newSAXParser(); XMLReader xr=sp.getXMLReader(); xr.setContentHandler(mHandler); xr.parse(is); return true; } catch ( ParserConfigurationException e) { Log.e(DreamDroid.LOG_TAG,e.toString()); mError=true; mErrorText=e.toString(); e.printStackTrace(); } catch ( SAXException e) { Log.e(DreamDroid.LOG_TAG,e.toString()); mError=true; mErrorText=e.toString(); e.printStackTrace(); } catch ( IOException e) { Log.e(DreamDroid.LOG_TAG,e.toString()); mError=true; mErrorText=e.toString(); e.printStackTrace(); } return false; }
Example 73
From project DrmLicenseService, under directory /src/com/sonyericsson/android/drm/drmlicenseservice/.
Source file: CustomDataParser.java

public String parseXML(ByteArrayBuffer xmlData){ if (xmlData != null && xmlData.length() > 0) { try { ByteArrayInputStream bais=new ByteArrayInputStream(xmlData.buffer(),0,xmlData.length()); SAXParserFactory spf=SAXParserFactory.newInstance(); SAXParser sp=spf.newSAXParser(); XMLReader xr=sp.getXMLReader(); CustomDataXmlHandler triggerHandler=new CustomDataXmlHandler(); xr.setContentHandler(triggerHandler); xr.parse(new InputSource(bais)); String customData=triggerHandler.getCustomData(); return customData; } catch ( ParserConfigurationException e) { } catch ( SAXException e) { } catch ( IOException e) { } } return null; }