public static XMLDocument create(XMLStreamEventsSync stream) throws XMLException, IOException {
		XMLDocument doc = new XMLDocument();
		do {
			switch (stream.event.type) {
			case DOCTYPE:
				if (doc.docType != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", "DOCTYPE");
				doc.docType = new XMLDocumentType(doc, stream.event.text.asString(),
					stream.event.publicId != null ? stream.event.publicId.asString() : null,
					stream.event.system != null ? stream.event.system.asString() : null);
				break;
			case START_ELEMENT:
				if (doc.root != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", stream.event.text.asString());
				doc.root = XMLElement.create(doc, stream);
				break;
			default: break;
			}
			try { stream.next(); }
			catch (EOFException e) {
				break;
			}
		} while (true);
		return doc;
	}
public static XMLDocument create ( XMLStreamEventsSync stream ) throws XMLException , IOException { XMLDocument doc = new XMLDocument ( ) ; do { switch ( stream . event . type ) { case DOCTYPE : if ( doc . docType != null ) throw new XMLException ( stream . getPosition ( ) , "Unexpected element " , "DOCTYPE" ) ; doc . docType = new XMLDocumentType ( doc , stream . event . text . asString ( ) , stream . event . publicId != null ? stream . event . publicId . asString ( ) : null , stream . event . system != null ? stream . event . system . asString ( ) : null ) ; break ; case START_ELEMENT : if ( doc . root != null ) throw new XMLException ( stream . getPosition ( ) , "Unexpected element " , stream . event . text . asString ( ) ) ; doc . root = XMLElement . create ( doc , stream ) ; break ; default : break ; } try { stream . next ( ) ; } catch ( EOFException e ) { break ; } } while ( true ) ; return doc ; }
Create a document from a XMLStreamEvents.