1 package com.bea.xml.stream.samples;
2
3 import java.io.FileReader;
4 import javax.xml.stream.*;
5 import javax.xml.stream.events.*;
6 import javax.xml.namespace.QName;
7 import com.bea.xml.stream.util.ElementTypeNames;
8 /***
9 * @author Copyright (c) 2002 by BEA Systems. All Rights Reserved.
10 */
11
12 public class EventWrite {
13
14 private static String filename = null;
15
16 private static void printUsage() {
17 System.out.println("usage: java com.bea.xml.stream.samples.EventWrite <xmlfile>");
18 }
19
20 public static void main(String[] args) throws Exception {
21 try {
22 filename = args[0];
23 } catch (ArrayIndexOutOfBoundsException aioobe){
24 printUsage();
25 System.exit(0);
26 }
27
28 System.setProperty("javax.xml.stream.XMLInputFactory",
29 "com.bea.xml.stream.MXParserFactory");
30 System.setProperty("javax.xml.stream.XMLOutputFactory",
31 "com.bea.xml.stream.XMLOutputFactoryBase");
32 System.setProperty("javax.xml.stream.XMLEventFactory",
33 "com.bea.xml.stream.EventFactory");
34
35 XMLInputFactory xmlif = XMLInputFactory.newInstance();
36 XMLOutputFactory xmlof = XMLOutputFactory.newInstance();
37 xmlif.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
38 Boolean.TRUE);
39
40
41 XMLEventReader xmlr = xmlif.createXMLEventReader(new FileReader(filename));
42 XMLEventWriter xmlw = xmlof.createXMLEventWriter(System.out);
43
44 xmlw.add(xmlr);
45 xmlw.flush();
46 }
47 }
48
49
50
51