List of usage examples for org.xml.sax.helpers XMLReaderFactory createXMLReader
public static XMLReader createXMLReader() throws SAXException
From source file:org.mycore.common.content.transformer.MCRXSLTransformer.java
protected XMLReader getXMLReader(LinkedList<TransformerHandler> transformHandlerList) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); reader.setEntityResolver(ENTITY_RESOLVER); reader.setContentHandler(transformHandlerList.getFirst()); return reader; }
From source file:org.n52.sos.XmlToExiConverter.java
protected void encode(String fileName) { try (InputStream exiIS = FileUtils.openInputStream(getFile(fileName, XML_EXTENSION)); OutputStream exiOS = FileUtils.openOutputStream(getFile(fileName, EXI_EXTENSION))) { EXIResult exiResult = new EXIResult(); exiResult.setOutputStream(exiOS); XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(exiResult.getHandler()); xmlReader.parse(new InputSource(exiIS)); } catch (Exception e) { // TODO: handle exception }/*from w w w .ja va 2s .c o m*/ }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
/** * @param xml/* w w w .ja v a 2 s.c o m*/ * @return a list of alarms from the given xml string. * @throws IOException * @throws SAXException */ public static List<SonosAlarm> getAlarmsFromStringResult(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); AlarmHandler handler = new AlarmHandler(); reader.setContentHandler(handler); try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { logger.error("Could not parse Alarms from String {}", xml); } return handler.getAlarms(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
/** * @param xml// w ww . j a v a2s. com * @return a list of Entrys from the given xml string. * @throws IOException * @throws SAXException */ public static List<SonosEntry> getEntriesFromString(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); EntryHandler handler = new EntryHandler(); reader.setContentHandler(handler); try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { logger.error("Could not parse Entries from String {}", xml); } return handler.getArtists(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
/** * Returns the meta data which is needed to play Pandora * (and others?) favorites/*from w w w . j a v a 2 s . com*/ * @param xml * @return The value of the desc xml tag * @throws SAXException */ public static SonosResourceMetaData getEmbededMetaDataFromResource(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); EmbededMetaDataHandler handler = new EmbededMetaDataHandler(); reader.setContentHandler(handler); try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { logger.error("Could not parse Entries from String {}", xml); } return handler.getMetaData(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
/** * @param controller//ww w.j a v a 2 s. c o m * @param xml * @return zone group from the given xml * @throws IOException * @throws SAXException */ public static List<SonosZoneGroup> getZoneGroupFromXML(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); ZoneGroupHandler handler = new ZoneGroupHandler(); reader.setContentHandler(handler); try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { // This should never happen - we're not performing I/O! logger.error("Could not parse ZoneGroup from String {}", xml); } return handler.getGroups(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
public static List<String> getRadioTimeFromXML(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); OpmlHandler handler = new OpmlHandler(); reader.setContentHandler(handler);//from w w w. j ava 2 s. c o m try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { // This should never happen - we're not performing I/O! logger.error("Could not parse RadioTime from String {}", xml); } return handler.getTextFields(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
public static Map<String, StateVariableValue> getRenderingControlFromXML(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); RenderingControlEventHandler handler = new RenderingControlEventHandler(); reader.setContentHandler(handler);/*from w w w. ja va 2 s .c om*/ try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { // This should never happen - we're not performing I/O! logger.debug("Could not parse Rendering Control event: {}", e); } return handler.getChanges(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
public static Map<String, StateVariableValue> getAVTransportFromXML(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); AVTransportEventHandler handler = new AVTransportEventHandler(); reader.setContentHandler(handler);/*www .j ava2 s.c om*/ try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { // This should never happen - we're not performing I/O! logger.error("Could not parse AV Transport Event: {}", e); } return handler.getChanges(); }
From source file:org.openhab.binding.sonos.internal.SonosXMLParser.java
public static SonosMetaData getMetaDataFromXML(String xml) throws SAXException { XMLReader reader = XMLReaderFactory.createXMLReader(); //logger.debug("getTrackFromXML {}",xml); MetaDataHandler handler = new MetaDataHandler(); reader.setContentHandler(handler);/*from w w w .j ava2 s . co m*/ try { reader.parse(new InputSource(new StringReader(xml))); } catch (IOException e) { // This should never happen - we're not performing I/O! logger.error("Could not parse AV Transport Event: {}", e); } return handler.getMetaData(); }