Example usage for javax.xml.transform.stream StreamSource StreamSource

List of usage examples for javax.xml.transform.stream StreamSource StreamSource

Introduction

In this page you can find the example usage for javax.xml.transform.stream StreamSource StreamSource.

Prototype

public StreamSource(File f) 

Source Link

Document

Construct a StreamSource from a File.

Usage

From source file:com.jaxio.celerio.configuration.support.AbstractJibxLoader.java

@SuppressWarnings("unchecked")
public T load(InputStream inputStream) throws XmlMappingException, IOException {
    return (T) getMarshaller().unmarshal(new StreamSource(inputStream));
}

From source file:com.hp.autonomy.types.idol.marshalling.marshallers.jaxb2.Jaxb2ResponseParser.java

@SuppressWarnings("CastToConcreteClass")
@Override/* w ww.j av  a 2s  .c o m*/
public Autnresponse parseResponse(final InputStream inputStream) {
    final Autnresponse autnresponse = (Autnresponse) responseEnvelopeMarshaller
            .unmarshal(new StreamSource(inputStream));

    if (!SUCCESS_STATE.equals(autnresponse.getResponse())) {
        final Node responseData = (Node) autnresponse.getResponseData();
        final ErrorResponse errorResponse = (ErrorResponse) errorMarshaller
                .unmarshal(new DOMSource(responseData));
        throw new AciErrorExceptionBuilder(errorResponse.getError()).build();
    }

    return autnresponse;
}

From source file:net.sf.dynamicreports.report.defaults.Defaults.java

private static XmlDynamicReports load() {
    String resource = "dynamicreports-defaults.xml";
    InputStream is = null;/*from w w w  .ja  v  a  2s . c  o  m*/

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    if (classLoader != null) {
        is = classLoader.getResourceAsStream(resource);
    }
    if (is == null) {
        classLoader = Defaults.class.getClassLoader();
        if (classLoader != null) {
            is = classLoader.getResourceAsStream(resource);
        }
        if (is == null) {
            is = Defaults.class.getResourceAsStream("/" + resource);
        }
    }
    if (is == null) {
        return null;
    }

    try {
        Unmarshaller unmarshaller = JAXBContext.newInstance(XmlDynamicReports.class).createUnmarshaller();
        JAXBElement<XmlDynamicReports> root = unmarshaller.unmarshal(new StreamSource(is),
                XmlDynamicReports.class);
        return root.getValue();
    } catch (JAXBException e) {
        log.error("Could not load dynamic reports defaults", e);
        return null;
    }
}

From source file:com.devnexus.ting.core.dao.jaxb.BackupDaoJaxb.java

@Override
public Backup convertToBackupData(final InputStream inputStream) {

    final StreamSource source = new StreamSource(inputStream);
    final Backup backup = (Backup) marshaller.unmarshal(source);

    LOGGER.info("Restoring: " + backup.getUsers().size() + " users, " + backup.getEvents().size() + " events, "
            + backup.getOrganizers().size() + " organizers, " + backup.getPresentations().size()
            + " presentations, and " + backup.getSpeakers().size() + " speakers.");

    return backup;

}

From source file:Main.java

public static synchronized Object deserialize(InputStream source, InputStream xsltSource, Class cls)
        throws TransformerConfigurationException, JAXBException, TransformerException {
    return deserialize(new StreamSource(source), xsltSource, cls);
}

From source file:Main.java

/**
 * Transforms an XML DOM Document using an XSL file and an array of parameters.
 * The parameter array consists of a sequence of pairs of (String parametername)
 * followed by (Object parametervalue) in an Object[].
 * @param doc the Document to transform.
 * @param xslFile the file containing the XSL transformation program.
 * @param params the array of transformation parameters.
 * @return the transformed DOM Document.
 *//*from  www .jav  a  2 s .  c om*/
public static Document getTransformedDocument(Document doc, File xslFile, Object[] params) throws Exception {
    return getTransformedDocument(new DOMSource(doc), new StreamSource(xslFile), params);
}

From source file:Main.java

public static void formatXML(Document doc, Reader xslStream, Writer writer) throws Exception {
    DOMSource xmlSource = new DOMSource(doc);
    StreamSource xslSource = new StreamSource(xslStream);
    formatXML(xmlSource, xslSource, writer);
    writer.flush();/*from w w  w  .ja  v  a  2 s. com*/
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.loader.bamloader.BAMParser.java

public BamXmlResultSet parse(final String fileName) throws IOException, SAXException {
    logger.info("Started parsing bam file " + fileName);
    final XMLBinding xmlBinding = new XMLBinding().add("bam-smooks-config.xml");
    xmlBinding.intiailize();/*w w w . j av a  2s  . c om*/
    InputStreamReader reader = null;
    try {
        reader = new InputStreamReader(new FileInputStream(fileName));
        Source xmlSource = new StreamSource(reader);
        BamXmlResultSet bamXmlResultSet = xmlBinding.fromXML(xmlSource, BamXmlResultSet.class);
        logger.info("Completed parsing bam file " + fileName);
        return bamXmlResultSet;
    } finally {
        IOUtils.closeQuietly(reader);
    }
}

From source file:Main.java

/**
 * Transform an XML file using an XSL DOM Document and an array of parameters.
 * The parameter array consists of a sequence of pairs of (String parametername)
 * followed by (Object parametervalue) in an Object[].
 * @param doc the file containing the XML to transform.
 * @param xsl the XSL transformation program.
 * @param params the array of transformation parameters.
 * @return the transformed DOM Document.
 *///w w  w.  j a  va 2s .  co  m
public static Document getTransformedDocument(File doc, Document xsl, Object[] params) throws Exception {
    return getTransformedDocument(new StreamSource(doc), new DOMSource(xsl), params);
}

From source file:com.filesprocessing.utils.XMLConverter.java

public Object convertFromXMLToObject(final File xmlfile) throws IOException {
    FileInputStream is = null;//  w  ww  .  j a v a 2 s  .c  om
    try {
        is = new FileInputStream(xmlfile);
        return getUnmarshaller().unmarshal(new StreamSource(is));
    } finally {
        if (is != null) {
            is.close();
        }
    }
}