Package javax.xml.stream

Examples of javax.xml.stream.XMLInputFactory.createXMLStreamReader()


public class XmlHelper {
  static final Logger log = LoggerFactory.getLogger(XmlHelper.class);

  public static XMLStreamReader buildXmlStreamReader(String xml) throws XMLStreamException {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    return factory.createXMLStreamReader(new StringReader(xml));
  }

  public static Document parseXmlDocument(String xml, boolean namespaceAware) throws ParserConfigurationException,
      SAXException, IOException {
    DocumentBuilder docBuilder = buildDocumentBuilder(namespaceAware);
View Full Code Here


   
    try {
      log.info("Reading data from " + inputFile);
     
      is = new FileInputStream(inputFile);
      reader = xif.createXMLStreamReader(is);
     
      os = new FileOutputStream(trainingOutputFile);
      writer = xof.createXMLStreamWriter(os);
      int trainingDataCount = extractXMLData(reader, writer, trainingDataSize);
      os.close();
View Full Code Here

    XMLInputFactory factory = XMLInputFactory.newInstance();
    if (logger.isDebugEnabled()) {
      logger.debug("Using StAX implementation [" + factory + "]");
    }

    XMLStreamReader reader = factory.createXMLStreamReader(inputStream);
    return reader;
  }

  /**
   * Creates a new <code>java.util.List</code> from the current element being
View Full Code Here

            TagExtractor tagextractor = new TagExtractor("abstract", 100);

            XMLStreamReader reader = null;
            try {
                XMLInputFactory factory = XMLInputFactory.newInstance();
                reader = factory.createXMLStreamReader(is);
                while (reader.hasNext()) {
                    switch (reader.next()) {
                    case XMLStreamReader.START_ELEMENT:
                        tagextractor.setTag(reader.getName().toString());
                        break;
View Full Code Here

            }
            String stockdata = stockQuoteService.GetQuote(sb.toString());

            InputStream in = new ByteArrayInputStream(stockdata.getBytes());
            XMLInputFactory factory = XMLInputFactory.newInstance();
            XMLStreamReader parser = factory.createXMLStreamReader(in);
            ArrayList<StockQuote> listQuotes = new ArrayList<StockQuote>();
            Hashtable<String, StockQuote> listQuoteHT = new Hashtable<String, StockQuote>();
            MapStock currentStock = null;
            StringBuilder currentText = new StringBuilder(100);
            for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
View Full Code Here

     */
    @Deprecated
    public XMLStreamReader createXMLStreamReader(InputStream in) throws XMLStreamException {
        XMLInputFactory factory = getInputFactory();
        try {
            return factory.createXMLStreamReader(IOHelper.buffered(in));
        } finally {
            returnXMLInputFactory(factory);
        }
    }
   
View Full Code Here

    public XMLStreamReader createXMLStreamReader(InputStream in, Exchange exchange) throws XMLStreamException {
        XMLInputFactory factory = getInputFactory();
        try {
            String charsetName = IOHelper.getCharsetName(exchange, false);
            if (charsetName == null) {
                return factory.createXMLStreamReader(IOHelper.buffered(in));
            } else {
                return factory.createXMLStreamReader(IOHelper.buffered(in), charsetName);
            }
        } finally {
            returnXMLInputFactory(factory);
View Full Code Here

        try {
            String charsetName = IOHelper.getCharsetName(exchange, false);
            if (charsetName == null) {
                return factory.createXMLStreamReader(IOHelper.buffered(in));
            } else {
                return factory.createXMLStreamReader(IOHelper.buffered(in), charsetName);
            }
        } finally {
            returnXMLInputFactory(factory);
        }
    }
View Full Code Here

    @Converter
    public XMLStreamReader createXMLStreamReader(File file, Exchange exchange) throws XMLStreamException, FileNotFoundException {
        XMLInputFactory factory = getInputFactory();
        try {
            return factory.createXMLStreamReader(IOHelper.buffered(new FileInputStream(file)), IOHelper.getCharsetName(exchange));
        } finally {
            returnXMLInputFactory(factory);
        }
    }
View Full Code Here

    @Converter
    public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
        XMLInputFactory factory = getInputFactory();
        try {
            return factory.createXMLStreamReader(IOHelper.buffered(reader));
        } finally {
            returnXMLInputFactory(factory);
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.