Java Code Examples for javax.xml.parsers.SAXParser

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 Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/dataholders/loadingutils/.

Source file: XmlMerger.java

  18 
vote

/** 
 * Check for modifications of included files.
 * @return <code>true</code> if at least one of included files has modifications.
 * @throws IOException                  IO Error.
 * @throws SAXException                 Document parsing error.
 * @throws ParserConfigurationException if a SAX parser cannotbe created which satisfies the requested configuration.
 */
private boolean checkFileModifications() throws Exception {
  long destFileTime=destFile.lastModified();
  if (sourceFile.lastModified() > destFileTime) {
    logger.debug("Source file was modified ");
    return true;
  }
  Properties metadata=restoreFileModifications(metaDataFile);
  if (metadata == null)   return true;
  SAXParserFactory parserFactory=SAXParserFactory.newInstance();
  SAXParser parser=parserFactory.newSAXParser();
  TimeCheckerHandler handler=new TimeCheckerHandler(baseDir,metadata);
  parser.parse(sourceFile,handler);
  return handler.isModified();
}
 

Example 2

From project Airports, under directory /src/com/nadmm/airports/wx/.

Source file: AirSigmetParser.java

  18 
vote

public void parse(File xml,AirSigmet airSigmet){
  try {
    airSigmet.fetchTime=xml.lastModified();
    InputSource input=new InputSource(new FileReader(xml));
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    AirSigmetHandler handler=new AirSigmetHandler(airSigmet);
    XMLReader xmlReader=parser.getXMLReader();
    xmlReader.setContentHandler(handler);
    xmlReader.parse(input);
  }
 catch (  Exception e) {
  }
}
 

Example 3

From project and-bible, under directory /IgnoreAndBibleExperiments/experiments/.

Source file: SwordApi.java

  18 
vote

private synchronized FormattedDocument readHtmlTextOptimizedZTextOsis(Book book,Key key,int maxKeyCount) throws NoSuchKeyException, BookException, IOException, SAXException, URISyntaxException, ParserConfigurationException {
  log.debug("Using fast method to fetch document data");
  InputStream is=new OSISInputStream(book,key);
  OsisToHtmlSaxHandler osisToHtml=getSaxHandler(book);
  SAXParserFactory spf=SAXParserFactory.newInstance();
  spf.setValidating(false);
  SAXParser parser=spf.newSAXParser();
  parser.parse(is,osisToHtml);
  FormattedDocument retVal=new FormattedDocument();
  retVal.setHtmlPassage(osisToHtml.toString());
  retVal.setNotesList(osisToHtml.getNotesList());
  return retVal;
}
 

Example 4

From project android-thaiime, under directory /makedict/src/com/android/inputmethod/latin/.

Source file: XmlDictInputOutput.java

  18 
vote

/** 
 * Reads a dictionary from an XML file. This is the public method that will parse an XML file and return the corresponding memory representation.
 * @param unigrams the file to read the data from.
 * @return the in-memory representation of the dictionary.
 */
public static FusionDictionary readDictionaryXml(InputStream unigrams,InputStream bigrams) throws SAXException, IOException, ParserConfigurationException {
  final SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  final SAXParser parser=factory.newSAXParser();
  final BigramHandler bigramHandler=new BigramHandler();
  if (null != bigrams)   parser.parse(bigrams,bigramHandler);
  final FusionDictionary dict=new FusionDictionary();
  final UnigramHandler unigramHandler=new UnigramHandler(dict,bigramHandler.getBigramMap());
  parser.parse(unigrams,unigramHandler);
  return dict;
}
 

Example 5

From project android_packages_inputmethods_LatinIME, under directory /tools/makedict/src/com/android/inputmethod/latin/.

Source file: XmlDictInputOutput.java

  18 
vote

/** 
 * Reads a dictionary from an XML file. This is the public method that will parse an XML file and return the corresponding memory representation.
 * @param unigrams the file to read the data from.
 * @return the in-memory representation of the dictionary.
 */
public static FusionDictionary readDictionaryXml(InputStream unigrams,InputStream bigrams) throws SAXException, IOException, ParserConfigurationException {
  final SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  final SAXParser parser=factory.newSAXParser();
  final BigramHandler bigramHandler=new BigramHandler();
  if (null != bigrams)   parser.parse(bigrams,bigramHandler);
  final FusionDictionary dict=new FusionDictionary();
  final UnigramHandler unigramHandler=new UnigramHandler(dict,bigramHandler.getBigramMap());
  parser.parse(unigrams,unigramHandler);
  return dict;
}
 

Example 6

From project ant4eclipse, under directory /org.ant4eclipse.lib.platform/src/org/ant4eclipse/lib/platform/internal/model/launcher/.

Source file: LaunchConfigurationReaderImpl.java

  18 
vote

/** 
 * {@inheritDoc}
 */
public LaunchConfiguration readLaunchConfiguration(File launchConfigurationFile){
  Assure.isFile("launchConfigurationFile",launchConfigurationFile);
  try {
    SAXParser parser=getParserFactory().newSAXParser();
    LaunchConfigHandler handler=new LaunchConfigHandler();
    parser.parse(launchConfigurationFile,handler);
    LaunchConfigurationImpl launchConfigurationImpl=new LaunchConfigurationImpl(handler.getLaunchConfigurationType(),handler.getAttributes());
    return launchConfigurationImpl;
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    throw new RuntimeException("Could not parse launch config '" + launchConfigurationFile + ": "+ ex,ex);
  }
}
 

Example 7

From project beam-third-party, under directory /beam-meris-veg/src/main/java/org/esa/beam/processor/baer/auxdata/.

Source file: AerPhaseLoader.java

  18 
vote

/** 
 * Parses the aerosol phase function auxiliary file.
 * @param defFile
 */
private void parseFile(URL defFile) throws ParserConfigurationException, SAXException, IOException {
  _luts.clear();
  _lutNames.clear();
  initStateVariables();
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser saxParser=factory.newSAXParser();
  saxParser.parse(defFile.openStream(),new LUTHandler());
}
 

Example 8

From project Carolina-Digital-Repository, under directory /fcrepo-irods-storage/src/test/java/.

Source file: MockFedoraIT.java

  18 
vote

private void parseIrodsFile(IrodsIFileSystem module,String testPath) throws LowlevelStorageException {
  InputStream is=module.read(new File(testPath));
  try {
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser parser=spf.newSAXParser();
    parser.parse(is,new DefaultHandler());
  }
 catch (  Exception e) {
    throw new RuntimeException("Error with SAX parser",e);
  }
}
 

Example 9

From project ChkBugReport, under directory /src/com/sonyericsson/chkbugreport/util/.

Source file: XMLNode.java

  18 
vote

public static XMLNode parse(InputStream is){
  XMLNodeHandler handler=new XMLNodeHandler();
  try {
    SAXParser parser=SAXParserFactory.newInstance().newSAXParser();
    parser.parse(is,handler);
    return handler.mRoot;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}
 

Example 10

From project CineShowTime-Android, under directory /Libraries/CineShowTime/src/com/binomed/showtime/android/util/.

Source file: CineShowtimeFactory.java

  18 
vote

private XMLReader getReader() throws Exception {
  if (reader == null) {
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    reader=sp.getXMLReader();
  }
  return reader;
}
 

Example 11

From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/utils/.

Source file: PlistParser.java

  18 
vote

private static Object parsePlist(InputStream in){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    PlistParser handler=new PlistParser();
    BufferedReader reader=new BufferedReader(new InputStreamReader(in),8192);
    parser.parse(new InputSource(reader),handler);
    return handler.rootDict;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 12

From project codjo-webservices, under directory /codjo-webservices-common/src/main/java/com/tilab/wsig/soap/.

Source file: SoapToJade.java

  18 
vote

/** 
 * Get SAX parser class name
 * @param s
 * @return parser name
 */
private static String getSaxParserName() throws Exception {
  String saxFactory=System.getProperty("org.xml.sax.driver");
  if (saxFactory != null) {
    return saxFactory;
  }
 else {
    SAXParserFactory newInstance=SAXParserFactory.newInstance();
    SAXParser newSAXParser=newInstance.newSAXParser();
    XMLReader reader=newSAXParser.getXMLReader();
    String name=reader.getClass().getName();
    return name;
  }
}
 

Example 13

From project Coffee-Framework, under directory /coffeeframework-core/src/main/java/coffee/.

Source file: CoffeeConfiguration.java

  18 
vote

/** 
 * @param configurationFile
 * @return a parsed coffee configuration
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 */
public static CoffeeConfiguration parse(InputStream configurationFile) throws ParserConfigurationException, SAXException, IOException {
  CoffeeConfiguration configurationParser=new CoffeeConfiguration();
  SAXParserFactory sax=SAXParserFactory.newInstance();
  sax.setValidating(false);
  sax.setNamespaceAware(true);
  SAXParser parser=sax.newSAXParser();
  parser.parse(configurationFile,configurationParser);
  return configurationParser;
}
 

Example 14

From project core_1, under directory /common/src/main/java/org/switchyard/common/xml/.

Source file: XMLHelper.java

  18 
vote

/** 
 * Compare the specified contents as XML.
 * @param content1 The first content.
 * @param content2 The second content.
 * @return true if equals, false otherwise.
 * @throws ParserConfigurationException Parser confiuration exception
 * @throws SAXException SAX exception
 * @throws IOException If unable to read the stream
 */
public static boolean compareXMLContent(final InputSource content1,final InputSource content2) throws ParserConfigurationException, SAXException, IOException {
  final SAXParserFactory parserFactory=SAXParserFactory.newInstance();
  parserFactory.setNamespaceAware(true);
  final SAXParser parser=parserFactory.newSAXParser();
  final IdentitySAXHandler handler1=new IdentitySAXHandler();
  parser.parse(content1,handler1);
  final IdentitySAXHandler handler2=new IdentitySAXHandler();
  parser.parse(content2,handler2);
  return (handler1.getRootElement().equals(handler2.getRootElement()));
}
 

Example 15

From project cpptasks-parallel, under directory /src/main/java/net/sf/antcontrib/cpptasks/.

Source file: DependencyTable.java

  18 
vote

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 16

From project crash, under directory /jcr/core/src/main/java/org/crsh/jcr/.

Source file: Importer.java

  18 
vote

public void file(String fileName,int length,InputStream data) throws IOException {
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setValidating(true);
    SAXParser parser=factory.newSAXParser();
    parser.parse(data,attributesHandler);
  }
 catch (  Exception e) {
    Safe.rethrow(IOException.class,e);
  }
}
 

Example 17

From project dcm4che, under directory /dcm4che-core/src/main/java/org/dcm4che/data/.

Source file: IOD.java

  18 
vote

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 18

From project DigitbooksExamples, under directory /DigitbooksExamples/src/fr/digitbooks/android/examples/chapitre08/.

Source file: DigitbooksGuestbookXml.java

  18 
vote

public List<HashMap<String,String>> parse(String xml) throws Exception {
  if (xml == null) {
    return null;
  }
  mData=new ArrayList<HashMap<String,String>>();
  InputSource inputSource=new InputSource(new StringReader(xml));
  SAXParserFactory spf=SAXParserFactory.newInstance();
  SAXParser sp=spf.newSAXParser();
  XMLReader xr=sp.getXMLReader();
  xr.setContentHandler(this);
  xr.parse(inputSource);
  return mData;
}
 

Example 19

From project Eclipse, under directory /com.mobilesorcery.sdk.core/src/com/mobilesorcery/sdk/core/.

Source file: LineReader.java

  18 
vote

@Override public final void stop(IOException ioe){
  Exception ex=ioe;
  if (ioe == null) {
    try {
      SAXParserFactory factory=SAXParserFactory.newInstance();
      SAXParser parser=factory.newSAXParser();
      parser.parse(new ByteArrayInputStream(buffer.toString().getBytes()),this);
    }
 catch (    Exception e) {
      ex=e;
    }
  }
  doStop(ex);
}
 

Example 20

From project entando-core-engine, under directory /src/main/java/com/agiletec/plugins/jacms/aps/system/services/resource/.

Source file: ResourceManager.java

  18 
vote

/** 
 * Valorizza una risorsa prototipo con gli elementi  dell'xml che rappresenta una risorsa specifica. 
 * @param resource Il prototipo di risorsa da specializzare con gli attributi dell'xml.
 * @param xml L'xml della risorsa specifica. 
 * @throws ApsSystemException
 */
protected void fillEmptyResourceFromXml(ResourceInterface resource,String xml) throws ApsSystemException {
  try {
    SAXParserFactory parseFactory=SAXParserFactory.newInstance();
    SAXParser parser=parseFactory.newSAXParser();
    InputSource is=new InputSource(new StringReader(xml));
    ResourceHandler handler=new ResourceHandler(resource,this.getCategoryManager());
    parser.parse(is,handler);
  }
 catch (  Throwable t) {
    ApsSystemUtils.logThrowable(t,this,"fillEmptyResourceFromXml");
    throw new ApsSystemException("Error loading resource",t);
  }
}
 

Example 21

From project faces_1, under directory /impl/src/main/java/org/jboss/seam/faces/projectstage/.

Source file: WebXmlContextParameterParser.java

  18 
vote

/** 
 * Parses the supplied web.xml  {@link InputStream}.
 * @param stream The stream to parse
 * @throws IOException for any errors during the parsing process
 */
public final void parse(InputStream stream) throws IOException {
  try {
    SAXParserFactory saxParserFactory=SAXParserFactory.newInstance();
    saxParserFactory.setNamespaceAware(true);
    SAXParser parser=saxParserFactory.newSAXParser();
    parser.parse(stream,this);
  }
 catch (  ParserConfigurationException e) {
    throw new IOException(e);
  }
catch (  SAXException e) {
    throw new IOException(e);
  }
}
 

Example 22

From project flexmojos, under directory /flexmojos-maven-plugin/src/main/java/net/flexmojos/oss/plugin/utilities/.

Source file: SourceFileResolver.java

  18 
vote

/** 
 * Parse an MXML file and returns true if the file is an application one
 * @param file the file to be parsed
 * @return true if the file is an application one
 */
private static boolean isApplicationFile(File file){
  try {
    SAXParser parser=SAXParserFactory.newInstance().newSAXParser();
    parser.getXMLReader().setFeature("http://xml.org/sax/features/namespaces",true);
    parser.getXMLReader().setFeature("http://xml.org/sax/features/namespace-prefixes",true);
    ApplicationHandler h=new ApplicationHandler();
    parser.parse(file,h);
    return h.isApplicationFile();
  }
 catch (  Exception e) {
    return false;
  }
}
 

Example 23

From project freemind, under directory /freemind/de/foltin/.

Source file: CompileXsdStart.java

  18 
vote

public void generate() throws ParserConfigurationException, SAXException, IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser saxParser=factory.newSAXParser();
  mCurrentHandler=new XsdHandler(null);
  mBindingXml.setLength(0);
  mBindingXml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><binding>\n");
  saxParser.parse(mInputStream,this);
  mBindingXml.append("</binding>\n");
}
 

Example 24

From project galaxyCar, under directory /AndroidColladaLoader/src/ckt/projects/acl/.

Source file: ColladaHandler.java

  18 
vote

public ArrayList<ColladaObject> parseFile(InputStream input){
  try {
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(input));
  }
 catch (  Exception e) {
  }
  ArrayList<ColladaObject> result=new ArrayList<ColladaObject>();
  result.add(new ColladaObject(vertices,indices,upAxis));
  return result;
}
 

Example 25

From project GenericKnimeNodes, under directory /com.genericworkflownodes.knime.base_plugin/src/com/genericworkflownodes/knime/config/.

Source file: CTDNodeConfigurationReader.java

  18 
vote

/** 
 * Initializes a SAXReader with the Param and CTD schema.
 * @return A fully configured {@link SAXReader}.
 * @throws SAXException See  {@link SAXReader} documentation.
 * @throws ParserConfigurationException See  {@link SAXReader} documentation.
 */
private SAXReader initializeSAXReader() throws SAXException, ParserConfigurationException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SchemaFactory schemaFactory=SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
  factory.setSchema(schemaFactory.newSchema(new Source[]{new StreamSource(SchemaProvider.class.getResourceAsStream("CTD.xsd")),new StreamSource(SchemaProvider.class.getResourceAsStream("Param_1_3.xsd"))}));
  SAXParser parser=factory.newSAXParser();
  SAXReader reader=new SAXReader(parser.getXMLReader());
  reader.setValidation(false);
  return reader;
}
 

Example 26

From project gh4a, under directory /src/com/gh4a/utils/.

Source file: RssParser.java

  18 
vote

public List<YourActionFeed> parse() throws Exception {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser parser=factory.newSAXParser();
  RssHandler handler=new RssHandler();
  parser.parse(this.getInputStream(),handler);
  return handler.getFeeds();
}
 

Example 27

From project gxa, under directory /annotator/src/main/java/uk/ac/ebi/gxa/annotator/loader/biomart/.

Source file: MartRegistry.java

  18 
vote

public static MartRegistry parse(InputStream in) throws SAXException, ParserConfigurationException, IOException {
  SAXParserFactory spf=SAXParserFactory.newInstance();
  SAXParser parser=spf.newSAXParser();
  XmlContentHandler handler=new XmlContentHandler();
  parser.parse(in,handler);
  return handler.getRegistry();
}
 

Example 28

From project Holo-Edit, under directory /holoedit/fileio/.

Source file: TjFileReader.java

  18 
vote

public void run(){
  SAXParserFactory factory=SAXParserFactory.newInstance();
  try {
    SAXParser saxParser=factory.newSAXParser();
    File f=new File(filename);
    saxParser.parse(f,this);
  }
 catch (  Throwable t) {
    error=true;
    t.printStackTrace();
    done=true;
  }
}
 

Example 29

From project ICS_LatinIME_QHD, under directory /tools/makedict/src/com/android/inputmethod/latin/.

Source file: XmlDictInputOutput.java

  18 
vote

/** 
 * Reads a dictionary from an XML file. This is the public method that will parse an XML file and return the corresponding memory representation.
 * @param unigrams the file to read the data from.
 * @return the in-memory representation of the dictionary.
 */
public static FusionDictionary readDictionaryXml(InputStream unigrams,InputStream bigrams) throws SAXException, IOException, ParserConfigurationException {
  final SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  final SAXParser parser=factory.newSAXParser();
  final BigramHandler bigramHandler=new BigramHandler();
  if (null != bigrams)   parser.parse(bigrams,bigramHandler);
  final FusionDictionary dict=new FusionDictionary();
  final UnigramHandler unigramHandler=new UnigramHandler(dict,bigramHandler.getBigramMap());
  parser.parse(unigrams,unigramHandler);
  return dict;
}
 

Example 30

From project jAPS2, under directory /src/com/agiletec/plugins/jacms/aps/system/services/resource/.

Source file: ResourceManager.java

  18 
vote

/** 
 * Valorizza una risorsa prototipo con gli elementi  dell'xml che rappresenta una risorsa specifica. 
 * @param resource Il prototipo di risorsa da specializzare con gli attributi dell'xml.
 * @param xml L'xml della risorsa specifica. 
 * @throws ApsSystemException
 */
protected void fillEmptyResourceFromXml(ResourceInterface resource,String xml) throws ApsSystemException {
  try {
    SAXParserFactory parseFactory=SAXParserFactory.newInstance();
    SAXParser parser=parseFactory.newSAXParser();
    InputSource is=new InputSource(new StringReader(xml));
    ResourceHandler handler=new ResourceHandler(resource,this.getCategoryManager());
    parser.parse(is,handler);
  }
 catch (  Throwable t) {
    ApsSystemUtils.logThrowable(t,this,"fillEmptyResourceFromXml");
    throw new ApsSystemException("Error loading resource",t);
  }
}
 

Example 31

From project jbosgi, under directory /testsuite/example/src/test/java/org/jboss/test/osgi/example/jaxp/.

Source file: SAXParserTestCase.java

  18 
vote

private void parse(SAXParserFactory factory) throws Exception {
  factory.setNamespaceAware(true);
  factory.setValidating(false);
  SAXParser saxParser=factory.newSAXParser();
  URL resURL=bundle.getResource("simple.xml");
  SAXHandler saxHandler=new SAXHandler();
  saxParser.parse(resURL.openStream(),saxHandler);
  assertEquals("content",saxHandler.getContent());
}
 

Example 32

From project jbosgi-framework, under directory /itest/src/test/java/org/jboss/test/osgi/framework/classloader/support/.

Source file: JavaXMLParserActivator.java

  18 
vote

@Override public void start(BundleContext context) throws Exception {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser saxParser=factory.newSAXParser();
  ByteArrayInputStream input=new ByteArrayInputStream(TEST_XML.getBytes());
  saxParser.parse(input,new Myhandler());
}
 

Example 33

From project jboss-modules, under directory /src/test/java/org/jboss/modules/.

Source file: JAXPModuleTest.java

  18 
vote

public void checkSax(Class<?> clazz,boolean fake) throws Exception {
  SAXParser parser=invokeMethod(clazz.newInstance(),"saxParser");
  SAXParserFactory factory=invokeMethod(clazz.newInstance(),"saxParserFactory");
  Assert.assertEquals(__SAXParserFactory.class.getName(),factory.getClass().getName());
  if (fake) {
    Assert.assertEquals(FakeSAXParser.class.getName(),parser.getClass().getName());
  }
 else {
    Assert.assertSame(SAXParserFactory.newInstance().newSAXParser().getClass(),parser.getClass());
  }
}
 

Example 34

From project jdcbot, under directory /src/org/elite/jdcbot/shareframework/.

Source file: FilelistConverter.java

  18 
vote

public FLDir parse() throws ParserConfigurationException, SAXException, IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser parser=factory.newSAXParser();
  FilelistHandler handler=new FilelistHandler();
  parser.parse(this,handler);
  return fl;
}
 

Example 35

From project jgraphx, under directory /src/com/mxgraph/reader/.

Source file: mxGraphViewImageReader.java

  18 
vote

/** 
 * Creates the image for the given display XML input source. (Note: The XML is an encoded mxGraphView, not mxGraphModel.)
 * @param inputSource Input source that contains the display XML.
 * @return Returns an image representing the display XML input source.
 */
public static BufferedImage convert(InputSource inputSource,mxGraphViewImageReader viewReader) throws ParserConfigurationException, SAXException, IOException {
  BufferedImage result=null;
  SAXParser parser=SAXParserFactory.newInstance().newSAXParser();
  XMLReader reader=parser.getXMLReader();
  reader.setContentHandler(viewReader);
  reader.parse(inputSource);
  if (viewReader.getCanvas() instanceof mxImageCanvas) {
    result=((mxImageCanvas)viewReader.getCanvas()).destroy();
  }
  return result;
}
 

Example 36

From project jsword, under directory /src/main/java/org/crosswire/common/xml/.

Source file: StringSAXEventProvider.java

  18 
vote

/** 
 * Simple ctor
 */
public StringSAXEventProvider(String xmlstr) throws ParserConfigurationException, SAXException {
  this.xmlstr=xmlstr;
  SAXParserFactory fact=SAXParserFactory.newInstance();
  SAXParser parser=fact.newSAXParser();
  reader=parser.getXMLReader();
}
 

Example 37

From project jugglingLab, under directory /source/jugglinglab/jml/.

Source file: JMLParser.java

  18 
vote

public void parse(Reader read) throws SAXException, IOException {
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setValidating(true);
    SAXParser parser=factory.newSAXParser();
    parser.parse(new InputSource(read),this);
  }
 catch (  ParserConfigurationException pce) {
    throw new SAXException(pce.getMessage());
  }
}
 

Example 38

From project junithelper, under directory /core/src/main/java/org/junithelper/core/config/extension/.

Source file: ExtConfigurationLoader.java

  18 
vote

public ExtConfiguration load(InputStream inputStream) throws Exception {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser parser=factory.newSAXParser();
  ExtConfigurationParserHandler handler=new ExtConfigurationParserHandler();
  parser.parse(inputStream,handler);
  return handler.getExtConfiguration();
}
 

Example 39

From project kabeja, under directory /core/src/main/java/org/kabeja/parser/xml/.

Source file: AbstractSAXParser.java

  18 
vote

public void parse(InputStream input,DraftDocument doc,Map properties) throws ParseException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  try {
    factory.setNamespaceAware(true);
    SAXParser parser=factory.newSAXParser();
    this.doc=doc;
    parser.parse(input,this);
  }
 catch (  Exception e) {
    throw new ParseException(e);
  }
}
 

Example 40

From project litle-sdk-for-java, under directory /lib/xerces-2_11_0/samples/simpletype/.

Source file: DatatypeInterfaceUsage.java

  18 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  if (args.length == 2) {
    SAXParserFactory fact=SAXParserFactory.newInstance();
    fact.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new File(args[0])));
    SAXParser parser=fact.newSAXParser();
    PSVIProvider p=(PSVIProvider)parser.getXMLReader();
    parser.parse(args[1],new DatatypeInterfaceUsage(p));
  }
 else   printUsage();
}
 

Example 41

From project makegood, under directory /com.piece_framework.makegood.core/src/com/piece_framework/makegood/core/run/.

Source file: ResultReader.java

  18 
vote

public void read() throws ParserConfigurationException, SAXException, IOException {
  if (!log.exists()) {
    log.createNewFile();
  }
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser parser=factory.newSAXParser();
  stream=new SynchronizedFileInputStream(log);
  parser.parse(stream,this);
}
 

Example 42

From project maven-surefire, under directory /maven-surefire-report-plugin/src/main/java/org/apache/maven/plugins/surefire/report/.

Source file: TestSuiteXmlParser.java

  18 
vote

public Collection<ReportTestSuite> parse(String xmlPath) throws ParserConfigurationException, SAXException, IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser saxParser=factory.newSAXParser();
  classesToSuites=new HashMap<String,ReportTestSuite>();
  saxParser.parse(new File(xmlPath),this);
  if (currentSuite != defaultSuite) {
    if (defaultSuite.getNumberOfTests() == 0) {
      classesToSuites.remove(defaultSuite.getFullClassName());
    }
  }
  return classesToSuites.values();
}
 

Example 43

From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/news/.

Source file: NewsModel.java

  18 
vote

private List<NewsItem> parseNewsItems(InputStream stream){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    NewsHandler handler=new NewsHandler();
    parser.parse(stream,handler);
    return handler.getNewsItems();
  }
 catch (  Exception e) {
    Log.d("NewsParser","RuntimeException");
    e.printStackTrace();
  }
  return null;
}
 

Example 44

From project mobilis, under directory /MobilisServer/src/de/tudresden/inf/rn/mobilis/server/deployment/helper/.

Source file: MSDLReader.java

  18 
vote

/** 
 * Gets the service dependencies.
 * @param msdlFile the msdl file which should be queried
 * @return the service dependencies
 */
public static List<ServiceDependency> getServiceDependencies(File msdlFile){
  List<ServiceDependency> resultList=new ArrayList<MSDLReader.ServiceDependency>();
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser saxParser=factory.newSAXParser();
    SAXServiceDependencyHandler saxHandler=new MSDLReader.SAXServiceDependencyHandler();
    saxParser.parse(msdlFile.getAbsolutePath(),saxHandler);
    resultList=saxHandler.getResultList();
  }
 catch (  Exception e) {
    MobilisManager.getLogger().log(Level.WARNING,String.format("Exception while reading the service dependencies from msdl: %s",e.getMessage()));
  }
  return resultList;
}
 

Example 45

From project modello, under directory /modello-plugins/modello-plugin-xsd/src/test/java/org/codehaus/modello/plugin/xsd/.

Source file: ModelloXsdGeneratorTest.java

  18 
vote

public void testXsdGenerator() throws Throwable {
  ModelloCore modello=(ModelloCore)lookup(ModelloCore.ROLE);
  Properties parameters=getModelloParameters("1.4.0");
  Model model=modello.loadModel(getTestFile("../../src/main/mdo/modello.mdo"));
  modello.generate(model,"xsd",parameters);
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setValidating(true);
  factory.setNamespaceAware(true);
  SAXParser saxParser=factory.newSAXParser();
  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema");
  saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",new File(getOutputDirectory(),"modello-1.4.0.xsd"));
  saxParser.parse(getTestFile("../../src/main/mdo/modello.mdo"),new Handler());
  saxParser.parse(getClass().getResourceAsStream("/features.mdo"),new Handler());
}
 

Example 46

From project mwe, under directory /plugins/org.eclipse.emf.mwe.core/src/org/eclipse/emf/mwe/internal/core/ast/parser/.

Source file: WorkflowParser.java

  18 
vote

public AbstractASTBase parse(final InputStream in,final String resourceName,final Issues issues){
  resource=resourceName;
  this.issues=issues;
  try {
    final SAXParser parser=SAXParserFactory.newInstance().newSAXParser();
    parser.parse(in,this);
  }
 catch (  final Exception e) {
    root=null;
    log.error(e.getMessage(),e);
    issues.addError(e.getMessage(),resourceName);
  }
  return root;
}
 

Example 47

From project mylyn.docs, under directory /org.eclipse.mylyn.docs.epub.core/src/org/eclipse/mylyn/internal/docs/epub/core/.

Source file: MetadataScanner.java

  18 
vote

public static void parse(InputSource file,Metadata metadata) throws ParserConfigurationException, SAXException, IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setFeature("http://xml.org/sax/features/validation",false);
  factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
  SAXParser parser=factory.newSAXParser();
  MetadataScanner tocGenerator=new MetadataScanner(metadata);
  try {
    parser.parse(file,tocGenerator);
  }
 catch (  SAXException e) {
    e.printStackTrace();
  }
}
 

Example 48

From project nodebox, under directory /src/main/java/nodebox/versioncheck/.

Source file: UpdateChecker.java

  18 
vote

private Appcast parseAppcastXML(InputStream is) throws Exception {
  SAXParserFactory spf=SAXParserFactory.newInstance();
  SAXParser parser=spf.newSAXParser();
  AppcastHandler handler=new AppcastHandler();
  parser.parse(is,handler);
  return handler.getAppcast();
}
 

Example 49

From project PageTurner, under directory /src/main/java/net/nightwhistler/nucular/parser/.

Source file: Nucular.java

  18 
vote

private static void parseStream(ElementParser rootElementsParser,InputStream stream) throws ParserConfigurationException, SAXException, IOException {
  SAXParserFactory parseFactory=SAXParserFactory.newInstance();
  SAXParser xmlParser=parseFactory.newSAXParser();
  XMLReader xmlIn=xmlParser.getXMLReader();
  StreamParser catalogParser=new StreamParser(rootElementsParser);
  xmlIn.setContentHandler(catalogParser);
  xmlIn.parse(new InputSource(stream));
}
 

Example 50

From project phing-eclipse, under directory /org.ganoro.phing.core/src/org/ganoro/phing/core/contentDescriber/.

Source file: AntHandler.java

  18 
vote

/** 
 * Creates a new SAX parser for use within this instance.
 * @return The newly created parser.
 * @throws ParserConfigurationException If a parser of the given configuration cannot be created.
 * @throws SAXException If something in general goes wrong when creating the parser.
 */
private final SAXParser createParser(SAXParserFactory parserFactory) throws ParserConfigurationException, SAXException, SAXNotRecognizedException, SAXNotSupportedException {
  final SAXParser parser=parserFactory.newSAXParser();
  final XMLReader reader=parser.getXMLReader();
  try {
    reader.setFeature("http://xml.org/sax/features/validation",false);
    reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
  }
 catch (  SAXNotRecognizedException e) {
  }
catch (  SAXNotSupportedException e) {
  }
  return parser;
}
 

Example 51

From project reader, under directory /src/com/quietlycoding/android/reader/parser/.

Source file: PostListParser.java

  18 
vote

public long syncDb(Handler h,long id,String feedUrl) throws Exception {
  mId=id;
  mUrl=feedUrl;
  final SAXParserFactory fact=SAXParserFactory.newInstance();
  final SAXParser sp=fact.newSAXParser();
  final XMLReader reader=sp.getXMLReader();
  reader.setContentHandler(this);
  reader.setErrorHandler(this);
  final URL url=new URL(mUrl);
  final URLConnection c=url.openConnection();
  c.setRequestProperty("User-Agent","Android/1.5");
  reader.parse(new InputSource(c.getInputStream()));
  return mId;
}
 

Example 52

From project repose, under directory /project-set/components/translation/src/main/java/com/rackspace/papi/components/translation/xslt/xmlfilterchain/.

Source file: XmlFilterChainBuilder.java

  18 
vote

protected XMLReader getSaxReader() throws ParserConfigurationException, SAXException {
  SAXParserFactory spf=SAXParserFactory.newInstance();
  spf.setValidating(true);
  spf.setNamespaceAware(true);
  SAXParser parser=spf.newSAXParser();
  XMLReader reader=parser.getXMLReader();
  return reader;
}
 

Example 53

From project RomRaider, under directory /src/com/romraider/util/.

Source file: SaxParserFactory.java

  18 
vote

public static void main(String args[]){
  try {
    SAXParser parser=SaxParserFactory.getSaxParser();
    BufferedInputStream b=new BufferedInputStream(new FileInputStream(new File("/ecu_defs.xml")));
    System.out.println(b.available());
    parser.parse(b,new DefaultHandler());
    System.out.println(parser.isValidating());
  }
 catch (  Exception ex) {
    System.err.println(ex);
  }
}
 

Example 54

From project sandbox, under directory /xwiki-wikiimporter/xwiki-wikiimporter-mediawiki-xml/src/main/java/org/xwiki/wikiimporter/internal/mediawiki/.

Source file: MediaWikiXmlImporter.java

  18 
vote

/** 
 * Parses MediaWiki XML using a SAX Parser
 * @param xmlFilePath the absolute path to the XML file.
 * @param listener {@link WikiImporterListener} which listens to events generated by parser.
 * @throws MediaWikiImporterException in case of any errors parsing the XML file.
 */
private void parseWikiDumpXml(MediaWikiImportParameters params,WikiImporterListener listener) throws MediaWikiImporterException {
  String xmlFilePath=params.getSrcPath();
  File file=new File(xmlFilePath);
  try {
    MediaWikiXmlHandler handler=new MediaWikiXmlHandler(this.componentManager,listener);
    SAXParser saxParser=this.saxParserFactory.newSAXParser();
    saxParser.parse(file,handler);
  }
 catch (  Exception e) {
    throw new MediaWikiImporterException("Error while parsing the MediaWiki XML Dump File",e);
  }
}
 

Example 55

From project SanDisk-HQME-SDK, under directory /projects/HqmeService/project/src/com/hqme/cm/core/.

Source file: Policy.java

  18 
vote

protected void fromString(String xmlContent){
  if (xmlContent != null && xmlContent.length() > 0)   try {
    PolicyParser parser=new PolicyParser();
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    xr.setContentHandler(parser);
    xr.parse(new InputSource(new StringReader(xmlContent)));
  }
 catch (  Exception fault) {
    CmClientUtil.debugLog(getClass(),"fromString",fault);
    throw new IllegalArgumentException(fault);
  }
}
 

Example 56

From project scufl2, under directory /scufl2-ucfpackage/src/main/java/uk/org/taverna/scufl2/ucfpackage/impl/odfdom/pkg/.

Source file: OdfXMLHelper.java

  18 
vote

/** 
 * create an XMLReader with a Resolver set to parse content in a ODF Package
 * @param pkg the ODF Package
 * @return a SAX XMLReader
 * @throws SAXException
 * @throws ParserConfigurationException
 */
public XMLReader newXMLReader(OdfPackage pkg) throws SAXException, ParserConfigurationException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  factory.setValidating(false);
  SAXParser parser=factory.newSAXParser();
  XMLReader xmlReader=parser.getXMLReader();
  xmlReader.setFeature("http://xml.org/sax/features/namespaces",true);
  xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
  xmlReader.setFeature("http://xml.org/sax/features/xmlns-uris",true);
  xmlReader.setEntityResolver(pkg.getEntityResolver());
  return xmlReader;
}
 

Example 57

From project android-context, under directory /src/edu/fsu/cs/contextprovider/monitor/.

Source file: WeatherMonitor.java

  17 
vote

@Override public void run(){
  weatherZip=LocationMonitor.getZip();
  URL url;
  try {
    String tmpStr=null;
    String cityParamString=weatherZip;
    Log.d(TAG,"cityParamString: " + cityParamString);
    String queryString="http://www.google.com/ig/api?weather=" + cityParamString;
    url=new URL(queryString.replace(" ","%20"));
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    gwh=new GoogleWeatherHandler();
    xr.setContentHandler(gwh);
    xr.parse(new InputSource(url.openStream()));
    ws=gwh.getWeatherSet();
    if (ws == null)     return;
    WeatherCurrentCondition wcc=ws.getWeatherCurrentCondition();
    if (wcc != null) {
      weatherTemp=null;
      Integer weatherTempInt=wcc.getTempFahrenheit();
      if (weatherTempInt != null) {
        weatherTemp=weatherTempInt;
      }
      weatherCond=wcc.getCondition();
      weatherHumid=wcc.getHumidity();
      weatherWindCond=wcc.getWindCondition();
      weatherHazard=calcHazard();
    }
  }
 catch (  Exception e) {
    Log.e(TAG,"WeatherQueryError",e);
  }
}
 

Example 58

From project android-rackspacecloud, under directory /src/com/rackspace/cloud/servers/api/client/.

Source file: FlavorManager.java

  17 
vote

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 59

From project android-rss, under directory /src/main/java/org/mcsoxford/rss/.

Source file: RSSParser.java

  17 
vote

/** 
 * 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 60

From project AndroidExamples, under directory /RSSExample/src/com/robertszkutak/androidexamples/rss/.

Source file: RSSExampleActivity.java

  17 
vote

@Override protected RSSFeed doInBackground(String... RSSuri){
  try {
    URL url=new URL(RSSuri[0]);
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    XMLReader xmlreader=parser.getXMLReader();
    RSSHandler theRssHandler=new RSSHandler();
    xmlreader.setContentHandler(theRssHandler);
    InputSource is=new InputSource(url.openStream());
    xmlreader.parse(is);
    return theRssHandler.getFeed();
  }
 catch (  Exception ee) {
    return null;
  }
}
 

Example 61

From project AudioBox.fm-JavaLib, under directory /audiobox.fm-core/src/main/java/fm/audiobox/configurations/.

Source file: DefaultResponseParser.java

  17 
vote

@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 62

From project BBC-News-Reader, under directory /src/org/mcsoxford/rss/.

Source file: RSSParser.java

  17 
vote

/** 
 * 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 63

From project BDSup2Sub, under directory /src/main/java/bdsup2sub/supstream/bdnxml/.

Source file: SupXml.java

  17 
vote

/** 
 * 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 64

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/.

Source file: AmazonManager.java

  17 
vote

/** 
 * 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 65

From project closure-templates, under directory /java/src/com/google/template/soy/xliffmsgplugin/.

Source file: XliffParser.java

  17 
vote

/** 
 * 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 66

From project Cloud9, under directory /src/dist/edu/umd/hooka/corpora/.

Source file: ParallelCorpusReader.java

  17 
vote

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 67

From project core_5, under directory /exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/.

Source file: XMLDocumentReader.java

  17 
vote

/** 
 * 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 68

From project Cours-3eme-ann-e, under directory /XML/examples/sax/.

Source file: SAXExample1.java

  17 
vote

public static void main(String args[]) throws ParserConfigurationException, SAXException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setValidating(true);
  System.out.println(factory.getClass().getName());
  SAXParser saxParser=factory.newSAXParser();
  System.out.println(saxParser.getClass().getName());
  XMLReader xmlReader=saxParser.getXMLReader();
  System.out.println(xmlReader.getClass().getName());
  DefaultHandler handler=new DefaultHandler();
  xmlReader.setContentHandler(handler);
  xmlReader.setErrorHandler(handler);
  try {
    xmlReader.parse(args[0]);
    System.out.println("Everything is ok !");
  }
 catch (  IOException e) {
    System.err.println("I/O error: " + e.getMessage());
  }
catch (  SAXException e) {
    System.err.println("Parsing error: " + e.getMessage());
  }
}
 

Example 69

From project dreamDroid, under directory /src/net/reichholf/dreamdroid/parsers/.

Source file: GenericSaxParser.java

  17 
vote

@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 70

From project DrmLicenseService, under directory /src/com/sonyericsson/android/drm/drmlicenseservice/.

Source file: CustomDataParser.java

  17 
vote

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;
}
 

Example 71

From project E12Planner, under directory /src/com/neoware/europlanner/.

Source file: E12DataService.java

  17 
vote

private boolean dataIsValid(String data){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    XMLReader reader=parser.getXMLReader();
    reader.parse(new InputSource(new ByteArrayInputStream(data.getBytes())));
  }
 catch (  SAXException ex) {
    return false;
  }
catch (  IOException ex) {
    return false;
  }
catch (  ParserConfigurationException ex) {
    return false;
  }
  return true;
}
 

Example 72

From project EasySOA, under directory /easysoa-registry/easysoa-registry-web/src/main/java/org/easysoa/beans/.

Source file: EasySOAImportBean.java

  17 
vote

private DocumentModel importSoapUIConf(){
  File soapUIConfFile=null;
  try {
    soapUIConfFile=transferBlobToFile();
    if (soapUIConfFile != null) {
      EasySOALocalApi api=new EasySOALocalApi(documentManager);
      EasySOAImportSoapUIParser soapUiParser=new EasySOAImportSoapUIParser(api,targetWorkspaceModel.getTitle());
      SAXParserFactory factory=SAXParserFactory.newInstance();
      SAXParser saxParser=factory.newSAXParser();
      saxParser.parse(soapUIConfFile,soapUiParser);
      return targetWorkspaceModel;
    }
  }
 catch (  Exception e) {
    log.error("Failed to import SoapUI configuration",e);
  }
 finally {
    if (soapUIConfFile != null) {
      soapUIConfFile.delete();
    }
  }
  return null;
}
 

Example 73

From project eclim, under directory /org.eclim.core/java/org/eclim/plugin/core/util/.

Source file: XmlUtils.java

  17 
vote

/** 
 * Validate the supplied xml file.
 * @param project The project name.
 * @param filename The file path to the xml file.
 * @param schema True to use schema validation relying on thexsi:schemaLocation attribute of the document.
 * @param handler The content handler to use while parsing the file.
 * @return A possibly empty list of errors.
 */
public static List<Error> validateXml(String project,String filename,boolean schema,DefaultHandler handler) throws Exception {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  factory.setValidating(true);
  if (schema) {
    factory.setFeature("http://apache.org/xml/features/validation/schema",true);
    factory.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
  }
  SAXParser parser=factory.newSAXParser();
  filename=ProjectUtils.getFilePath(project,filename);
  filename=filename.replace('\\','/');
  ErrorAggregator errorHandler=new ErrorAggregator(filename);
  EntityResolver entityResolver=new EntityResolver(FileUtils.getFullPath(filename));
  try {
    parser.parse(new File(filename),getHandler(handler,errorHandler,entityResolver));
  }
 catch (  SAXParseException spe) {
    ArrayList<Error> errors=new ArrayList<Error>();
    errors.add(new Error(spe.getMessage(),filename,spe.getLineNumber(),spe.getColumnNumber(),false));
    return errors;
  }
  return errorHandler.getErrors();
}
 

Example 74

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.core/src/org/springsource/ide/eclipse/commons/core/.

Source file: SpringCoreUtils.java

  17 
vote

public static SAXParser getSaxParser(){
  if (!SAX_PARSER_ERROR) {
    try {
      SAXParserFactory factory=SAXParserFactory.newInstance();
      factory.setNamespaceAware(true);
      SAXParser parser=factory.newSAXParser();
      return parser;
    }
 catch (    Exception e) {
      StatusHandler.log(new Status(IStatus.INFO,CorePlugin.PLUGIN_ID,"Error creating SaxParserFactory. Switching to OSGI service reference."));
      SAX_PARSER_ERROR=true;
    }
  }
  BundleContext bundleContext=CorePlugin.getDefault().getBundle().getBundleContext();
  ServiceReference reference=bundleContext.getServiceReference(SAXParserFactory.class.getName());
  if (reference != null) {
    try {
synchronized (SAX_PARSER_LOCK) {
        SAXParserFactory factory=(SAXParserFactory)bundleContext.getService(reference);
        return factory.newSAXParser();
      }
    }
 catch (    Exception e) {
      StatusHandler.log(new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,"Error creating SaxParserFactory",e));
    }
 finally {
      bundleContext.ungetService(reference);
    }
  }
  return null;
}
 

Example 75

From project encog-java-core, under directory /src/main/java/org/encog/ml/bayesian/bif/.

Source file: BIFUtil.java

  17 
vote

/** 
 * Read a BIF file from a stream.
 * @param is The stream to read from.
 * @return The Bayesian network read.
 */
public static BayesianNetwork readBIF(InputStream is){
  try {
    BIFHandler h=new BIFHandler();
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    sp.parse(is,h);
    return h.getNetwork();
  }
 catch (  IOException ex) {
    throw new BayesianError(ex);
  }
catch (  ParserConfigurationException ex) {
    throw new BayesianError(ex);
  }
catch (  SAXException ex) {
    throw new BayesianError(ex);
  }
}
 

Example 76

From project flexymind-alpha, under directory /src/com/larvalabs/svgandroid/.

Source file: SVGParser.java

  17 
vote

private static SVG parse(InputStream in,Integer searchColor,Integer replaceColor,boolean whiteMode) throws SVGParseException {
  try {
    long start=System.currentTimeMillis();
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    final Picture picture=new Picture();
    SVGHandler handler=new SVGHandler(picture);
    handler.setColorSwap(searchColor,replaceColor);
    handler.setWhiteMode(whiteMode);
    xr.setContentHandler(handler);
    xr.parse(new InputSource(in));
    SVG result=new SVG(picture,handler.bounds);
    if (!Float.isInfinite(handler.limits.top)) {
      result.setLimits(handler.limits);
    }
    return result;
  }
 catch (  Exception e) {
    throw new SVGParseException(e);
  }
}
 

Example 77

From project FlipDroid, under directory /app/src/com/goal98/flipdroid2/model/google/.

Source file: RssParser.java

  17 
vote

public void parse(){
  SAXParserFactory spf=null;
  SAXParser sp=null;
  spf=SAXParserFactory.newInstance();
  try {
    InputSource is=new InputSource(new InputStreamReader(content,"utf-8"));
    if (spf != null) {
      sp=spf.newSAXParser();
      sp=spf.newSAXParser();
      sp.parse(is,this);
    }
  }
 catch (  ParserConfigurationException e) {
    e.printStackTrace();
  }
catch (  SAXException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    try {
    }
 catch (    Exception e) {
    }
  }
}
 

Example 78

From project God-Save-The-Bag, under directory /src/com/estudio/cheke/game/gstb/.

Source file: SVGParser.java

  17 
vote

private static SVG parse(InputStream in,Integer searchColor,Integer replaceColor,boolean whiteMode) throws SVGParseException {
  SVGHandler svgHandler=null;
  try {
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    final Picture picture=new Picture();
    svgHandler=new SVGHandler(picture);
    svgHandler.setColorSwap(searchColor,replaceColor);
    svgHandler.setWhiteMode(whiteMode);
    CopyInputStream cin=new CopyInputStream(in);
    IDHandler idHandler=new IDHandler();
    xr.setContentHandler(idHandler);
    xr.parse(new InputSource(cin.getCopy()));
    svgHandler.idXml=idHandler.idXml;
    xr.setContentHandler(svgHandler);
    xr.parse(new InputSource(cin.getCopy()));
    SVG result=new SVG(picture,svgHandler.bounds);
    if (!Float.isInfinite(svgHandler.limits.top)) {
      result.setLimits(svgHandler.limits);
    }
    return result;
  }
 catch (  Exception e) {
    throw new SVGParseException(e);
  }
}
 

Example 79

From project guj.com.br, under directory /src/net/jforum/security/.

Source file: XMLPermissionControl.java

  17 
vote

/** 
 * @return <code>List</code> object containing <code>Section</code> objects. Each<code>Section</code>  contains many <code>PermissionItem</code> objects,  which represent the permission elements of some section. For its turn, the <code>PermissionItem</code> objects have many <code>FormSelectedData</code> objects, which are the ones responsible to store field values, and which values are checked and which not.
 * @param xmlFile String
 */
public List loadConfigurations(String xmlFile){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setValidating(false);
    SAXParser parser=factory.newSAXParser();
    File fileInput=new File(xmlFile);
    if (fileInput.exists()) {
      parser.parse(fileInput,this);
    }
 else {
      InputSource inputSource=new InputSource(xmlFile);
      parser.parse(inputSource,this);
    }
    return this.listSections;
  }
 catch (  Exception e) {
    throw new ForumException(e);
  }
}
 

Example 80

From project HapiPodcastJ, under directory /src/info/xuluan/podcast/parser/.

Source file: FeedParser.java

  17 
vote

public void parse(InputStream input,DefaultHandler handler){
  try {
    SAXParser parser=saxParserFactory.newSAXParser();
    parser.parse(input,handler);
  }
 catch (  SAXException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
catch (  ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
 finally {
    if (input != null) {
      try {
        input.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
 

Example 81

From project hdiv, under directory /hdiv-config/src/main/java/org/hdiv/config/validations/.

Source file: DefaultValidationParser.java

  17 
vote

/** 
 * Read xml file from the given path.
 * @param filePath xml file path
 */
public void readDefaultValidations(String filePath){
  try {
    ClassLoader classLoader=DefaultValidationParser.class.getClassLoader();
    InputStream is=classLoader.getResourceAsStream(filePath);
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    sp.parse(is,this);
  }
 catch (  ParserConfigurationException e) {
    throw new HDIVException(e.getMessage());
  }
catch (  SAXException e) {
    throw new HDIVException(e.getMessage());
  }
catch (  IOException e) {
    throw new HDIVException(e.getMessage());
  }
}
 

Example 82

From project ISAconfigurator, under directory /src/main/java/org/isatools/isacreatorconfigurator/configui/io/xml/.

Source file: SimpleXMLParser.java

  17 
vote

public void parseStructureFile(){
  SAXParserFactory spf=SAXParserFactory.newInstance();
  try {
    SAXParser sp=spf.newSAXParser();
    sp.parse(fileLocation,this);
  }
 catch (  SAXException se) {
    log.error("SAX Exception Caught: \n Details are: \n" + se.getMessage());
  }
catch (  ParserConfigurationException pce) {
    log.error("Parser Configuration Exception Caught: \n Details are: \n" + pce.getMessage());
  }
catch (  IOException ioe) {
    log.error("File not found: \n Details are: \n" + ioe.getMessage());
  }
}
 

Example 83

From project ISAcreator, under directory /src/main/java/org/isatools/isacreator/ontologymanager/bioportal/xmlresulthandlers/.

Source file: BioPortalOntologyListResultHandler.java

  17 
vote

/** 
 * Parse the config.xml file
 * @param fileLoc - location of file to be parsed!
 */
public List<Ontology> parseFile(String fileLoc){
  result=new ArrayList<Ontology>();
  SAXParserFactory spf=SAXParserFactory.newInstance();
  try {
    SAXParser sp=spf.newSAXParser();
    sp.parse(fileLoc,this);
    return result;
  }
 catch (  SAXException se) {
    log.error("SAX Exception Caught: \n Details are: \n" + se.getMessage());
  }
catch (  ParserConfigurationException pce) {
    log.error("Parser Configuration Exception Caught: \n Details are: \n" + pce.getMessage());
  }
catch (  IOException ioe) {
    log.error("File not found: \n Details are: \n" + ioe.getMessage());
  }
  return null;
}
 

Example 84

From project JaamSim, under directory /com/eteks/sweethome3d/j3d/.

Source file: DAELoader.java

  17 
vote

/** 
 * Returns the scene parsed from a Collada XML stream. 
 */
private Scene parseXMLStream(InputStream in,URL baseUrl) throws IOException {
  try {
    SceneBase scene=new SceneBase();
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setValidating(false);
    SAXParser saxParser=factory.newSAXParser();
    saxParser.parse(in,new DAEHandler(scene,baseUrl));
    return scene;
  }
 catch (  ParserConfigurationException ex) {
    IOException ex2=new IOException("Can't parse XML stream");
    ex2.initCause(ex);
    throw ex2;
  }
catch (  SAXException ex) {
    IOException ex2=new IOException("Can't parse XML stream");
    ex2.initCause(ex);
    throw ex2;
  }
}
 

Example 85

From project jangaroo-tools, under directory /exml/exml-compiler/src/main/java/net/jangaroo/exml/parser/.

Source file: ExmlToModelParser.java

  17 
vote

private Document buildDom(InputStream inputStream) throws SAXException, IOException {
  SAXParser parser;
  final Document doc;
  try {
    final SAXParserFactory saxFactory=SAXParserFactory.newInstance();
    saxFactory.setNamespaceAware(true);
    parser=saxFactory.newSAXParser();
    DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    doc=factory.newDocumentBuilder().newDocument();
  }
 catch (  ParserConfigurationException e) {
    throw new IllegalStateException("a default dom builder should be provided",e);
  }
  PreserveLineNumberHandler handler=new PreserveLineNumberHandler(doc);
  parser.parse(inputStream,handler);
  return doc;
}
 

Example 86

From project jboss-jstl-api_spec, under directory /src/main/java/javax/servlet/jsp/jstl/tlv/.

Source file: PermittedTaglibsTLV.java

  17 
vote

public synchronized ValidationMessage[] validate(String prefix,String uri,PageData page){
  try {
    this.uri=uri;
    permittedTaglibs=readConfiguration();
    DefaultHandler h=new PermittedTaglibsHandler();
    SAXParserFactory f=SAXParserFactory.newInstance();
    f.setValidating(true);
    SAXParser p=f.newSAXParser();
    p.parse(page.getInputStream(),h);
    if (failed)     return vmFromString("taglib " + prefix + " ("+ uri+ ") allows only the "+ "following taglibs to be imported: "+ permittedTaglibs);
 else     return null;
  }
 catch (  SAXException ex) {
    return vmFromString(ex.toString());
  }
catch (  ParserConfigurationException ex) {
    return vmFromString(ex.toString());
  }
catch (  IOException ex) {
    return vmFromString(ex.toString());
  }
}
 

Example 87

From project jbossportletbridge, under directory /core/portletbridge-impl/src/main/java/org/jboss/portletbridge/config/.

Source file: FacesConfigProcessor.java

  17 
vote

protected void parse(InputStream facesConfig,ParsingLocation location) throws ParsingException {
  try {
    SAXParser parser=saxFactory.newSAXParser();
    XMLReader reader=parser.getXMLReader();
    FacesConfigHandler facesConfigHandler=new FacesConfigHandler(reader);
    reader.setContentHandler(facesConfigHandler);
    reader.setEntityResolver(WebXmlProcessor.NULL_RESOLVER);
    reader.setErrorHandler(facesConfigHandler);
    reader.setDTDHandler(facesConfigHandler);
    reader.parse(new InputSource(facesConfig));
    excludedAttributes.addAll(facesConfigHandler.getExcludedAttributes());
    publicParameterMapping.putAll(facesConfigHandler.getParameterMapping());
    if (location.equals(ParsingLocation.CLASSPATH) || location.equals(ParsingLocation.DEFAULT)) {
      writeBehindRenderResponseWrapper=facesConfigHandler.getRenderResponseWrapperClass();
      writeBehindResourceResponseWrapper=facesConfigHandler.getResourceResponseWrapperClass();
    }
 else     if (location.equals(ParsingLocation.OPTIONAL)) {
      if (null == writeBehindRenderResponseWrapper) {
        writeBehindRenderResponseWrapper=facesConfigHandler.getRenderResponseWrapperClass();
      }
      if (null == writeBehindResourceResponseWrapper) {
        writeBehindResourceResponseWrapper=facesConfigHandler.getResourceResponseWrapperClass();
      }
    }
  }
 catch (  ParserConfigurationException e) {
    throw new ParsingException("SAX Parser configuration error",e);
  }
catch (  SAXException e) {
    logger.log(java.util.logging.Level.WARNING,"Exception at faces-config.xml parsing",e);
  }
catch (  IOException e) {
    logger.log(java.util.logging.Level.WARNING,"Exception at faces-config.xml parsing",e);
  }
}
 

Example 88

From project jentrata-msh, under directory /Clients/Corvus.WSClient/src/main/java/hk/hku/cecid/corvus/http/.

Source file: PartnershipOpVerifer.java

  17 
vote

/** 
 * Validate the HTML content received after executed partnership operation. The content is passed as a input stream <code>ins</code>. <br/><br/> This operation is quite expensive because it first transform the whole HTML content received to a well-formed XHTML before parsing by the SAX Parser.  
 * @param ins The HTML content to validate the result of partnership operation  
 * @throws SAXException <ol> <li>When unable to down-load the HTML DTD from the web. Check your Internet connectivity</li> <li>When IO related problems occur</li> </ol>
 * @throws ParserConfigurationException When SAX parser mis-configures. 
 */
public void validate(InputStream ins) throws SAXException, ParserConfigurationException {
  if (ins == null)   throw new NullPointerException("Missing 'input stream' for validation");
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    Tidy t=new Tidy();
    t.setXHTML(true);
    t.setQuiet(true);
    t.setShowWarnings(false);
    t.parse(ins,baos);
    ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray());
    PageletContentVerifer verifer=new PageletContentVerifer();
    spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
    SAXParser parser=spf.newSAXParser();
    parser.parse(bais,verifer);
    boolean result=verifer.getIsVerifiedWithNoError();
    if (!result)     throw new SAXException("Fail to execute partnership operation as : " + verifer.getVerifiedMessage());
  }
 catch (  ConnectException cex) {
    cex.printStackTrace();
    throw new SAXException("Seems unable to download correct DTD from the web, behind proxy/firewall?",cex);
  }
catch (  IOException ioex) {
    throw new SAXException("IO Error during SAX parsing.",ioex);
  }
}
 

Example 89

From project jforum2, under directory /src/net/jforum/security/.

Source file: XMLPermissionControl.java

  17 
vote

/** 
 * @return <code>List</code> object containing <code>Section</code> objects. Each<code>Section</code>  contains many <code>PermissionItem</code> objects,  which represent the permission elements of some section. For its turn, the <code>PermissionItem</code> objects have many <code>FormSelectedData</code> objects, which are the ones responsible to store field values, and which values are checked and which not.
 * @param xmlFile String
 */
public List loadConfigurations(String xmlFile){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setValidating(false);
    SAXParser parser=factory.newSAXParser();
    File fileInput=new File(xmlFile);
    if (fileInput.exists()) {
      parser.parse(fileInput,this);
    }
 else {
      InputSource inputSource=new InputSource(xmlFile);
      parser.parse(inputSource,this);
    }
    return this.listSections;
  }
 catch (  Exception e) {
    throw new ForumException(e);
  }
}
 

Example 90

From project jreepad, under directory /src/jreepad/io/.

Source file: XmlReader.java

  17 
vote

public JreepadTreeModel read(InputStream in) throws IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  Handler handler=null;
  try {
    SAXParser parser=factory.newSAXParser();
    handler=new Handler();
    parser.parse(in,handler);
  }
 catch (  ParserConfigurationException e) {
    throw new IOException(e.toString());
  }
catch (  SAXException e) {
    throw new IOException(e.toString());
  }
  JreepadTreeModel document=new JreepadTreeModel(handler.getRoot());
  document.setFileType(JreepadPrefs.FILETYPE_XML);
  return document;
}
 

Example 91

From project karaf, under directory /features/core/src/main/java/org/apache/karaf/features/internal/model/.

Source file: JaxbUtil.java

  17 
vote

/** 
 * Read in a Features from the input stream.
 * @param in       input stream to read
 * @param validate whether to validate the input.
 * @return a Features read from the input stream
 * @throws ParserConfigurationException is the SAX parser can not be configured
 * @throws SAXException                 if there is an xml problem
 * @throws JAXBException                if the xml cannot be marshalled into a T.
 */
public static Features unmarshal(InputStream in,boolean validate){
  InputSource inputSource=new InputSource(in);
  SAXParserFactory factory=SAXParserFactory.newInstance();
  factory.setNamespaceAware(true);
  factory.setValidating(validate);
  SAXParser parser;
  try {
    parser=factory.newSAXParser();
    Unmarshaller unmarshaller=FEATURES_CONTEXT.createUnmarshaller();
    unmarshaller.setEventHandler(new ValidationEventHandler(){
      public boolean handleEvent(      ValidationEvent validationEvent){
        System.out.println(validationEvent);
        return false;
      }
    }
);
    XMLFilter xmlFilter=new NoSourceAndNamespaceFilter(parser.getXMLReader());
    xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
    SAXSource source=new SAXSource(xmlFilter,inputSource);
    return (Features)unmarshaller.unmarshal(source);
  }
 catch (  ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
catch (  JAXBException e) {
    throw new RuntimeException(e);
  }
catch (  SAXException e) {
    throw new RuntimeException(e);
  }
}
 

Example 92

From project kumvandroid, under directory /src/com/ijuru/kumva/search/.

Source file: OnlineSearch.java

  17 
vote

/** 
 * @see com.ijuru.kumva.search.Search#doSearch(String)
 */
@Override public SearchResult doSearch(String query,int limit){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    QueryXMLHandler handler=new QueryXMLHandler();
    handler.addListener(this);
    URL url=dictionary.createQueryURL(query,limit);
    URLConnection connection=url.openConnection();
    connection.setRequestProperty("Accept-Encoding","gzip");
    connection.setConnectTimeout(timeout);
    connection.setReadTimeout(timeout);
    InputStream stream=connection.getInputStream();
    if ("gzip".equals(connection.getContentEncoding()))     stream=new GZIPInputStream(stream);
    InputSource source=new InputSource(stream);
    parser.parse(source,handler);
    stream.close();
    return new SearchResult(handler.getSuggestion(),results);
  }
 catch (  Exception e) {
    Log.e("Kumva",e.getMessage(),e);
    return null;
  }
}
 

Example 93

From project lib-gwt-svg, under directory /src/main/java/com/google/gwt/uibinder/rebind/.

Source file: W3cDomHelper.java

  17 
vote

/** 
 * Creates an XML document model with the given contents.
 */
public Document documentFor(String string,String resourcePath) throws SAXParseException {
  try {
    factory.setFeature("http://xml.org/sax/features/xmlns-uris",true);
    factory.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
    if (resourcePath != null) {
      int pos=resourcePath.lastIndexOf('/');
      resourcePath=(pos < 0) ? "" : resourcePath.substring(0,pos + 1);
    }
    W3cDocumentBuilder handler=new W3cDocumentBuilder(logger,resourcePath,resourceOracle);
    SAXParser parser=factory.newSAXParser();
    InputSource input=new InputSource(new StringReader(string));
    input.setSystemId(resourcePath);
    parser.parse(input,handler);
    return handler.getDocument();
  }
 catch (  SAXParseException e) {
    throw e;
  }
catch (  SAXException e) {
    throw new RuntimeException(e);
  }
catch (  IOException e) {
    throw new RuntimeException(e);
  }
catch (  ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
}
 

Example 94

From project LitHub, under directory /LitHub-Android/src/us/lithub/data/.

Source file: BookParser.java

  17 
vote

public static Map<String,String> getBookAttributesFromUpc(String upc){
  try {
    final URL url=new URL("http://isbndb.com/api/books.xml?access_key=MIIRXTQX&index1=isbn&value1=" + upc);
    final SAXParserFactory spf=SAXParserFactory.newInstance();
    final SAXParser sp=spf.newSAXParser();
    final XMLReader xr=sp.getXMLReader();
    final IsbnDbHandler handler=new IsbnDbHandler();
    xr.setContentHandler(handler);
    xr.parse(new InputSource(url.openStream()));
    return handler.getAttributes();
  }
 catch (  MalformedURLException e) {
    Log.e(TAG,e.getMessage());
  }
catch (  SAXException e) {
    Log.e(TAG,e.getMessage());
  }
catch (  ParserConfigurationException e) {
    Log.e(TAG,e.getMessage());
  }
catch (  IOException e) {
    Log.e(TAG,e.getMessage());
  }
  return null;
}
 

Example 95

From project logback, under directory /logback-core/src/main/java/ch/qos/logback/core/joran/event/.

Source file: SaxEventRecorder.java

  17 
vote

public List<SaxEvent> recordEvents(InputSource inputSource) throws JoranException {
  SAXParser saxParser=buildSaxParser();
  try {
    saxParser.parse(inputSource,this);
    return saxEventList;
  }
 catch (  IOException ie) {
    handleError("I/O error occurred while parsing xml file",ie);
  }
catch (  SAXException se) {
    throw new JoranException("Problem parsing XML document. See previously reported errors.",se);
  }
catch (  Exception ex) {
    handleError("Unexpected exception while parsing XML document.",ex);
  }
  throw new IllegalStateException("This point can never be reached");
}
 

Example 96

From project lor-jamwiki, under directory /jamwiki-core/src/main/java/org/jamwiki/migrate/.

Source file: MediaWikiXmlImporter.java

  17 
vote

/** 
 */
private void importWikiXml(File file) throws MigrationException {
  System.setProperty("entityExpansionLimit","1000000");
  SAXParserFactory factory=SAXParserFactory.newInstance();
  FileInputStream fis=null;
  try {
    fis=new FileInputStream(file);
    SAXParser saxParser=factory.newSAXParser();
    saxParser.parse(fis,this);
  }
 catch (  ParserConfigurationException e) {
    throw new MigrationException(e);
  }
catch (  IOException e) {
    throw new MigrationException(e);
  }
catch (  SAXException e) {
    if (e.getCause() instanceof DataAccessException || e.getCause() instanceof WikiException) {
      throw new MigrationException(e.getCause());
    }
 else {
      throw new MigrationException(e);
    }
  }
 finally {
    IOUtils.closeQuietly(fis);
  }
}
 

Example 97

From project maven-shared, under directory /maven-verifier/src/main/java/org/apache/maven/it/.

Source file: Verifier.java

  17 
vote

public void parse(File file) throws VerificationException {
  try {
    SAXParserFactory saxFactory=SAXParserFactory.newInstance();
    SAXParser parser=saxFactory.newSAXParser();
    InputSource is=new InputSource(new FileInputStream(file));
    parser.parse(is,this);
  }
 catch (  FileNotFoundException e) {
    throw new VerificationException("file not found path : " + file.getAbsolutePath(),e);
  }
catch (  IOException e) {
    throw new VerificationException(" IOException path : " + file.getAbsolutePath(),e);
  }
catch (  ParserConfigurationException e) {
    throw new VerificationException(e);
  }
catch (  SAXException e) {
    throw new VerificationException("Parsing exception for file " + file.getAbsolutePath(),e);
  }
}
 

Example 98

From project mediautilities, under directory /src/com/larvalabs/svgandroid/.

Source file: SVGParser.java

  17 
vote

private static SVG parse(InputStream in,Integer searchColor,Integer replaceColor,boolean whiteMode) throws SVGParseException {
  SVGHandler svgHandler=null;
  try {
    SAXParserFactory spf=SAXParserFactory.newInstance();
    SAXParser sp=spf.newSAXParser();
    XMLReader xr=sp.getXMLReader();
    final Picture picture=new Picture();
    svgHandler=new SVGHandler(picture);
    svgHandler.setColorSwap(searchColor,replaceColor);
    svgHandler.setWhiteMode(whiteMode);
    CopyInputStream cin=new CopyInputStream(in);
    IDHandler idHandler=new IDHandler();
    xr.setContentHandler(idHandler);
    xr.parse(new InputSource(cin.getCopy()));
    svgHandler.idXml=idHandler.idXml;
    xr.setContentHandler(svgHandler);
    xr.parse(new InputSource(cin.getCopy()));
    SVG result=new SVG(picture,svgHandler.bounds);
    if (!Float.isInfinite(svgHandler.limits.top)) {
      result.setLimits(svgHandler.limits);
    }
    return result;
  }
 catch (  Exception e) {
    throw new SVGParseException(e);
  }
}
 

Example 99

From project MEditor, under directory /editor-common/editor-common-server/src/main/java/cz/mzk/editor/server/fedora/utils/.

Source file: DocumentLoader.java

  17 
vote

public static Document loadDocument(InputStream in,boolean validate) throws DocumentException {
  try {
    SAXParserFactory saxParserFactory=SAXParserFactory.newInstance();
    SAXParser saxParser=saxParserFactory.newSAXParser();
    XMLReader parser=saxParser.getXMLReader();
    parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);
    parser.setFeature("http://xml.org/sax/features/validation",false);
    SAXReader reader=new SAXReader(parser);
    return reader.read(in);
  }
 catch (  ParserConfigurationException ex) {
    Logger.getLogger(DocumentLoader.class.getName()).log(Level.SEVERE,null,ex);
    return null;
  }
catch (  SAXException ex) {
    Logger.getLogger(DocumentLoader.class.getName()).log(Level.SEVERE,null,ex);
    return null;
  }
}
 

Example 100

From project mkgmap, under directory /src/uk/me/parabola/mkgmap/reader/osm/xml/.

Source file: Osm5MapDataSource.java

  17 
vote

/** 
 * Load the .osm file and produce the intermediate format.
 * @param name The filename to read.
 * @throws FileNotFoundException If the file does not exist.
 */
public void load(String name) throws FileNotFoundException, FormatException {
  try {
    InputStream is=Utils.openFile(name);
    SAXParserFactory parserFactory=SAXParserFactory.newInstance();
    parserFactory.setXIncludeAware(true);
    parserFactory.setNamespaceAware(true);
    SAXParser parser=parserFactory.newSAXParser();
    try {
      Osm5XmlHandler handler=new Osm5XmlHandler(getConfig());
      Osm5XmlHandler.SaxHandler saxHandler=handler.new SaxHandler();
      setupHandler(handler);
      parser.parse(is,saxHandler);
      osmReadingHooks.end();
      elementSaver.finishLoading();
      elementSaver.convert(getConverter());
      addBackground();
    }
 catch (    IOException e) {
      throw new FormatException("Error reading file",e);
    }
  }
 catch (  SAXException e) {
    throw new FormatException("Error parsing file",e);
  }
catch (  ParserConfigurationException e) {
    throw new FormatException("Internal error configuring xml parser",e);
  }
}
 

Example 101

From project mylyn.docs.intent.main, under directory /plugins/org.eclipse.mylyn.docs.intent.markup/src/org/eclipse/mylyn/docs/intent/markup/resource/.

Source file: WikimediaResource.java

  17 
vote

private void handleImagesData(URI eImgURI,String baseServer,InputStream input) throws ParserConfigurationException, SAXException, IOException {
  final SAXParserFactory parserFactory=SAXParserFactory.newInstance();
  parserFactory.setNamespaceAware(true);
  parserFactory.setValidating(false);
  SAXParser saxParser=parserFactory.newSAXParser();
  XMLReader xmlReader=saxParser.getXMLReader();
  xmlReader.setEntityResolver(IgnoreDtdEntityResolver.getInstance());
  ImageFetchingContentHandler contentHandler=new ImageFetchingContentHandler();
  xmlReader.setContentHandler(contentHandler);
  try {
    xmlReader.parse(new InputSource(input));
  }
 catch (  IOException e) {
    throw new RuntimeException(String.format("Unexpected exception retrieving data from %s",eImgURI),e);
  }
  if (contentHandler.imageTitleToUrl.size() > 0) {
    Iterator<Image> it=Iterators.filter(getAllContents(),Image.class);
    while (it.hasNext()) {
      Image cur=it.next();
      String completeURL=contentHandler.imageTitleToUrl.get("Image:" + cur.getUrl());
      if (completeURL != null) {
        cur.setUrl(baseServer + "/" + completeURL);
      }
    }
  }
}
 

Example 102

From project nantes-mobi-parkings, under directory /data/src/main/java/fr/ippon/android/opendata/data/trafficfluency/.

Source file: BisonFuteApi.java

  17 
vote

/** 
 * @param url     url.
 * @return liste d'objets.
 * @throws ApiReseauException en cas d'erreur r?seau.
 */
private List<BasicDataValue> appelApi(String url) throws ApiReseauException {
  Datex2Handler handler=new Datex2Handler();
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    InputStream inputStream=connecteur.openInputStream(url);
    try {
      parser.parse(inputStream,handler);
    }
  finally {
      try {
        inputStream.close();
      }
 catch (      Exception exception) {
        LOGGER.warning(exception.getMessage());
      }
    }
  }
 catch (  IOException ioException) {
    throw new ApiReseauException(ioException);
  }
catch (  SAXException saxException) {
    throw new ApiReseauException(saxException);
  }
catch (  ParserConfigurationException exception) {
    throw new ApiException("Erreur lors de l'appel ? l'API OpenData",exception);
  }
  if (handler.getData() == null || handler.getData().isEmpty()) {
    throw new ApiReseauException();
  }
  return handler.getData();
}
 

Example 103

From project ndg, under directory /ndg-server-core/src/main/java/br/org/indt/ndg/server/client/.

Source file: TemporaryOpenRosaBussinessDelegate.java

  17 
vote

public boolean parseAndPersistResult(InputStreamReader inputStreamReader,String contentType) throws IOException {
  String resultString=parseMultipartEncodedFile(inputStreamReader,contentType,"filename");
  SAXParserFactory factory=SAXParserFactory.newInstance();
  OpenRosaResultsHandler handler=new OpenRosaResultsHandler();
  try {
    ByteArrayInputStream streamToParse=new ByteArrayInputStream(resultString.getBytes());
    SAXParser saxParser=factory.newSAXParser();
    saxParser.parse(streamToParse,handler);
    streamToParse.close();
  }
 catch (  Throwable err) {
    err.printStackTrace();
  }
  String resultId=handler.getResultId();
  String deviceId=handler.getDeviceId();
  String surveyId=handler.getSurveyId();
  if (resultId == null || deviceId == null || surveyId == null) {
    return false;
  }
 else {
    return persistResult(resultString,surveyId,resultId,deviceId);
  }
}
 

Example 104

From project ndg-mobile-client, under directory /src/main/java/br/org/indt/ndg/mobile/xmlhandle/.

Source file: Parser.java

  17 
vote

public void parseInputStream(InputStream is){
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser saxParser=factory.newSAXParser();
    try {
      saxParser.parse(is,handler);
    }
 catch (    DoneParsingException e) {
    }
catch (    SAXParseException e) {
      Logger.getInstance().logException("SAXParseException on parsing: " + e.getMessage());
      e.printStackTrace();
      error=true;
      AppMIDlet.getInstance().getFileSystem().setError(true);
    }
  }
 catch (  Exception e) {
    Logger.getInstance().logException("Exception on parsing: " + e.getMessage());
    e.printStackTrace();
    error=true;
    GeneralAlert.getInstance().addCommand(ExitCommand.getInstance());
    GeneralAlert.getInstance().show(Resources.ERROR_TITLE,Resources.EPARSE_GENERAL,GeneralAlert.ERROR);
  }
}
 

Example 105

From project OpenDataNantesApi, under directory /src/main/java/fr/ybo/opendata/nantes/.

Source file: OpenDataApi.java

  17 
vote

/** 
 * @param < T >     type d'objet OpenDataApi.
 * @param url     url.
 * @param handler handler.
 * @return liste d'objets OpenDataApi.
 * @throws ApiReseauException en cas d'erreur r?seau.
 */
private <T>List<T> appelApi(String url,ApiHandler<T> handler) throws ApiReseauException {
  Answer<T> answer;
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    SAXParser parser=factory.newSAXParser();
    InputStream inputStream=connecteur.openInputStream(url);
    try {
      parser.parse(inputStream,handler);
      answer=handler.getAnswer();
    }
  finally {
      try {
        inputStream.close();
      }
 catch (      Exception exception) {
        LOGGER.warning(exception.getMessage());
      }
    }
  }
 catch (  IOException ioException) {
    throw new ApiReseauException(ioException);
  }
catch (  SAXException saxException) {
    throw new ApiReseauException(saxException);
  }
catch (  ParserConfigurationException exception) {
    throw new ApiException("Erreur lors de l'appel ? l'API OpenData",exception);
  }
  if (answer == null || answer.getStatus() == null || !"0".equals(answer.getStatus().getCode())) {
    throw new ApiReseauException();
  }
  return answer.getData();
}
 

Example 106

From project OpenDDR-Java, under directory /src/org/openddr/simpleapi/oddr/.

Source file: ODDRVocabularyService.java

  17 
vote

private void parseVocabularyFromPath(VocabularyHandler vocabularyHandler,String prop,String path) throws InitializationException {
  InputStream stream=null;
  SAXParser parser=null;
  try {
    stream=new FileInputStream(new File(path));
  }
 catch (  IOException ex) {
    throw new InitializationException(InitializationException.INITIALIZATION_ERROR,new IllegalArgumentException("Can not open " + prop + " : "+ path));
  }
  try {
    parser=SAXParserFactory.newInstance().newSAXParser();
  }
 catch (  ParserConfigurationException ex) {
    throw new InitializationException(InitializationException.INITIALIZATION_ERROR,new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
  }
catch (  SAXException ex) {
    throw new InitializationException(InitializationException.INITIALIZATION_ERROR,new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
  }
  try {
    parser.parse(stream,vocabularyHandler);
  }
 catch (  SAXException ex) {
    throw new InitializationException(InitializationException.INITIALIZATION_ERROR,new RuntimeException("Can not parse document: " + path));
  }
catch (  IOException ex) {
    throw new InitializationException(InitializationException.INITIALIZATION_ERROR,new RuntimeException("Can not open " + prop + " : "+ path));
  }
  try {
    stream.close();
  }
 catch (  IOException ex) {
    Logger.getLogger(ODDRService.class.getName()).log(Level.WARNING,null,ex);
  }
  parser=null;
}
 

Example 107

From project phonegap-simjs, under directory /src/org/apache/wink/json4j/utils/.

Source file: XML.java

  17 
vote

/** 
 * Method to do the transform from an XML input stream to a JSON stream. Neither input nor output streams are closed.  Closure is left up to the caller.
 * @param XMLStream The XML stream to convert to JSON
 * @param JSONStream The stream to write out JSON to.  The contents written to this stream are always in UTF-8 format.
 * @param verbose Flag to denote whether or not to render the JSON text in verbose (indented easy to read), or compact (not so easy to read, but smaller), format.
 * @throws SAXException Thrown if a parse error occurs.
 * @throws IOException Thrown if an IO error occurs.
 */
public static void toJson(InputStream XMLStream,OutputStream JSONStream,boolean verbose) throws SAXException, IOException {
  if (logger.isLoggable(Level.FINER)) {
    logger.entering(className,"toJson(InputStream, OutputStream)");
  }
  if (XMLStream == null) {
    throw new NullPointerException("XMLStream cannot be null");
  }
 else   if (JSONStream == null) {
    throw new NullPointerException("JSONStream cannot be null");
  }
 else {
    if (logger.isLoggable(Level.FINEST)) {
      logger.logp(Level.FINEST,className,"transform","Fetching a SAX parser for use with JSONSAXHandler");
    }
    try {
      SAXParserFactory factory=SAXParserFactory.newInstance();
      factory.setNamespaceAware(true);
      SAXParser sParser=factory.newSAXParser();
      XMLReader parser=sParser.getXMLReader();
      JSONSAXHandler jsonHandler=new JSONSAXHandler(JSONStream,verbose);
      parser.setContentHandler(jsonHandler);
      parser.setErrorHandler(jsonHandler);
      InputSource source=new InputSource(new BufferedInputStream(XMLStream));
      if (logger.isLoggable(Level.FINEST)) {
        logger.logp(Level.FINEST,className,"transform","Parsing the XML content to JSON");
      }
      source.setEncoding("UTF-8");
      parser.parse(source);
      jsonHandler.flushBuffer();
    }
 catch (    javax.xml.parsers.ParserConfigurationException pce) {
      throw new SAXException("Could not get a parser: " + pce.toString());
    }
  }
  if (logger.isLoggable(Level.FINER)) {
    logger.exiting(className,"toJson(InputStream, OutputStream)");
  }
}
 

Example 108

From project PomoTodo, under directory /pomotodo/src/net/juancarlosfernandez/pomotodo/toodledo/xml/.

Source file: AccountInfoParser.java

  17 
vote

public AccountInfo getAccountInfo(){
  SAXParserFactory spf=SAXParserFactory.newInstance();
  try {
    SAXParser sp=spf.newSAXParser();
    sp.parse(new ByteArrayInputStream(xml.getBytes("UTF-8")),this);
  }
 catch (  SAXException se) {
    se.printStackTrace();
  }
catch (  ParserConfigurationException pce) {
    pce.printStackTrace();
  }
catch (  IOException ie) {
    ie.printStackTrace();
  }
  return accountInfo;
}
 

Example 109

From project RecordBreaker, under directory /src/java/com/cloudera/recordbreaker/analyzer/.

Source file: XMLSchemaDescriptor.java

  17 
vote

/** 
 * Creates a new <code>XMLSchemaDescriptor</code> instance. Processes the input XML data and creates an Avro-compatible Schema representation.
 */
public XMLSchemaDescriptor(FileSystem fs,Path p) throws IOException {
  SAXParserFactory factory=SAXParserFactory.newInstance();
  SAXParser parser=null;
  factory.setValidating(false);
  try {
    XMLProcessor xp=new XMLProcessor();
    parser=factory.newSAXParser();
    parser.parse(fs.open(p),xp);
    this.rootTag=xp.getRoot();
    this.rootTag.completeTree();
  }
 catch (  SAXException saxe) {
    throw new IOException(saxe.toString());
  }
catch (  ParserConfigurationException pcee) {
    throw new IOException(pcee.toString());
  }
}
 

Example 110

From project siena, under directory /source/src/main/java/siena/sdb/ws/.

Source file: SimpleDB.java

  17 
vote

private <T extends Response>T request(TreeMap<String,String> parameters,BasicHandler<T> handler){
  signParams(METHOD,HOST,PATH,awsSecretAccessKey,parameters);
  try {
    SAXParserFactory factory=SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setNamespaceAware(false);
    SAXParser parser=factory.newSAXParser();
    URL url=new URL(PROTOCOL + "://" + HOST+ PATH);
    URLConnection connection=url.openConnection();
    connection.setRequestProperty("Content-type","application/x-www-form-urlencoded;charset=" + ENCODING);
    connection.setDoOutput(true);
    connection.setDoInput(true);
    OutputStream os=connection.getOutputStream();
    os.write(query(parameters).getBytes(ENCODING));
    os.close();
    parser.parse(connection.getInputStream(),handler);
    return handler.response;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}
 

Example 111

From project Sketchy-Truck, under directory /andengine/src/org/anddev/andengine/entity/layer/tiled/tmx/.

Source file: TMXLoader.java

  17 
vote

public TMXTiledMap load(final InputStream pInputStream) throws TMXLoadException {
  try {
    final SAXParserFactory spf=SAXParserFactory.newInstance();
    final SAXParser sp=spf.newSAXParser();
    final XMLReader xr=sp.getXMLReader();
    final TMXParser tmxParser=new TMXParser(this.mContext,this.mTextureManager,this.mTextureOptions,this.mTMXTilePropertyListener);
    xr.setContentHandler(tmxParser);
    xr.parse(new InputSource(new BufferedInputStream(pInputStream)));
    return tmxParser.getTMXTiledMap();
  }
 catch (  final SAXException e) {
    throw new TMXLoadException(e);
  }
catch (  final ParserConfigurationException pe) {
    return null;
  }
catch (  final IOException e) {
    throw new TMXLoadException(e);
  }
}
 

Example 112

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/builder/.

Source file: BELCompileBuilder.java

  15 
vote

private SAXParser getParser() throws ParserConfigurationException, SAXException {
  if (parserFactory == null) {
    parserFactory=SAXParserFactory.newInstance();
  }
  return parserFactory.newSAXParser();
}
 

Example 113

From project phresco-eclipse, under directory /com.photon.phresco.ui/src/com/photon/phresco/ui/builder/.

Source file: PhrescoBuilder.java

  15 
vote

private SAXParser getParser() throws ParserConfigurationException, SAXException {
  if (parserFactory == null) {
    parserFactory=SAXParserFactory.newInstance();
  }
  return parserFactory.newSAXParser();
}