Esempio n. 1
0
 function __construct($gmlSource)
 {
     parent::__construct();
     include_once "libs/class_xml_check.php";
     $check = new XML_check();
     if ($check->check_string($gmlSource)) {
         print "GML is well-formed\n";
         //print("Elements      : ".$check->get_xml_elements());
         //print("Attributes    : ".$check->get_xml_attributes());
         //print("Size          : ".$check->get_xml_size());
         //print("Text sections : ".$check->get_xml_text_sections());
         //print("Text size     : ".$check->get_xml_text_size());
     } else {
         print "GML is not well-formed. ";
         print $check->get_full_error() . "\n";
         print "Script terminated\n";
         die;
     }
     $this->gmlSource = $gmlSource;
     $this->gmlCon = new gmlConverter();
     require_once "XML/Unserializer.php";
     $unserializer_options = array('parseAttributes' => TRUE);
     $unserializer = new XML_Unserializer($unserializer_options);
     // Serialize the data structure
     $status = $unserializer->unserialize($this->gmlSource);
     $this->gmlArray = $unserializer->getUnserializedData();
     print date('l jS \\of F Y h:i:s A') . " GML serialized\n";
     // Check if XML is a ServiceException
     if ($unserializer->getRootName() == "ServiceExceptionReport") {
         print "The server returned an exception:\n";
         print $this->gmlSource . "\n";
         print "Script terminated\n";
         die;
     }
 }
Esempio n. 2
0
function validateXML($xml)
{
    $validXML = true;
    $xmlCheck = new XML_check();
    $xml1 = $xml;
    $validXML = $xmlCheck->check_string($xml1);
    // verifica se o XML é bem formado
    return $validXML;
}
Esempio n. 3
0
 function validateXML($xml)
 {
     $validXML = true;
     if ($this->defFile['XML_ERROR']['ENABLED_XML_ERROR'] == '1') {
         $xmlCheck = new XML_check();
         $xml1 = $xml;
         $validXML = $xmlCheck->check_string($xml1);
         // verifica se o XML é bem formado
     }
     return $validXML;
 }
 function transform($xsl, $xml)
 {
     if (!$this->socket) {
         die("{$errstr} ({$errno})<br />\n");
     }
     $aspas = array(chr(147), chr(148));
     $menos = array(chr(150));
     /* 
     	o transformador via socket usa xml com encoding iso,
     	assim, se o xml vier em utf, necessário executar o utf8_decode
     */
     if (strpos(strtolower($xml), 'utf-') > 0) {
         $xml = $this->xml_utf8_decode($xml);
         $utf = true;
     }
     $xml = str_replace($aspas, "&quot;", $xml);
     $xml = str_replace($menos, "-", $xml);
     $xml = str_replace("\n", "", $xml);
     $xml = str_replace(chr(132), "", $xml);
     $xml = str_replace(chr(131), "", $xml);
     $xml = str_replace(chr(134), "", $xml);
     $xml = str_replace(chr(145), "", $xml);
     $xml = str_replace(chr(146), "", $xml);
     //fwrite($this->socket, "ISO-8859-1:".$xsl.":".$xml."\n") or die("1")
     if ($this->defFile['XML_ERROR']['ENABLED_XML_ERROR'] == '1') {
         $xmlCheck = new XML_check();
         $xml1 = $xml;
         if ($xmlCheck->check_string($xml1)) {
             // verifica se o XML é bem formado
             fwrite($this->socket, "utf-8:" . $xsl . ":" . $xml . "\n") or die("1");
             fwrite($this->socket, $this->END_OF_MESS_SYMBOL . "\n") or die("2");
             $message = $this->recebeResultado() . "<!-- XML well formed verifier ON -->";
         } else {
             include_once dirname(__FILE__) . "/mail_msg.php";
             $url = "http://" . $_SERVER['SERVER_NAME'] . "/php/xmlError.php?lang=" . $_REQUEST['lng'];
             exit('<META http-equiv="refresh" content="0;URL=' . $url . '">');
         }
     } else {
         fwrite($this->socket, "utf-8:" . $xsl . ":" . $xml . "\n") or die("1");
         fwrite($this->socket, $this->END_OF_MESS_SYMBOL . "\n") or die("2");
         $message = $this->recebeResultado() . "<!-- XML well formed verifier OFF -->";
     }
     return $message;
 }
Esempio n. 5
0
<?php

include_once "class_xml_check.php";
$myxml = '<?xml version="1.0"?>
<foo>
 <data id="1">
   <name>pepe</name>
   <num>2</num>
 </data>
 <data>
   <name>foo</name>
   <num>5</num>
 </data>
</foo>';
$check = new XML_check();
//if($check->check_url("http://www.w3.org/")) {
if ($check->check_string($myxml)) {
    print "XML is well-formed<br/>";
    print "<pre>";
    print "Elements      : " . $check->get_xml_elements() . "<br/>";
    print "Attributes    : " . $check->get_xml_attributes() . "<br/>";
    print "Size          : " . $check->get_xml_size() . "<br/>";
    print "Text sections : " . $check->get_xml_text_sections() . "<br/>";
    print "Text size     : " . $check->get_xml_text_size() . "<br/>";
    print "</pre>";
} else {
    print "XML is not well-formed<br/>";
    print $check->get_full_error();
}