public Document parse(Source source) throws XMLPlatformException { try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); SAXResult saxResult = new SAXResult(); SAXDocumentBuilder builder = new SAXDocumentBuilder(); saxResult.setHandler(builder); transformer.transform(source, saxResult); return builder.getDocument(); } catch (TransformerException e) { throw XMLPlatformException.xmlPlatformParseException(e); } }
/** * Parses given source. * * @param source source to parse * @return parsed document * @throws XMLPlatformException exception occurred while parsing given source */ public Document parse(Source source) throws XMLPlatformException { try { if (null == transformerFactory) { transformerFactory = TransformerFactory.newInstance(); } Transformer transformer = transformerFactory.newTransformer(); SAXResult saxResult = new SAXResult(); SAXDocumentBuilder builder = new SAXDocumentBuilder(); saxResult.setHandler(builder); transformer.transform(source, saxResult); return builder.getDocument(); } catch (TransformerException e) { throw XMLPlatformException.xmlPlatformParseException(e); } }
public Object unmarshal(XMLReader xmlReader, InputSource inputSource, Class clazz) { try { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return xmlToObject(new DOMRecord(saxDocumentBuilder.getDocument()), clazz); } catch(IOException e) { throw XMLMarshalException.unmarshalException(e); } catch(SAXException e) { throw XMLMarshalException.unmarshalException(e); } }
public Object unmarshal(XMLReader xmlReader, InputSource inputSource) { try { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return xmlToObject(new DOMRecord(saxDocumentBuilder.getDocument())); } catch(IOException e) { throw XMLMarshalException.unmarshalException(e); } catch(SAXException e) { throw XMLMarshalException.unmarshalException(e); } }
/** * Parses given source. * * @param source source to parse * @return parsed document * @throws XMLPlatformException exception occurred while parsing given source */ @Override public Document parse(Source source) throws XMLPlatformException { try { if (null == transformerFactory) { transformerFactory = XMLHelper.createTransformerFactory(false); } Transformer transformer = transformerFactory.newTransformer(); SAXResult saxResult = new SAXResult(); SAXDocumentBuilder builder = new SAXDocumentBuilder(); saxResult.setHandler(builder); transformer.transform(source, saxResult); return builder.getDocument(); } catch (TransformerException e) { throw XMLPlatformException.xmlPlatformParseException(e); } }
public Object unmarshal(XMLReader xmlReader, InputSource inputSource) { if(!xmlUnmarshaller.isApplicationXML()){ throw XMLMarshalException.unsupportedMediaTypeForPlatform(); } try { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return xmlToObject(new DOMRecord(saxDocumentBuilder.getDocument())); } catch(IOException e) { throw XMLMarshalException.unmarshalException(e); } catch(SAXException e) { throw XMLMarshalException.unmarshalException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
public Object unmarshal(XMLReader xmlReader, InputSource inputSource, Class clazz) { if(!xmlUnmarshaller.isApplicationXML()){ throw XMLMarshalException.unsupportedMediaTypeForPlatform(); } try { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return xmlToObject(new DOMRecord(saxDocumentBuilder.getDocument()), clazz); } catch(IOException e) { throw XMLMarshalException.unmarshalException(e); } catch(SAXException e) { throw XMLMarshalException.unmarshalException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
@Override public Object unmarshal(XMLReader xmlReader, InputSource inputSource, Class clazz) { if(!xmlUnmarshaller.isApplicationXML()){ throw XMLMarshalException.unsupportedMediaTypeForPlatform(); } try { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return xmlToObject(new DOMRecord(saxDocumentBuilder.getDocument()), clazz); } catch(IOException e) { throw XMLMarshalException.unmarshalException(e); } catch(SAXException e) { throw XMLMarshalException.unmarshalException(e); } finally { xmlUnmarshaller.getStringBuffer().reset(); } }
public Object unmarshal(org.xml.sax.XMLReader xmlReader, InputSource inputSource) { try { XMLContext xmlContext = xmlUnmarshaller.getXMLContext(); if (xmlContext.hasDocumentPreservation()) { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource); return unmarshal(saxDocumentBuilder.getDocument().getDocumentElement()); } XMLReader extendedXMLReader; if(xmlReader instanceof XMLReader) { extendedXMLReader = (XMLReader) xmlReader; } else { extendedXMLReader = new XMLReader(xmlReader); } SAXUnmarshallerHandler saxUnmarshallerHandler = new SAXUnmarshallerHandler(xmlContext); saxUnmarshallerHandler.setXMLReader(extendedXMLReader); saxUnmarshallerHandler.setUnmarshaller(xmlUnmarshaller); extendedXMLReader.setContentHandler(saxUnmarshallerHandler); extendedXMLReader.parse(inputSource); // resolve any mapping references saxUnmarshallerHandler.resolveReferences(); return saxUnmarshallerHandler.getObject(); } catch (IOException e) { throw XMLMarshalException.unmarshalException(e); } catch (SAXException e) { throw convertSAXException(e); } }
Context xmlContext = xmlUnmarshaller.getContext(); if (xmlContext.hasDocumentPreservation()) { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource);
Context xmlContext = xmlUnmarshaller.getContext(); if (xmlContext.hasDocumentPreservation()) { SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource);
SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource);
SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource);
SAXDocumentBuilder saxDocumentBuilder = new SAXDocumentBuilder(); xmlReader.setContentHandler(saxDocumentBuilder); xmlReader.parse(inputSource);
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument();
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument();
this.documentBuilder = new SAXDocumentBuilder(); documentBuilder.startDocument();