«
PHP İçin Java İle Hazırladığım E-Fatura UBL-TR Schematron Doğrulama
PHP İçin Java İle Hazırladığım E-Fatura UBL-TR Schematron Doğrulama Kullanım Şekli
=====================
Bu eklentinin çalışması için sisteminizde en az Java 1.6 sürümü yüklü olmalı.
/* UBL Kontrolü */
function UBLTesti ( $java_dosyasi , $ubl_dosyasi , $fatura_dosyasi , $return = false )
{
/* Java Dosyasına Veri Yollanıyor */
exec ( "java -Dfile.encoding=UTF8 -jar $java_dosyasi $ubl_dosyasi $fatura_dosyasi 2>&1" , $cikti );
/* Önemsiz Hatalar Temizleniyor */
foreach( $cikti as $anahtar => $deger )
{
if(stristr ( $deger , 'The child axis starting' ) == true )
unset($cikti [ $anahtar ]);
if(stristr ( $deger , 'Warning: on line' ) == true )
unset($cikti [ $anahtar ]);
}
/* Hatalar Ekrana Yazdırılıyor */
if( $return == false )
{
if(count ( $cikti ) > 0 )
{
foreach($cikti as $ciktiSonuc )
echo $ciktiSonuc . '<br />' ;
exit();
}
}
else return $cikti ;
}
/* UBL Kontrolü */
$dizin = ( __DIR__ . DIRECTORY_SEPARATOR );
$java_dosyasi = $dizin . "Java/NTG_UBLTR_Schematron.jar" ;
$ubl_dosyasi = $dizin . "Schematron/UBL-TR_Main_Schematron.xml" ;
$fatura_dosyasi = 'TemelFaturaOrnegi.xml' ;
$cikti = UBLTesti ( $java_dosyasi , $ubl_dosyasi , $fatura_dosyasi , true );
if(count ( $cikti ) > 0 )
{
foreach($cikti as $ciktiSonuc )
echo $ciktiSonuc . '<br />' ;
}
else echo 'Hata Yok...' ;
Ubl kontrolü yapan Java sınıfı :
package com . ntg ;
import se . uglisch . XmlSchemaNsUris ;
import javax . xml . transform . stream . StreamSource ;
import javax . xml . validation . Schema ;
import javax . xml . validation . SchemaFactory ;
import java . io . File ;
import java . io . FileInputStream ;
import java . io . InputStream ;
@SuppressWarnings ( "unused" )
public class NTGSch {
public static void main ( String [] args ) throws Exception {
try( InputStream UBL = new FileInputStream ( args [ 0 ]); InputStream fatura = new FileInputStream ( args [ 1 ])){
SchemaFactory schemaFactory = SchemaFactory . newInstance ( XmlSchemaNsUris . SCHEMATRON_NS_URI );
Schema schema = schemaFactory . newSchema (new StreamSource ( UBL ));
schema . newValidator (). validate (new StreamSource ( fatura ));
} catch (Exception e ) {
System . out . println ( e . getMessage ());
}
}
}
Eklentiyi İndirmek İçin Bağlantıya Tıklayın :
https://github.com/3zRasasi/UBL-TR-Schematron Not: Bu Java yazılımı kodcu.com'un "Schematron-Validation" isimli örneğinden yeniden derlenerek PHP ile uyumlu hale getirilmiştir. Kodcu.com 'a teşekkürler...
Yorumlar
(Toplam: 0)
Sıralama:
Eskiden yeniye
Yeniden eskiye
Henüz yorum yapılmamış, ilk yorumu siz yazın.
- Dil Değiştir - Türkçe
English - İngilizce