Java XML JAXB String to Object xmlToXhtml(T catalog, StreamSource xslt, StreamResult result)

Here you can find the source of xmlToXhtml(T catalog, StreamSource xslt, StreamResult result)

Description

xml To Xhtml

License

Open Source License

Declaration

public static <T> void xmlToXhtml(T catalog, StreamSource xslt, StreamResult result) 

Method Source Code


//package com.java2s;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class Main {
    public static <T> void xmlToXhtml(T catalog, StreamSource xslt, StreamResult result) {
        try {// w  w  w  .  j  a  v a  2s.c o m
            TransformerFactory.newInstance().newTransformer(xslt)
                    .transform(new JAXBSource(JAXBContext.newInstance(catalog.getClass()), catalog), result);
        } catch (JAXBException | TransformerException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related

  1. xmlToJaxb(Class xmlClass, String xml)
  2. xmlToJaxb(Class xmlClass, String xml)
  3. xmlToObject(String xml, Class... type)
  4. xmlToObject(String xml, Class classe)
  5. XmlToObject(String xml, Class type)