<?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * This file is part of the PEAR EDI package. * * PHP version 5 * * LICENSE: This source file is subject to the MIT license that is available * through the world-wide-web at the following URI: * http://opensource.org/licenses/mit-license.php * * @category File_Formats * @package EDI * @author Mark Foster <*****@*****.**> * @copyright 2013 Mark Foster * @license http://opensource.org/licenses/mit-license.php MIT License * @link http://en.wikipedia.org/wiki/Electronic_Data_Interchange * @filesource */ /** * Include the EDI class. */ require_once 'EDI.php'; try { $interch = EDI::interchangeFactory('EDIFACT', array('directory' => 'D96A', 'syntaxIdentifier' => 'UNOC', 'syntaxVersion' => 3)); } catch (EDI_Exception $exc) { echo $exc->getMessage() . "\n"; exit(1); }
* * PHP version 5 * * LICENSE: This source file is subject to the MIT license that is available * through the world-wide-web at the following URI: * http://opensource.org/licenses/mit-license.php * * @category File_Formats * @package EDI * @author David JEAN LOUIS <*****@*****.**> * @copyright 2008 David JEAN LOUIS * @license http://opensource.org/licenses/mit-license.php MIT License * @version SVN: $Id: example1.php,v 1.1.1.1 2008/09/14 16:22:06 izi Exp $ * @link http://pear.php.net/package/EDI * @link http://en.wikipedia.org/wiki/Electronic_Data_Interchange * @since File available since release 0.1.0 * @filesource */ /** * Include the EDI class. */ require_once 'EDI.php'; try { $parser = EDI::parserFactory('EDIFACT'); $interch = $parser->parse(dirname(__FILE__) . '/example1.edi'); // do something with the edi interchange instance echo $interch->toXML(); } catch (EDI_Exception $exc) { echo $exc->getMessage() . "\n"; exit(1); }
/** * Returns true if the interchange is valid and false otherwise. * If not valid an error message is set in the errorMessage property. * * An optional argument strict can be passed, if set to true the method * will skip type (alpha, numeric, alphanumeric) and length checks. * An exemple: * * <code> * $interchange = EDI::interchangeFactory('EDIFACT'); * // build interchange * // [..] * if (!$interchange->isValid()) { * fwrite(STDERR, $interchange->errorMessage); * exit(1); * } * </code> * * @param bool $strict If set to true type and length checks are skipped * * @access public * @return boolean */ public function isValid($strict = true) { try { $parser = EDI::parserFactory('EDIFACT'); $parser->parseString($this->toEDI()); } catch (EDI_Exception $exc) { $this->errorMessage = $exc->getMessage(); return false; } return true; }