public static SepaVersion autodetect ( InputStream xml ) { try { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setIgnoringComments ( true ) ; factory . setValidating ( false ) ; factory . setNamespaceAware ( true ) ; DocumentBuilder builder = factory . newDocumentBuilder ( ) ; Document doc = builder . parse ( xml ) ; Node root = doc . getFirstChild ( ) ; // Das ist das Element mit dem Namen "Document" if ( root == null ) throw new IllegalArgumentException ( "XML data did not contain a root element" ) ; String uri = root . getNamespaceURI ( ) ; if ( uri == null ) return null ; return SepaVersion . byURN ( uri ) ; } catch ( IllegalArgumentException e ) { throw e ; } catch ( Exception e2 ) { throw new IllegalArgumentException ( e2 ) ; } }
Ermittelt die SEPA - Version aus dem uebergebenen XML - Stream .