List of usage examples for javax.xml.parsers SAXParser parse
public void parse(InputSource is, DefaultHandler dh) throws SAXException, IOException
From source file:org.ops4j.gaderian.parse.XmlResourceProcessor.java
/** * Returns the ModuleDescriptor obtained by parsing the specified Resource using the given * {@link SAXParser} and {@link DescriptorParser}. Called by {@link #processResource(Resource)} * after the DescriptorParser has been//from w ww. ja v a 2 s . c o m * {@link DescriptorParser#initialize(Resource, ClassResolver) initialized}. Suitable for * overriding by subclasses. */ protected ModuleDescriptor parseResource(Resource resource, SAXParser parser, DescriptorParser contentHandler) throws SAXException, IOException { InputSource source = getInputSource(resource); parser.parse(source, contentHandler); return contentHandler.getModuleDescriptor(); }
From source file:org.owasp.dependencycheck.data.update.CpeUpdater.java
/** * Parses the CPE XML file to return a list of CPE entries. * * @param xml the CPE data file//from ww w. j a v a 2 s .c o m * @return the list of CPE entries * @throws UpdateException thrown if there is an issue with parsing the XML file */ private List<Cpe> processXML(final File xml) throws UpdateException { try { final SAXParserFactory factory = SAXParserFactory.newInstance(); final SAXParser saxParser = factory.newSAXParser(); final CPEHandler handler = new CPEHandler(); saxParser.parse(xml, handler); return handler.getData(); } catch (ParserConfigurationException ex) { throw new UpdateException("Unable to parse CPE XML file due to SAX Parser Issue", ex); } catch (SAXException ex) { throw new UpdateException("Unable to parse CPE XML file due to SAX Parser Exception", ex); } catch (IOException ex) { throw new UpdateException("Unable to parse CPE XML file due to IO Failure", ex); } }
From source file:org.pentaho.di.core.xml.XMLCheck.java
/** * Checks an xml string is well formed./*from w w w. j ava 2s . com*/ * * @param is * inputstream * @return true if the xml is well formed. */ public static final boolean isXMLWellFormed(InputStream is) throws KettleException { boolean retval = false; try { SAXParserFactory factory = SAXParserFactory.newInstance(); XMLTreeHandler handler = new XMLTreeHandler(); // Parse the input. SAXParser saxParser = factory.newSAXParser(); saxParser.parse(is, handler); retval = true; } catch (Exception e) { throw new KettleException(e); } return retval; }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SchedulerXmlSerializer.java
private JobsParserHandler parseJobNamesXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = XmlSerializerUtil.getSAXParserFactory().newSAXParser(); JobsParserHandler h = new JobsParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h;// w w w . j a va 2 s . c om }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SchedulerXmlSerializer.java
/** * // w w w .ja va 2 s . c o m * @param strXml * @return * @throws SAXException * @throws IOException * @throws ParserConfigurationException */ private SchedulerExceptionParserHandler parseSchedulerExceptionXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = XmlSerializerUtil.getSAXParserFactory().newSAXParser(); SchedulerExceptionParserHandler h = new SchedulerExceptionParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h; }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SolutionRepositoryXmlSerializer.java
/** * // w w w. j a va 2s . c om * @param strXml * @return * @throws SAXException * @throws IOException * @throws ParserConfigurationException */ private SolutionRepositoryErrorParserHandler parseSchedulerExceptionXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = XmlSerializerUtil.getSAXParserFactory().newSAXParser(); SolutionRepositoryErrorParserHandler h = new SolutionRepositoryErrorParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h; }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SubscriptionXmlSerializer.java
private SubscriptionScheduleParserHandler parseSubscriptionScheduleJobsXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = getSAXParserFactory().newSAXParser(); SubscriptionScheduleParserHandler h = new SubscriptionScheduleParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h;//from www .j ava 2s . c o m }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SubscriptionXmlSerializer.java
private SubscriptionExceptionParserHandler parseSubscriptionExceptionXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = getSAXParserFactory().newSAXParser(); SubscriptionExceptionParserHandler h = new SubscriptionExceptionParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h;//w w w. ja v a 2 s . com }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.SubscriptionXmlSerializer.java
private SubscriptionErrorParserHandler parseSubscriptionErrorXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = getSAXParserFactory().newSAXParser(); SubscriptionErrorParserHandler h = new SubscriptionErrorParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h;/*from w w w .j a v a 2 s . co m*/ }
From source file:org.pentaho.pac.server.biplatformproxy.xmlserializer.XActionXmlSerializer.java
private XActionResponseParserHandler parseXActionResponseXml(String strXml) throws SAXException, IOException, ParserConfigurationException { SAXParser parser = XmlSerializerUtil.getSAXParserFactory().newSAXParser(); XActionResponseParserHandler h = new XActionResponseParserHandler(); // TODO sbarkdull, need to set encoding // String encoding = CleanXmlHelper.getEncoding( strXml ); // InputStream is = new ByteArrayInputStream( strXml.getBytes( encoding ) ); InputStream is = new ByteArrayInputStream(strXml.getBytes("UTF-8")); //$NON-NLS-1$ parser.parse(is, h); return h;//from ww w . ja v a 2 s . c o m }