List of usage examples for javax.xml.transform.stream StreamSource StreamSource
public StreamSource(File f)
From source file:Main.java
public static void main(String args[]) throws Exception { StreamSource source = new StreamSource(args[0]); StreamSource stylesource = new StreamSource(args[1]); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(stylesource); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); }
From source file:Main.java
public static void main(String[] args) throws Exception { XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xmlSource = new StreamSource("src/forum19559825/input.xml"); XMLStreamReader xsr = xif.createXMLStreamReader(xmlSource); positionXMLStreamReaderAtAnyElement(xsr); processAnyElement(xsr);/*from w w w . j av a 2 s .co m*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { StreamSource xmlFile = new StreamSource(new File(args[0])); StreamSource xsltFile = new StreamSource(new File(args[1])); TransformerFactory xsltFactory = TransformerFactory.newInstance(); Transformer transformer = xsltFactory.newTransformer(xsltFile); StreamResult resultStream = new StreamResult(System.out); transformer.transform(xmlFile, resultStream); }
From source file:Main.java
public static void main(String[] args) throws Exception { Source xslSource = new StreamSource(Main.class.getResourceAsStream("test.xsl")); Source xmlSource = new StreamSource(Main.class.getResourceAsStream("test.xml")); Transformer transf = TransformerFactory.newInstance().newTransformer(xslSource); StreamResult transformedXml = new StreamResult(System.out); transf.transform(xmlSource, transformedXml); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String schemaLang = "http://www.w3.org/2001/XMLSchema"; SchemaFactory factory = SchemaFactory.newInstance(schemaLang); Schema schema = factory.newSchema(new StreamSource("sample.xsd")); Validator validator = schema.newValidator(); validator.validate(new StreamSource("sample.xml")); }
From source file:Main.java
public static void main(String[] args) throws Exception { String xmlString = "<message>HELLO!</message> "; JAXBContext jc = JAXBContext.newInstance(String.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); StreamSource xmlSource = new StreamSource(new StringReader(xmlString)); JAXBElement<String> je = unmarshaller.unmarshal(xmlSource, String.class); System.out.println(je.getValue()); }
From source file:Transform2.java
public static void main(String[] args) throws Exception { SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new File("r.xml")); Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource("program.xsl")); JDOMResult out = new JDOMResult(); transformer.transform(new JDOMSource(document), out); XMLOutputter xmlOutputter = new XMLOutputter(); xmlOutputter.output(out.getDocument(), new FileWriter("JDOMAlteredRichard.html")); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Main.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); String code = "<book><title>Harry Potter</title></book>"; StreamSource source = new StreamSource(new StringReader(code)); JAXBElement<Main> jaxbElement = unmarshaller.unmarshal(source, Main.class); }
From source file:Main.java
public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Customer.class); XMLInputFactory xif = XMLInputFactory.newFactory(); XMLStreamReader xsr = xif.createXMLStreamReader(new StreamSource(new File("input.xml"))); Unmarshaller unmarshaller = jc.createUnmarshaller(); unmarshaller.setListener(new LocationListener(xsr)); Customer customer = (Customer) unmarshaller.unmarshal(xsr); }
From source file:Main.java
public static void main(String[] argv) throws Exception { TransformerFactory factory = TransformerFactory.newInstance(); Templates template = factory.newTemplates(new StreamSource(new FileInputStream("xsl.xlt"))); Transformer xformer = template.newTransformer(); Source source = new StreamSource(new FileInputStream("in.xml")); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.newDocument(); Result result = new DOMResult(doc); xformer.transform(source, result);//from w w w .j a va2 s . c om }