Examples of XMLInputFactory


Examples of javax.xml.stream.XMLInputFactory

    ncfile.close();
  }

  public static void main(String args[]) throws XMLStreamException, IOException {

    XMLInputFactory myFactory = XMLInputFactory.newInstance();
    //myFactory.setXMLReporter(myXMLReporter);
    //myFactory.setXMLResolver(myXMLResolver);
    myFactory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
    new TimeStaxReading(myFactory, "C:/TEMP/thredds.xml");

    /* String dir = "C:/doc/metarEncoding/save/";
    new TimeStaxReading(myFactory, dir+"xmlC.xml");

View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

   * aware, non-validating, support DTDs, and in text coalescing mode.
   *
   * @return a StAX factory
   */
  private static XMLInputFactory getDefaultInputFactory() {
    XMLInputFactory inputFactory = defaultInputFactory.getInputFactory();
    if (DEBUG) System.err.println("got XMLInputFactory=" + inputFactory.getClass().getName());
    return inputFactory;
  }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

      throw new IllegalArgumentException("input must not be null");
   
    if (baseURI != null && baseURI.length() == 0) baseURI = null;
    //baseURI = canonicalizeURL(baseURI); // TODO
   
    XMLInputFactory inputFactory = getDefaultInputFactory();
    try {
      synchronized (inputFactory) {
        // Grabbing a lock is necessary for SJSXP, but not for woodstox
        // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6365687
        return inputFactory.createXMLStreamReader(baseURI, input);
      }
    } catch (XMLStreamException e) {
      wrapException(e);
      return null; // unreachable
    }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

   
    /** Cached StAX XMLInputFactory; shared; thread safe */
    private SoftReference factoryRef = new SoftReference(null);
   
    private synchronized XMLInputFactory getInputFactory() {
      XMLInputFactory inputFactory = (XMLInputFactory) factoryRef.get();
      if (inputFactory == null) {
        inputFactory = createInputFactory();
        factoryRef = new SoftReference(inputFactory);
      }
      return inputFactory;
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

//      System.setProperty("javax.xml.stream.XMLOutputFactory", "com.bea.xml.stream.XMLOutputFactoryBase");
//      System.setProperty("javax.xml.stream.XMLEventFactory",  "com.bea.xml.stream.EventFactory");
//  }
 
    private XMLInputFactory createInputFactory() {
      XMLInputFactory factory;
      for (int i = 0; i < StAX_FACTORIES.length; i++) {
        try {
          factory = (XMLInputFactory) ClassLoaderUtil.newInstance(StAX_FACTORIES[i]);
          setupProperties(factory);       
          if (DEBUG) System.err.println("using XMLInputFactory=" + factory.getClass().getName());
          return factory;
        } catch (IllegalArgumentException e) {
          // keep on trying
        } catch (NoClassDefFoundError err) {
          // keep on trying
        } catch (Exception err) {
          // keep on trying
        }
      }
     
      try { // StAX default
        factory = XMLInputFactory.newInstance();
        setupProperties(factory);
      } catch (IllegalArgumentException ex) {
        throw new XMLException(
            "Could not find or create a suitable StAX parser"
                + " - check your classpath", ex);
      } catch (Exception ex) {
        throw new XMLException(
            "Could not find or create a suitable StAX parser"
                + " - check your classpath", ex);
      } catch (NoClassDefFoundError ex) {
        throw new XMLException(
            "Could not find or create a suitable StAX parser"
                + " - check your classpath", ex);
      }
     
      if (DEBUG) System.err.println("using default XMLInputFactory="
            + factory.getClass().getName());
      return factory;
    }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

      System.setProperty("nu.xom.Verifier.checkPCDATA", "false");
      System.setProperty("nu.xom.Verifier.checkURI", "false");
      System.out.println("patchesEnabled=true");
    }
   
    XMLInputFactory staxInputFactory = null;
    if (mode.indexOf("stax") >= 0 && mode.indexOf("fi") < 0) {
      if (mode.indexOf("sun") >= 0) {
        staxInputFactory = (XMLInputFactory) Class.forName("com.sun.xml.stream.ZephyrParserFactory").newInstance();
//        System.setProperty("javax.xml.stream.XMLInputFactory", "com.sun.xml.stream.ZephyrParserFactory");
//        System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.stream.ZephyrWriterFactory");
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

   
  private void run(File file) throws Exception {
    Document expected = getBuilder().build(file);
   
    NodeFactory factory = new NodeFactory();
    XMLInputFactory staxFactory = createXMLInputFactory();
    Document actual = StaxUtil.createBuilder(staxFactory, factory).build(file);
   
    IOTestUtil.xomAssertEquals(expected, actual);
    IOTestUtil.canonicalAssertEquals(expected, actual);   
  }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

  }

  private static XMLInputFactory createXMLInputFactory() {
    String clazz = System.getProperty("javax.xml.stream.XMLInputFactory");
    if (clazz == null) return null; // use Nux default
    XMLInputFactory staxFactory = XMLInputFactory.newInstance();
    System.out.println("staxFactory=" + staxFactory.getClass().getName());
    return staxFactory;
  }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

        // temporary (?) performance hack via patch: disable some expensive sanity checks
        System.setProperty("nu.xom.Verifier.checkPCDATA", "false");
        System.setProperty("nu.xom.Verifier.checkURI", "false");
      }
     
      XMLInputFactory staxInputFactory = null;
      if (mode.indexOf("stax") >= 0 && mode.indexOf("fi") < 0) {
        if (mode.indexOf("sun") >= 0) {
          staxInputFactory = (XMLInputFactory) Class.forName("com.sun.xml.stream.ZephyrParserFactory").newInstance();
//          System.setProperty("javax.xml.stream.XMLInputFactory", "com.sun.xml.stream.ZephyrParserFactory");
//          System.setProperty("javax.xml.stream.XMLOutputFactory", "com.sun.xml.stream.ZephyrWriterFactory");
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

   static XMLStreamReader getXMLStreamReader(InputStream entityStream)
   {
      InputStream in = new BufferedInputStream(entityStream, 2048);
      try
      {
         XMLInputFactory factory = XMLInputFactory.newInstance();
         return factory.createXMLStreamReader(in);
      }
      catch (XMLStreamException e)
      {
         throw new ExceptionAdapter(e);
      }
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.