Examples of XMLInputFactory


Examples of javax.xml.stream.XMLInputFactory

    @SuppressWarnings("unchecked")
  public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
    if (sourceClass == null || sourceClass == StreamSource.class) {
      return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId());
    } else if (sourceClass == StAXSource.class) {
      XMLInputFactory factory = XMLInputFactory.newInstance();
      try {
        return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream()));
      } catch (XMLStreamException e) {
        throw new SQLException(e);
      }
    } else if (sourceClass == SAXSource.class) {
      return (T) new SAXSource(new InputSource(getBinaryStream()));
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

        return result;
  }

  public static Type isXml(Reader reader) throws TransformationException {
    Type type = Type.ELEMENT;
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        try{       
             XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
             int event = xmlReader.getEventType();
           if  (event == XMLEvent.START_DOCUMENT && xmlReader.getLocation().getColumnNumber() != 1) {
             type = Type.DOCUMENT;
           }
             while (xmlReader.hasNext()) {
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

      return null;
    }
  }

  public static String getEncoding(InputStream is) {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader;
    try {
      reader = factory.createXMLStreamReader(is);
      return reader.getEncoding();
    } catch (XMLStreamException e) {
      return null;
    } finally {
      try {
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

      }
      break;
    }
    case UNKNOWN:  //assume a document
    case DOCUMENT: //filter the doc declaration
      XMLInputFactory inputFactory = XMLInputFactory.newInstance();
      if (!(r instanceof BufferedReader)) {
        r = new BufferedReader(r);
      }
      XMLEventReader eventReader = inputFactory.createXMLEventReader(r);
      eventReader = inputFactory.createFilteredReader(eventReader, new EventFilter() {
        @Override
        public boolean accept(XMLEvent event) {
          return !event.isStartDocument() && !event.isEndDocument();
        }
      });
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

   
    /**
     * Internal constructor.
     */
    private StAXReaderFactory() {
        XMLInputFactory factory;
        try {
            factory = XMLInputFactory.newInstance();
        } catch (FactoryConfigurationError e) {
            Thread thread = Thread.currentThread();
            ClassLoader cl = thread.getContextClassLoader();
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

    private XMLInputFactory ifactory;
    private XMLOutputFactory ofactory;
   
    public void testReader() throws Exception
    {
        XMLInputFactory ifactory = STAXUtils.getXMLInputFactory(null);
        XMLStreamReader reader =
            ifactory.createXMLStreamReader(getClass().getResourceAsStream("/org/codehaus/xfire/util/amazon.xml"));
       
        DepthXMLStreamReader dr = new DepthXMLStreamReader(reader);
       
        STAXUtils.toNextElement(dr);
        assertEquals("ItemLookup", dr.getLocalName());
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory


   
    private XMLStreamReader readerForString(String string) throws XMLStreamException
    {
        XMLInputFactory factory = STAXUtils.getXMLInputFactory(null);
        return factory.createXMLStreamReader(new StringReader(string));
    }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

    this.catElemParserFactory = new CatalogElementParser.Factory();
  }

  private XMLInputFactory getFactory()
  {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    factory.setProperty( "javax.xml.stream.isCoalescing", Boolean.TRUE );
    factory.setProperty( "javax.xml.stream.supportDTD", Boolean.FALSE );
//    factory.setXMLReporter(  );
//    factory.setXMLResolver(  );
    return factory;
  }
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

  private CatalogBuilder readCatalogXML( Source source )
          throws ThreddsXmlParserException
  {
    try
    {
      XMLInputFactory factory = getFactory();
      XMLEventReader eventReader = factory.createXMLEventReader( source );

      ThreddsBuilderFactory catBuilderFac = new ThreddsBuilderFactoryImpl();
      ThreddsBuilder threddsBuilder = null;
      while ( eventReader.hasNext() )
      {
View Full Code Here

Examples of javax.xml.stream.XMLInputFactory

  static XMLEventReader createXmlEventReaderOnXmlString( String xml, String docBaseUri )
          throws XMLStreamException
  {
    Reader stringReader = new StringReader( xml );
    Source source = new StreamSource( stringReader, docBaseUri.toString() );
    XMLInputFactory factory = XMLInputFactory.newInstance();
    factory.setProperty( "javax.xml.stream.isCoalescing", Boolean.TRUE );
    factory.setProperty( "javax.xml.stream.supportDTD", Boolean.FALSE );

    return factory.createXMLEventReader( source );
  }
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.