Example #1
0
function createArticle($aFileName)
{
    $articleDoc = new DOMDocument("1.0", "UTF-8");
    $articleDoc->appendChild($articleDoc->createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../component/article/view-article.xsl\""));
    $articleDoc->appendChild($articleDoc->createProcessingInstruction("setter", "href=\"../component/article/setter-article.php\""));
    $articleE = $articleDoc->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "article"));
    $articleE->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "http://formax.cz/ns/article ../component/article/model-article.xsd");
    $articleE->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "h", "nový článek"));
    $articleE->appendChild($articleDoc->createElementNS("http://formax.cz/ns/article", "p", "nový článek"));
    $articleDoc->save($aFileName);
}
Example #2
0
function createCCR($action, $raw = "no")
{
    $authorID = getUuid();
    $patientID = getUuid();
    $sourceID = getUuid();
    $oemrID = getUuid();
    $result = getActorData();
    while ($res = sqlFetchArray($result[2])) {
        ${"labID{$res['id']}"} = getUuid();
    }
    $ccr = new DOMDocument('1.0', 'UTF-8');
    $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="stylesheet/ccr.xsl"');
    $ccr->appendChild($e_styleSheet);
    $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord');
    $ccr->appendChild($e_ccr);
    /////////////// Header
    require_once "createCCRHeader.php";
    $e_Body = $ccr->createElement('Body');
    $e_ccr->appendChild($e_Body);
    /////////////// Problems
    $e_Problems = $ccr->createElement('Problems');
    require_once "createCCRProblem.php";
    $e_Body->appendChild($e_Problems);
    /////////////// Alerts
    $e_Alerts = $ccr->createElement('Alerts');
    require_once "createCCRAlerts.php";
    $e_Body->appendChild($e_Alerts);
    ////////////////// Medication
    $e_Medications = $ccr->createElement('Medications');
    require_once "createCCRMedication.php";
    $e_Body->appendChild($e_Medications);
    ///////////////// Immunization
    $e_Immunizations = $ccr->createElement('Immunizations');
    require_once "createCCRImmunization.php";
    $e_Body->appendChild($e_Immunizations);
    /////////////////// Results
    $e_Results = $ccr->createElement('Results');
    require_once "createCCRResult.php";
    $e_Body->appendChild($e_Results);
    /////////////////// Procedures
    //$e_Procedures = $ccr->createElement('Procedures');
    //require_once("createCCRProcedure.php");
    //$e_Body->appendChild($e_Procedures);
    //////////////////// Footer
    // $e_VitalSigns = $ccr->createElement('VitalSigns');
    // $e_Body->appendChild($e_VitalSigns);
    /////////////// Actors
    $e_Actors = $ccr->createElement('Actors');
    require_once "createCCRActor.php";
    $e_ccr->appendChild($e_Actors);
    if ($action == "generate") {
        gnrtCCR($ccr, $raw);
    }
    if ($action == "viewccd") {
        viewCCD($ccr, $raw);
    }
}
 private function createRssDoc()
 {
     $doc = new DOMDocument('1.0', 'UTF-8');
     $style = $doc->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="RssStyle.xsl"');
     $doc->appendChild($style);
     $rss = $doc->createElement('rss');
     $rss->setAttribute('version', '2.0');
     $doc->appendChild($rss);
     return $doc;
 }
Example #4
0
function createCCR($action, $raw = "no")
{
    $authorID = getUuid();
    echo '<!--';
    $ccr = new DOMDocument('1.0', 'UTF-8');
    $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="ccr.xsl"');
    $ccr->appendChild($e_styleSheet);
    $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord');
    $ccr->appendChild($e_ccr);
    /////////////// Header
    require_once "createCCRHeader.php";
    $e_Body = $ccr->createElement('Body');
    $e_ccr->appendChild($e_Body);
    /////////////// Problems
    $e_Problems = $ccr->createElement('Problems');
    require_once "createCCRProblem.php";
    $e_Body->appendChild($e_Problems);
    /////////////// Alerts
    $e_Alerts = $ccr->createElement('Alerts');
    require_once "createCCRAlerts.php";
    $e_Body->appendChild($e_Alerts);
    ////////////////// Medication
    $e_Medications = $ccr->createElement('Medications');
    require_once "createCCRMedication.php";
    $e_Body->appendChild($e_Medications);
    ///////////////// Immunization
    $e_Immunizations = $ccr->createElement('Immunizations');
    require_once "createCCRImmunization.php";
    $e_Body->appendChild($e_Immunizations);
    /////////////////// Results
    $e_Results = $ccr->createElement('Results');
    require_once "createCCRResult.php";
    $e_Body->appendChild($e_Results);
    /////////////////// Procedures
    $e_Procedures = $ccr->createElement('Procedures');
    require_once "createCCRProcedure.php";
    $e_Body->appendChild($e_Procedures);
    //////////////////// Footer
    // $e_VitalSigns = $ccr->createElement('VitalSigns');
    // $e_Body->appendChild($e_VitalSigns);
    /////////////// Actors
    $e_Actors = $ccr->createElement('Actors');
    require_once "createCCRActor.php";
    $e_ccr->appendChild($e_Actors);
    // save created CCR in file
    echo " \n action=" . $action;
    if ($action == "generate") {
        gnrtCCR($ccr, $raw);
    }
    if ($action == "viewccd") {
        viewCCD($ccr, $raw);
    }
}
Example #5
0
 /**
  * Add processing instruction
  *
  * @param string $name
  * @param string $data
  */
 public function add_processing_instruction($name, $data)
 {
     $n = $this->node ? new self($this->owner) : $this;
     $e = $this->doc->createProcessingInstruction($name, $data);
     if (!$this->node) {
         $n->node = $this->node = $this->doc->appendChild($e);
     } else {
         $n->node = $this->node->appendChild($e);
     }
     unset($e);
     return $n;
 }
Example #6
0
 function dom_standard()
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     if ($this->xslt_src) {
         $xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $this->xslt_src . '"');
         $dom->appendChild($xslt);
     }
     $root = $dom->appendChild($dom->createElement('template'));
     $_pagi_actual = $dom->createElement("actual");
     $_pagi_actual->appendChild($dom->createTextNode($this->_pagi_actual));
     $_pagi_inicial = $dom->createElement("inicial");
     $_pagi_inicial->appendChild($dom->createTextNode($this->_pagi_inicial));
     $_pagi_anterior = $dom->createElement("anterior");
     $_pagi_anterior->appendChild($dom->createTextNode($this->_pagi_anterior));
     $_pagi_siguiente = $dom->createElement("siguiente");
     $_pagi_siguiente->appendChild($dom->createTextNode($this->_pagi_siguiente));
     $_pagi_ultimo = $dom->createElement("ultima");
     $_pagi_ultimo->appendChild($dom->createTextNode($this->_pagi_ultimo));
     $_pagi_total_reg = $dom->createElement("total_reg");
     $_pagi_total_reg->appendChild($dom->createTextNode($this->get_total_reg()));
     $_paginas = $dom->createElement("paginas");
     /**
      * Adicion de paginas
      */
     if ($this->_pagi_actual != $this->_pagi_inicial) {
         //for($i=$actual-1;$i>($actual-3)&&$i>=$primera;$i--)
         for ($i = $this->_pagi_actual - 1; $i > $this->_pagi_actual - 3 && $i >= $this->_pagi_inicial; $i--) {
             $arreglo[] = $i;
         }
         if ($arreglo) {
             sort($arreglo);
             if (!in_array($this->_pagi_inicial, $arreglo)) {
                 $this->_intervalo_paginas[] = $this->_pagi_inicial;
                 $nodo = $dom->createElement("num");
                 $nodo->appendChild($dom->createTextNode($this->_pagi_inicial));
                 $_paginas->appendChild($nodo);
             }
             foreach ($arreglo as $_no_pagina) {
                 if ($_no_pagina != $this->_pagi_actual) {
                     $this->_intervalo_paginas[] = $_no_pagina;
                     $nodo = $dom->createElement("num");
                     $nodo->appendChild($dom->createTextNode($_no_pagina));
                     $_paginas->appendChild($nodo);
                 }
             }
         }
     }
     //Pagina actual
     $nodo = $dom->createElement("num");
     $nodo->appendChild($dom->createTextNode($this->_pagi_actual));
     $nodo->setAttribute("actual", true);
     $_paginas->appendChild($nodo);
     if ($this->_pagi_actual != $this->_pagi_ultimo) {
         //for($i=$actual+1;$i<($actual+3)&&$i<=$ultima;$i++)
         for ($i = $this->_pagi_actual + 1; $i < $this->_pagi_actual + 3 && $i <= $this->_pagi_ultimo; $i++) {
             if ($i != $this->_pagi_actual) {
                 $this->_intervalo_paginas[] = $i;
                 $nodo = $dom->createElement("num");
                 $nodo->appendChild($dom->createTextNode($i));
                 $_paginas->appendChild($nodo);
                 $_ultima_pagina = $i;
             }
         }
         /*
         echo "<pre>";
         var_export( $_ultima_pagina );
         echo "</pre>";
         */
         if ($_ultima_pagina) {
             if ($_ultima_pagina < $this->_pagi_ultimo) {
                 $this->_intervalo_paginas[] = $this->_pagi_ultimo;
                 $nodo = $dom->createElement("num");
                 $nodo->appendChild($dom->createTextNode($this->_pagi_ultimo));
                 $_paginas->appendChild($nodo);
             }
         }
     }
     $paginacion = $dom->createElement("paginacion");
     if ($this->_reg_x_pag != $this->_reg_x_pag_default) {
         $_reg_x_pagina = $dom->createElement("reg_x_pag");
         $_reg_x_pagina->appendChild($dom->createTextNode($this->get_reg_x_pag()));
         $paginacion->appendChild($_reg_x_pagina);
     }
     $paginacion->appendChild($_pagi_actual);
     $paginacion->appendChild($_pagi_inicial);
     $paginacion->appendChild($_pagi_anterior);
     $paginacion->appendChild($_pagi_siguiente);
     $paginacion->appendChild($_pagi_ultimo);
     $paginacion->appendChild($_pagi_total_reg);
     $paginacion->appendChild($_paginas);
     $root->appendChild($paginacion);
     return array($root, $dom);
 }
Example #7
0
<?php

require_once dirname(dirname(__FILE__)) . '/config.php';
require_once 'Common/Fun_FormatText.inc.php';
require_once 'Common/Lib/Obj_RankFactory.php';
if (!CheckTourSession()) {
    print get_text('CrackError');
    exit;
}
$MaxNum = 0;
if (isset($_REQUEST["MaxNum"]) && is_numeric($_REQUEST["MaxNum"])) {
    $MaxNum = $_REQUEST["MaxNum"];
}
$ToFit = isset($_REQUEST['ToFitarco']) ? $_REQUEST['ToFitarco'] : null;
$XmlDoc = new DOMDocument('1.0', 'UTF-8');
$TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleElimination.xsl" ');
$XmlDoc->appendChild($TmpNode);
$XmlRoot = $XmlDoc->createElement('Results');
$XmlRoot->setAttribute('IANSEO', ProgramVersion);
$XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
$XmlDoc->appendChild($XmlRoot);
$ListHeader = NULL;
$options = array();
if (isset($_REQUEST["Event"]) && preg_match("/^[0-9A-Z]{1,4}\$/i", $_REQUEST["Event"])) {
    $options['events'] = array($_REQUEST["Event"]);
}
$family = 'ElimInd';
$rank = Obj_RankFactory::create($family, $options);
$rank->read();
$rankData = $rank->getData();
if (count($rankData['sections'])) {
Example #8
0
<?php

//$link = new mysqli("localhost","root","","quiz");
$link = new mysqli("mysql.hostinger.es", "u526113874_rb15", "123456789", "u526113874_quiz");
if ($link->connect_errno) {
    die("Huts egin du konexioak MySQL-ra: (" . $link->connect_errno() . ") " . $link->connect_error());
}
$sql = "Delete from galdera";
//Galdera taula osoa borratu
$link->query($sql);
$balioBerriak = $_POST['berria'];
//Balio guztiak lortu berriz
unlink("galderak.xml");
//XML fitxategia borratu
$xml = new DOMDocument();
$xslt = $xml->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="seeXMLQuestions.xsl"');
//Stylesheet gehitzeko
$xml->appendChild($xslt);
$galderak = $xml->createElement("assessmentItems");
$xml->appendChild($galderak);
$xml->save("galderak.xml");
$kopBalioak = count($balioBerriak);
$kontagailua = 0;
$xml2 = simplexml_load_file('galderak.xml');
while ($kontagailua < $kopBalioak) {
    $galdera = $balioBerriak[$kontagailua];
    $kontagailua++;
    $erantzuna = $balioBerriak[$kontagailua];
    $kontagailua++;
    $zailtasuna = $balioBerriak[$kontagailua];
    $kontagailua++;
Example #9
0
function viewCCD($ccr, $raw = "no", $requested_by = "")
{
    global $pid;
    $ccr->preserveWhiteSpace = false;
    $ccr->formatOutput = true;
    $ccr->save(dirname(__FILE__) . '/generatedXml/ccrForCCD.xml');
    $xmlDom = new DOMDocument();
    $xmlDom->loadXML($ccr->saveXML());
    $ccr_ccd = new DOMDocument();
    $ccr_ccd->load(dirname(__FILE__) . '/ccd/ccr_ccd.xsl');
    $xslt = new XSLTProcessor();
    $xslt->importStylesheet($ccr_ccd);
    $ccd = new DOMDocument();
    $ccd->preserveWhiteSpace = false;
    $ccd->formatOutput = true;
    $ccd->loadXML($xslt->transformToXML($xmlDom));
    $ccd->save(dirname(__FILE__) . '/generatedXml/ccdDebug.xml');
    if ($raw == "yes") {
        // simply send the xml to a textarea (nice debugging tool)
        echo "<textarea rows='35' cols='500' style='width:95%' readonly>";
        echo $ccd->saveXml();
        echo "</textarea>";
        return;
    }
    if ($raw == "pure") {
        // send a zip file that contains a separate xml data file and xsl stylesheet
        if (!class_exists('ZipArchive')) {
            displayError(xl("ERROR: Missing ZipArchive PHP Module"));
            return;
        }
        $tempDir = $GLOBALS['temporary_files_dir'];
        $zipName = $tempDir . "/" . getReportFilename() . "-ccd.zip";
        if (file_exists($zipName)) {
            unlink($zipName);
        }
        $zip = new ZipArchive();
        if (!$zip) {
            displayError(xl("ERROR: Unable to Create Zip Archive."));
            return;
        }
        if ($zip->open($zipName, ZIPARCHIVE::CREATE)) {
            $zip->addFile("stylesheet/cda.xsl", "stylesheet/cda.xsl");
            $xmlName = $tempDir . "/" . getReportFilename() . "-ccd.xml";
            if (file_exists($xmlName)) {
                unlink($xmlName);
            }
            $e_styleSheet = $ccd->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="stylesheet/cda.xsl"');
            $ccd->insertBefore($e_styleSheet, $ccd->firstChild);
            $ccd->save($xmlName);
            $zip->addFile($xmlName, basename($xmlName));
            $zip->close();
            header("Pragma: public");
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Content-Type: application/force-download");
            header("Content-Length: " . filesize($zipName));
            header("Content-Disposition: attachment; filename=" . basename($zipName) . ";");
            header("Content-Description: File Transfer");
            readfile($zipName);
            unlink($zipName);
            unlink($xmlName);
            exit(0);
        } else {
            displayError(xl("ERROR: Unable to Create Zip Archive."));
            return;
        }
    }
    if (substr($raw, 0, 4) == "send") {
        $recipient = trim(stripslashes(substr($raw, 5)));
        $result = transmitCCD($ccd, $recipient, $requested_by);
        echo htmlspecialchars($result, ENT_NOQUOTES);
        return;
    }
    $ss = new DOMDocument();
    $ss->load(dirname(__FILE__) . "/stylesheet/cda.xsl");
    $xslt->importStyleSheet($ss);
    $html = $xslt->transformToXML($ccd);
    echo $html;
}
Example #10
0
<?php

include "../config/config.php";
include "../config/autoloadapi.php";
$db = new Db();
$db = Db::connect();
// "Create" the document.
$xml = new DOMDocument("1.0", "ISO-8859-15");
//to have indented output, not just a line
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
// ------------- Interresting part here ------------
//creating an xslt adding processing line
$xslt = $xml->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="rssfeed.xsl"');
//adding it to the xml
$xml->appendChild($xslt);
// ----------- / Interresting part here -------------
//adding some elements
$query = "SELECT * FROM book";
$result = $db->query($query);
$books = $xml->createElement("books");
if ($result->num_rows > 0) {
    while ($row = $result->fetch_object()) {
        $book = $xml->createElement("book");
        $id = $xml->createElement("id", $row->id);
        $book->appendChild($id);
        $name = $xml->createElement("name", $row->name);
        $book->appendChild($name);
        $author = $xml->createElement("author", $row->author);
        $book->appendChild($author);
        $description = $xml->createElement("description", $row->description);
 /**
  * The main method of the PlugIn
  *
  * @access	public
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  *
  * @return	void
  */
 public function main($content, $conf)
 {
     // Initialize plugin.
     $this->init($conf);
     // Turn cache off.
     $this->setCache(FALSE);
     // Get GET and POST variables.
     $this->getUrlParams();
     // Delete expired resumption tokens.
     $this->deleteExpiredTokens();
     // Create XML document.
     $this->oai = new DOMDocument('1.0', 'UTF-8');
     // Add processing instruction (aka XSL stylesheet).
     if (!empty($this->conf['stylesheet'])) {
         // Resolve "EXT:" prefix in file path.
         if (substr($this->conf['stylesheet'], 0, 4) == 'EXT:') {
             list($extKey, $filePath) = explode('/', substr($this->conf['stylesheet'], 4), 2);
             if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
                 $this->conf['stylesheet'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($extKey) . $filePath;
             }
         }
         $stylesheet = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->conf['stylesheet']);
     } else {
         // Use default stylesheet if no custom stylesheet is given.
         $stylesheet = \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/oai/transform.xsl');
     }
     $this->oai->appendChild($this->oai->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . htmlspecialchars($stylesheet, ENT_NOQUOTES, 'UTF-8') . '"'));
     // Create root element.
     $root = $this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'OAI-PMH');
     $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $root->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd');
     // Add response date.
     $root->appendChild($this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'responseDate', gmdate('Y-m-d\\TH:i:s\\Z', $GLOBALS['EXEC_TIME'])));
     // Get response data.
     switch ($this->piVars['verb']) {
         case 'GetRecord':
             $response = $this->verbGetRecord();
             break;
         case 'Identify':
             $response = $this->verbIdentify();
             break;
         case 'ListIdentifiers':
             $response = $this->verbListIdentifiers();
             break;
         case 'ListMetadataFormats':
             $response = $this->verbListMetadataFormats();
             break;
         case 'ListRecords':
             $response = $this->verbListRecords();
             break;
         case 'ListSets':
             $response = $this->verbListSets();
             break;
         default:
             $response = $this->error('badVerb');
     }
     // Add request.
     $linkConf = array('parameter' => $GLOBALS['TSFE']->id, 'forceAbsoluteUrl' => 1);
     $request = $this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'request', htmlspecialchars($this->cObj->typoLink_URL($linkConf), ENT_NOQUOTES, 'UTF-8'));
     if (!$this->error) {
         foreach ($this->piVars as $key => $value) {
             $request->setAttribute($key, htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'));
         }
     }
     $root->appendChild($request);
     // Add response data.
     $root->appendChild($response);
     // Build XML output.
     $this->oai->appendChild($root);
     $content = $this->oai->saveXML();
     // Clean output buffer.
     \TYPO3\CMS\Core\Utility\GeneralUtility::cleanOutputBuffers();
     // Send headers.
     header('HTTP/1.1 200 OK');
     header('Cache-Control: no-cache');
     header('Content-Length: ' . strlen($content));
     header('Content-Type: text/xml; charset=utf-8');
     header('Date: ' . date('r', $GLOBALS['EXEC_TIME']));
     header('Expires: ' . date('r', $GLOBALS['EXEC_TIME'] + $this->conf['expired']));
     echo $content;
     // Flush output buffer and end script processing.
     ob_end_flush();
     exit;
 }
Example #12
0
 public function printAll()
 {
     date_default_timezone_set("Europe/Brussels");
     $xml = new DOMDocument("1.0", "UTF-8");
     //<?xml-stylesheet type="text/xsl" href="xmlstylesheets/trains.xsl"
     $xmlstylesheet = $xml->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="xmlstylesheets/trains.xsl"');
     $xml->appendChild($xmlstylesheet);
     $rootNode = $xml->createElement("connections");
     $rootNode->setAttribute("version", "0.2");
     $rootNode->setAttribute("timestamp", date("U"));
     $xml->appendChild($rootNode);
     $conId = 0;
     foreach ($this->connections as $c) {
         /* @var $c Connection */
         $connection = $xml->createElement("connection");
         $connection->setAttribute("id", $conId);
         //DEPART
         $departure = $xml->createElement("departure");
         $station = $xml->createElement("station", $c->getDepart()->getStation()->getName());
         $station->setAttribute("location", $c->getDepart()->getStation()->getY() . " " . $c->getDepart()->getStation()->getX());
         $time0 = $xml->createElement("time", date("H:i", $c->getDepart()->getTime()));
         $date0 = $xml->createElement("date", date("dmy", $c->getDepart()->getTime()));
         $departure->appendChild($time0);
         $departure->appendChild($date0);
         $departure->appendChild($station);
         $connection->appendChild($departure);
         //ARRIVAL
         $arrival = $xml->createElement("arrival");
         $station = $xml->createElement("station", $c->getArrival()->getStation()->getName());
         $station->setAttribute("location", $c->getArrival()->getStation()->getY() . " " . $c->getArrival()->getStation()->getX());
         $time0 = $xml->createElement("time", date("H:i", $c->getArrival()->getTime()));
         $date0 = $xml->createElement("date", date("dmy", $c->getArrival()->getTime()));
         $arrival->appendChild($time0);
         $arrival->appendChild($date0);
         $arrival->appendChild($station);
         $connection->appendChild($arrival);
         $delay = $xml->createElement("delay", "0");
         if ($c->getDepart()->getDelay() > 0) {
             $delay = $xml->createElement("delay", "1");
         }
         $connection->appendChild($delay);
         //OTHER
         $minutes = $c->getDuration() / 60 % 60;
         $hours = floor($c->getDuration() / 3600);
         if ($minutes < 10) {
             $minutes = "0" . $minutes;
         }
         $duration = $xml->createElement("duration", $hours . ":" . $minutes);
         $connection->appendChild($duration);
         //TRAINS
         $trains = $xml->createElement("trains");
         foreach ($c->getVias() as $v) {
             $train = $xml->createElement("train", $v->getVehicle()->getInternalId());
             $trains->appendChild($train);
         }
         $trainArr = $xml->createElement("train", $c->getArrival()->getVehicle()->getInternalId());
         $trains->appendChild($trainArr);
         $connection->appendChild($trains);
         $rootNode->appendChild($connection);
         $conId++;
     }
     echo $xml->saveXML();
 }
Example #13
0
<?php

// Create the DOMDocument for the XML output
$xmlDoc = new DOMDocument("1.0");
if ($data['format'] == "xml") {
    // Add reference to the XSLT
    $xsl = $xmlDoc->createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" . base_url() . "css/api.xsl\"");
    $xmlDoc->appendChild($xsl);
}
// Get the method called, and build the root node
$call = $data['queryInfo']['call'];
$rootNode = $xmlDoc->createElement("Cloudlog-API");
$parentNode = $xmlDoc->appendChild($rootNode);
// Get the results output
$output = $data[$call . "_Result"];
// Add the queryInfo node
$node = $xmlDoc->createElement("queryInfo");
$queryElement = $parentNode->appendChild($node);
$queryElement->setAttribute("timeStamp", date("r", time()));
$queryElement->setAttribute("calledMethod", $data['queryInfo']['call']);
//$queryElement->setAttribute("queryArgs", $queryArgsString);
$queryElement->setAttribute("resultsCount", count($data['queryInfo']['numResults']));
if (ENVIRONMENT == "development") {
    $debugInfo = $xmlDoc->createElement("debugInfo");
    $debugElement = $queryElement->appendChild($debugInfo);
    $debugElement->setAttribute("dbQuery", $data['queryInfo']['dbQuery']);
    $debugElement->setAttribute("clientVersion", $_SERVER['HTTP_USER_AGENT']);
    $debugElement->setAttribute("requestURI", $_SERVER['REQUEST_URI']);
    #	$debugElement->setAttribute("benchMark", $this->benchmark->marker['total_execution_time_start'].", ".$this->benchmark->marker['loading_time:_base_classes_start'].", ".$this->benchmark->marker['loading_time:_base_classes_end'].", ".$this->benchmark->marker['controller_execution_time_( api / add )_start']);
}
$queryElement->setAttribute("executionTime", $data['queryInfo']['executionTime']);
Example #14
0
<?php

require_once __DIR__ . '/../conf/bootstrap.php';
require_once __DIR__ . '/../conf/conf.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (!isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
        $GLOBALS["HTTP_RAW_POST_DATA"] = file_get_contents("php://input");
    }
    if (array_key_exists("CONTENT_TYPE", $_SERVER) && strpos($_SERVER["CONTENT_TYPE"], "/xml") !== FALSE) {
        $xmlstr = $GLOBALS["HTTP_RAW_POST_DATA"];
        $params = [];
        parse_str($_SERVER['QUERY_STRING'], $params);
        if (isset($params["xsltDocument"])) {
            $doc = new \DOMDocument();
            $xslt = $doc->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="stylesheets/Archive/' . $params["xsltDocument"] . '"');
            $doc->appendChild($xslt);
            $xml = new \DOMDocument();
            $xml->loadXML($xmlstr);
            $root = $xml->documentElement;
            $newRoot = $doc->importNode($root, true);
            $doc->appendChild($newRoot);
            \XML_Output::tryHTML($doc->saveXML(), true);
            exit(0);
        }
        throw new \Exception("Unsupported Media Type. */xml content type supported only.", 415);
    }
    throw new \Exception("Query param `xsltDocument` not found", 400);
}
throw new \Exception("Method not allowed", 405);
function generate_europasslp_xml($userid, $showHTML = false, $locale = 'en_GB', $internaldateformat = 'dmy11', $externaldateformat = '/numeric/long', $convert = false)
{
    // ================================
    // Load values from Mahara database
    // ================================
    // load user's existing contact information
    $element_list = array('firstname' => 'text', 'lastname' => 'text');
    $contactinfo = array('firstname' => null, 'lastname' => null);
    $contactinfo_data = get_records_select_array('artefact', "owner=? AND artefacttype IN (" . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($element_list))) . ")", array($userid));
    if ($contactinfo_data) {
        foreach ($contactinfo_data as $field) {
            $contactinfo[$field->artefacttype] = $field->title;
        }
    }
    // load user's existing demographics information
    $demographics = null;
    try {
        $demographics = artefact_instance_from_type('personalinformation', $userid);
    } catch (Exception $e) {
    }
    // load user's existing mother tongue(s) and foreign language(s)
    $artefact_id = get_field('artefact', 'id', 'artefacttype', 'mothertongue', 'owner', $userid);
    if ($artefact_id !== false) {
        $mothertongue_list = get_records_select_array('artefact_europass_mothertongue', "artefact=?", array($artefact_id));
    } else {
        $mothertongue_list = array();
    }
    $artefact_id = get_field('artefact', 'id', 'artefacttype', 'otherlanguage', 'owner', $userid);
    if ($artefact_id !== false) {
        $otherlanguage_list = get_records_select_array('artefact_europass_otherlanguage', "artefact=?", array($artefact_id));
    } else {
        $otherlanguage_list = array();
    }
    // ======================
    // Dinamically create XML
    // ======================
    $xmlDoc = new DOMDocument('1.0', 'UTF-8');
    // We want a nice output
    //$xmlDoc->formatOutput = true;
    $styleSheet = $xmlDoc->createProcessingInstruction('xml-stylesheet', 'href="http://europass.cedefop.europa.eu/xml/lp_' . $locale . '_V2.0.xsl" type="text/xsl"');
    $xmlDoc->appendChild($styleSheet);
    $rootElement = $xmlDoc->createElement('europass:learnerinfo');
    $rootNode = $xmlDoc->appendChild($rootElement);
    $rootNode->setAttribute('locale', $locale);
    $rootNode->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
    $rootNode->setAttribute('xmlns:europass', 'http://europass.cedefop.europa.eu/Europass/V2.0');
    $rootNode->setAttribute('xsi:schemaLocation', 'http://europass.cedefop.europa.eu/Europass/V2.0 http://europass.cedefop.europa.eu/xml/EuropassSchema_V2.0.xsd');
    $children = array('docinfo', 'prefs', 'identification', 'languagelist');
    foreach ($children as $child) {
        $childRoot = $xmlDoc->getElementsByTagName('europass:learnerinfo')->item(0);
        $childElement = $xmlDoc->createElement($child);
        $childRoot->appendChild($childElement);
    }
    // =======================
    // Dinamically set docinfo
    // =======================
    // Dinamically set issuedate
    $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0);
    $childElement = $xmlDoc->createElement('issuedate');
    $childElement->nodeValue = date('Y-m-d\\TH:i:sP');
    $childRoot->appendChild($childElement);
    // Dinamically set xsdversion
    $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0);
    $childElement = $xmlDoc->createElement('xsdversion');
    $childElement->nodeValue = 'V2.0';
    $childRoot->appendChild($childElement);
    // Dinamically set comment
    $childRoot = $xmlDoc->getElementsByTagName('docinfo')->item(0);
    $childElement = $xmlDoc->createElement('comment');
    $childElement->nodeValue = 'Automatically generated Europass Language Passport from Mahara e-portfolio data';
    $childRoot->appendChild($childElement);
    // ========================================
    // Dinamically set prefs and identification
    // ========================================
    // Dinamically set first and last name
    $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0);
    $childElement = $xmlDoc->createElement('field');
    $childElement->setAttribute('name', 'personal.lastName');
    $childElement->setAttribute('before', 'personal.firstName');
    $childRoot->appendChild($childElement);
    $childRoot = $xmlDoc->getElementsByTagName('identification')->item(0);
    $childElement = $xmlDoc->createElement('firstname');
    $childElement->nodeValue = valid_xml_string($contactinfo['firstname']);
    $childRoot->appendChild($childElement);
    $childElement = $xmlDoc->createElement('lastname');
    $childElement->nodeValue = valid_xml_string($contactinfo['lastname']);
    $childRoot->appendChild($childElement);
    // ----------------------------
    // Dinamically set demographics
    // ----------------------------
    $childRoot = $xmlDoc->getElementsByTagName('identification')->item(0);
    $childElement = $xmlDoc->createElement('demographics');
    $childRoot->appendChild($childElement);
    // Dinamically set birthdate
    $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0);
    $childElement = $xmlDoc->createElement('field');
    $childElement->setAttribute('name', 'personal.birthDate');
    $childElement->setAttribute('keep', !empty($demographics) ? 'false' : 'true');
    $childElement->setAttribute('format', $externaldateformat);
    $childRoot->appendChild($childElement);
    $childRoot = $xmlDoc->getElementsByTagName('demographics')->item(0);
    $childElement = $xmlDoc->createElement('birthdate');
    $childElement->nodeValue = !empty($demographics) ? strftime('%Y-%m-%d', $demographics->get_composite('dateofbirth') + 3600) : null;
    $childRoot->appendChild($childElement);
    // =======================================
    // Dinamically set prefs and language list
    // =======================================
    // Dinamically add mother tongue(s)
    $childRoot = $xmlDoc->getElementsByTagName('languagelist')->item(0);
    $childElement = $xmlDoc->createElement('language');
    $childElement->setAttribute('xsi:type', 'europass:mother');
    $childRoot->appendChild($childElement);
    $language_label = null;
    if (!empty($mothertongue_list)) {
        foreach ($mothertongue_list as $mothertongue) {
            $language_label .= get_string_from_file('language.' . $mothertongue->language, get_config('docroot') . 'artefact/europass/lang/' . get_lang_from_locale($locale) . '/artefact.europass.php') . ', ';
        }
        $language_label = substr($language_label, 0, -2);
        // omitt last comma and whitespace from $language_label
        $childRoot = $xmlDoc->getElementsByTagName('language')->item(0);
        if (count($mothertongue_list) == 1) {
            $childElement = $xmlDoc->createElement('code');
            $childElement->nodeValue = $mothertongue->language;
            $childRoot->appendChild($childElement);
        }
        $childElement = $xmlDoc->createElement('label');
        $childElement->nodeValue = $language_label;
        $childRoot->appendChild($childElement);
    }
    //Dinamically add foreign language(s)
    $l = 0;
    if (!empty($otherlanguage_list)) {
        foreach ($otherlanguage_list as $otherlanguage) {
            // Get otherlanguage's diploma list
            if ($otherlanguage->id !== false) {
                $diploma_list = get_records_select_array('artefact_europass_languagediploma', "languageid=?", array($otherlanguage->id));
            } else {
                $diploma_list = array();
            }
            // Get otherlanguage's experience list
            if ($otherlanguage->id !== false) {
                $experience_list = get_records_select_array('artefact_europass_languageexperience', "languageid=?", array($otherlanguage->id));
            } else {
                $experience_list = array();
            }
            $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0);
            // Set foreign language
            $childElement = $xmlDoc->createElement('field');
            $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].ass');
            $childElement->setAttribute('keep', $otherlanguage->language == null ? 'false' : 'true');
            $childRoot->appendChild($childElement);
            // Set foreign language diploma(s)
            if (!empty($diploma_list)) {
                for ($d = 0; $d < count($diploma_list); $d++) {
                    $childElement = $xmlDoc->createElement('field');
                    $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].diplomaList[' . $d . ']');
                    $childElement->setAttribute('keep', 'true');
                    $childRoot->appendChild($childElement);
                }
            }
            // Set foreign language experience(s)
            if (!empty($experience_list)) {
                for ($e = 0; $e < count($experience_list); $e++) {
                    $childElement = $xmlDoc->createElement('field');
                    $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].experienceList[' . $e . ']');
                    $childElement->setAttribute('keep', 'true');
                    $childRoot->appendChild($childElement);
                    $childElement = $xmlDoc->createElement('field');
                    $childElement->setAttribute('name', 'foreignLanguageList[' . $l . '].experienceList[' . $e . '].period');
                    $childElement->setAttribute('format', $externaldateformat);
                    $childRoot->appendChild($childElement);
                }
            }
            // Dinamically set data for each foreign language
            $childRoot = $xmlDoc->getElementsByTagName('languagelist')->item(0);
            $childElement = $xmlDoc->createElement('language');
            $childElement->setAttribute('xsi:type', 'europass:foreign');
            $childRoot->appendChild($childElement);
            $childRoot = $xmlDoc->getElementsByTagName('language')->item($l + 1);
            // Because mothertongue has index 0...
            $childElement = $xmlDoc->createElement('code');
            $childElement->nodeValue = $otherlanguage->language;
            $childRoot->appendChild($childElement);
            $childElement = $xmlDoc->createElement('label');
            $childElement->nodeValue = get_string_from_file('language.' . $otherlanguage->language, get_config('docroot') . 'artefact/europass/lang/' . get_lang_from_locale($locale) . '/artefact.europass.php');
            $childRoot->appendChild($childElement);
            $childElement = $xmlDoc->createElement('level');
            $childRoot->appendChild($childElement);
            // language levels
            $grandchildRoot = $childRoot->lastChild;
            $levels = array('listening' => $otherlanguage->listening, 'reading' => $otherlanguage->reading, 'spokeninteraction' => $otherlanguage->spokeninteraction, 'spokenproduction' => $otherlanguage->spokenproduction, 'writing' => $otherlanguage->writing);
            foreach ($levels as $field => $value) {
                $grandchildElement = $xmlDoc->createElement($field);
                $grandchildElement->nodeValue = strtolower($value);
                $grandchildRoot->appendChild($grandchildElement);
            }
            // language diploma list
            $childElement = $xmlDoc->createElement('diplomalist');
            $childRoot->appendChild($childElement);
            //language experience list
            $childElement = $xmlDoc->createElement('experiencelist');
            $childRoot->appendChild($childElement);
            // -----------------------------
            // language diploma list entries
            // -----------------------------
            $parentRoot = $xmlDoc->getElementsByTagName('diplomalist')->item($l);
            if (!empty($diploma_list)) {
                foreach ($diploma_list as $diploma) {
                    $parentElement = $xmlDoc->createElement('diploma');
                    $parentRoot->appendChild($parentElement);
                    $childRoot = $parentRoot->lastChild;
                    // diploma title
                    $childElement = $xmlDoc->createElement('title');
                    $childElement->nodeValue = valid_xml_string($diploma->certificate);
                    $childRoot->appendChild($childElement);
                    // diploma awarding body
                    $childElement = $xmlDoc->createElement('awardingBody');
                    $childElement->nodeValue = $showHTML ? replacehtmlchars(nl2br($diploma->awardingbody)) : valid_xml_string($diploma->awardingbody);
                    // Execute nl2br transformation for HTML display...
                    $childRoot->appendChild($childElement);
                    // diploma date
                    $childElement = $xmlDoc->createElement('date');
                    $childRoot->appendChild($childElement);
                    $grandchildRoot = $childRoot->firstChild->nextSibling->nextSibling;
                    if ($diploma->certificatedate != null) {
                        if (date('Y', strtotime($diploma->certificatedate)) != null) {
                            $grandchildElement = $xmlDoc->createElement('year');
                            $grandchildElement->nodeValue = date('Y', strtotime($diploma->certificatedate));
                            $grandchildRoot->appendChild($grandchildElement);
                        }
                        if (date('m', strtotime($diploma->certificatedate)) != null) {
                            $grandchildElement = $xmlDoc->createElement('month');
                            $grandchildElement->nodeValue = '--' . date('m', strtotime($diploma->certificatedate));
                            $grandchildRoot->appendChild($grandchildElement);
                        }
                        if (date('d', strtotime($diploma->certificatedate)) != null) {
                            $grandchildElement = $xmlDoc->createElement('day');
                            $grandchildElement->nodeValue = '---' . date('d', strtotime($diploma->certificatedate));
                            $grandchildRoot->appendChild($grandchildElement);
                        }
                    }
                    // diploma level
                    $childElement = $xmlDoc->createElement('level');
                    $childElement->nodeValue = strtolower($diploma->europeanlevel);
                    $childRoot->appendChild($childElement);
                }
            }
            // --------------------------------
            // language experience list entries
            // --------------------------------
            $parentRoot = $xmlDoc->getElementsByTagName('experiencelist')->item($l);
            if (!empty($experience_list)) {
                foreach ($experience_list as $experience) {
                    $parentElement = $xmlDoc->createElement('experience');
                    $parentRoot->appendChild($parentElement);
                    $childRoot = $parentRoot->lastChild;
                    // experience period
                    $childElement = $xmlDoc->createElement('period');
                    $childRoot->appendChild($childElement);
                    // experience period - from
                    $grandchildRoot = $childRoot->firstChild;
                    $grandchildElement = $xmlDoc->createElement('from');
                    $grandchildRoot->appendChild($grandchildElement);
                    $grandgrandchildRoot = $grandchildRoot->firstChild;
                    if ($experience->startdate != null) {
                        if (date('Y', strtotime($experience->startdate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('year');
                            $grandgrandchildElement->nodeValue = date('Y', strtotime($experience->startdate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                        if (date('m', strtotime($experience->startdate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('month');
                            $grandgrandchildElement->nodeValue = '--' . date('m', strtotime($experience->startdate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                        if (date('d', strtotime($experience->startdate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('day');
                            $grandgrandchildElement->nodeValue = '---' . date('d', strtotime($experience->startdate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                    }
                    // experience period - to
                    $grandchildElement = $xmlDoc->createElement('to');
                    $grandchildRoot->appendChild($grandchildElement);
                    $grandgrandchildRoot = $grandchildRoot->firstChild->nextSibling;
                    if ($experience->enddate != null) {
                        if (date('Y', strtotime($experience->enddate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('year');
                            $grandgrandchildElement->nodeValue = date('Y', strtotime($experience->enddate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                        if (date('m', strtotime($experience->enddate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('month');
                            $grandgrandchildElement->nodeValue = '--' . date('m', strtotime($experience->enddate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                        if (date('d', strtotime($experience->enddate)) != null) {
                            $grandgrandchildElement = $xmlDoc->createElement('day');
                            $grandgrandchildElement->nodeValue = '---' . date('d', strtotime($experience->enddate));
                            $grandgrandchildRoot->appendChild($grandgrandchildElement);
                        }
                    }
                    // experience description
                    $childElement = $xmlDoc->createElement('description');
                    $childElement->nodeValue = $showHTML ? replacehtmlchars(nl2br($experience->description)) : valid_xml_string($experience->description);
                    $childRoot->appendChild($childElement);
                }
            }
            $l++;
        }
    }
    // ===================================
    // Dinamically set prefs (grid option)
    // ===================================
    $childRoot = $xmlDoc->getElementsByTagName('prefs')->item(0);
    $childElement = $xmlDoc->createElement('field');
    $childElement->setAttribute('name', 'grid');
    $childElement->setAttribute('keep', 'true');
    $childRoot->appendChild($childElement);
    // ================================
    // Return dinamically generated XML
    // ================================
    return $xmlDoc->saveXML();
}
<?php

$doc = new DOMDocument();
$node = $doc->createElement("para");
$newnode = $doc->appendChild($node);
try {
    $test_proc_inst = $doc->createProcessingInstruction("bla bla bla");
    $node->appendChild($test_proc_inst);
    echo $doc->saveXML();
} catch (DOMException $e) {
    echo 'Test failed!', PHP_EOL;
}
Example #17
0
$Path = $_GET['path'];
$Path = preg_replace('/\\s/', '+', $Path);
if (isset($_GET['numeroplanche'])) {
    require_once '/var/www/appli/class/class.exa.php';
    $obj = new exaprint();
    $obj->logFile(basename(__FILE__), "script", "RUN", "DomXML.php?{$_GET['numeroplanche']}");
    if (!empty($Path)) {
        require 'class/class.fichefab.planches.mssql.php';
        require 'class/class.fichefab.cmd.mssql.php';
        // nouvel obj DOMxml
        $dom = new DOMDocument('1.0', 'UTF-8');
        //to have indented output, not just a link
        $dom->preserveWhiteSpace = true;
        $dom->formatOutput = true;
        // insert xsl
        $xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="http://94.103.137.90/PrinergyWeb/xml/template.xsl"');
        $dom->appendChild($xslt);
        // root <fichefab>
        $new_fichefab = $dom->createElement('fichefab');
        $dom->appendChild($new_fichefab);
        // add comment fichefab/<planches>
        $commentObject = $dom->createComment('planches');
        $new_fichefab->appendChild($commentObject);
        // fichefab/<planches>
        $new_planches = $dom->createElement('planches');
        $new_fichefab->appendChild($new_planches);
        // add comment fichefab/planches/<spec> et attributes
        $commentObject = $dom->createComment('Caracteristiques de la planches');
        $new_planches->appendChild($commentObject);
        // fichefab/planches/<spec> et attributes
        $new_spec = $dom->createElement('spec');
<?php

$doc = new DOMDocument();
$node = $doc->createElement("para");
$newnode = $doc->appendChild($node);
$test_proc_inst0 = $doc->createProcessingInstruction("blablabla");
$node->appendChild($test_proc_inst0);
$test_proc_inst1 = $doc->createProcessingInstruction("blablabla", "datadata");
$node->appendChild($test_proc_inst1);
echo $doc->saveXML();
Example #19
0
 private static function render_adf($lead)
 {
     //create the xml document
     $xmlDoc = new DOMDocument('1.0', 'utf-8');
     $adfImplementation = new DOMImplementation();
     $doc = $adfImplementation->createDocument(NULL, "ADF");
     $pi = $xmlDoc->createProcessingInstruction('ADF', 'version="1.0"');
     $xmlDoc->appendChild($pi);
     $xmlDoc->formatOutput = true;
     //create the root element
     $root = $xmlDoc->appendChild($xmlDoc->createElement("adf"));
     $prospect = $xmlDoc->createElement("prospect");
     $root->appendChild($prospect);
     // ID
     $id = $xmlDoc->createElement("id");
     $id->setAttribute('sequence', 'uniqueLeadId');
     $id->setAttribute('source', get_bloginfo('name'));
     $prospect->appendChild($id);
     // Request Date
     $reqDate = $xmlDoc->createElement("requestdate");
     $reqDate->appendChild($xmlDoc->createTextNode(date(DATE_ATOM)));
     $prospect->appendChild($reqDate);
     // Vehicle
     $data_vehicle = $lead->get_data('vehicle');
     $vehicle = $xmlDoc->createElement("vehicle");
     $prospect->appendChild($vehicle);
     static::fill_section($data_vehicle, $vehicle, $xmlDoc);
     // Customer
     $data_customer = $lead->get_data('customer');
     $customer = $xmlDoc->createElement("customer");
     $prospect->appendChild($customer);
     static::fill_section($data_customer, $customer, $xmlDoc);
     // Vendor
     $data_vendor = $lead->get_data('vendor');
     $vendor = $xmlDoc->createElement("vendor");
     $prospect->appendChild($vendor);
     static::fill_section($data_vendor, $vendor, $xmlDoc);
     // Provider
     $data_provider = $lead->get_data('provider');
     $provider = $xmlDoc->createElement("provider");
     $prospect->appendChild($provider);
     static::fill_section($data_provider, $provider, $xmlDoc);
     $xpath = new DOMXPath($xmlDoc);
     while (($node_list = $xpath->query('//*[not(*) and not(@*) and not(text()[normalize-space()])]')) && $node_list->length) {
         foreach ($node_list as $node) {
             $node->parentNode->removeChild($node);
         }
     }
     return $xmlDoc->saveXML();
     /*
     <?ADF VERSION "1.0"?>
     <?XML VERSION “1.0”?>
     <adf>
     <prospect>
     <requestdate>2000-03-30T15:30:20-08:00</requestdate>
     <vehicle>
     <year>1999</year>
     <make>Chevrolet</make>
     <model>Blazer</model>
     </vehicle>
     <customer>
      <contact>
      <name part="full">John Doe</name>
      <phone>393-999-3922</phone>
      </contact>
      </customer>
     <vendor>
      <contact>
      <name part="full">Acura of Bellevue</name>
      </contact>
     </vendor>
     </prospect>
     </adf>            
     */
 }
 function se_sitemap_create()
 {
     $se_sitemap_settings = get_option('se_sitemap_settings');
     $sitemap = new DOMDocument('1.0', 'utf-8');
     $mobileXmlNS = 'http://www.google.com/schemas/sitemap-mobile/1.0';
     $mobileNodeType = array('', '', '', 'pc,mobile', 'htmladapt');
     $priorityNodeValue = array('0.0', '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0');
     $freqNodeValue = array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never');
     foreach ($se_sitemap_settings['settings']['sitemap_settings'] as $item) {
         if ($item['mobile'] > 2) {
             $mobileXmlNS = 'http://www.baidu.com/schemas/sitemap-mobile/1/';
             break;
         }
     }
     $sitemap_stylesheet_path = defined('WP_CONTENT_DIR') ? home_url('/') . basename(WP_CONTENT_DIR) : home_url('/') . 'wp-content';
     $sitemap_stylesheet_path .= defined('WP_PLUGIN_DIR') ? '/' . basename(WP_PLUGIN_DIR) . '/searchengine-sitemap-gen/sitemap.xsl' : '/plugins/searchengine-sitemap-gen/sitemap.xsl';
     $xslt = $sitemap->createProcessingInstruction('xml-stylesheet', "type=\"text/xsl\" href=\"{$sitemap_stylesheet_path}\"");
     $sitemap->appendChild($xslt);
     $sitemapNS = $sitemap->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
     $sitemapNS->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:mobile', $mobileXmlNS);
     $urlset = $sitemap->appendChild($sitemapNS);
     // Add Home Page
     if ($se_sitemap_settings['settings']['sitemap_settings']['home_page']['include'] == 1) {
         $homepage_url = $urlset->appendChild($sitemap->createElement('url'));
         $homepage_loc = $homepage_url->appendChild($sitemap->createElement('loc'));
         $homepage_loc->appendChild($sitemap->createTextNode(home_url()));
         if ($se_sitemap_settings['settings']['sitemap_settings']['home_page']['mobile'] > 0) {
             $postpage_moblie = $sitemap->createElementNS($mobileXmlNS, 'mobile:mobile');
             if ($se_sitemap_settings['settings']['sitemap_settings']['home_page']['mobile'] > 2) {
                 $postpage_moblie->setAttribute('type', $mobileNodeType[$se_sitemap_settings['settings']['sitemap_settings']['home_page']['mobile']]);
             }
             $homepage_moblie_node = $homepage_url->appendChild($postpage_moblie);
             $homepage_url->appendChild($homepage_moblie_node);
         }
         $homepage_lastmod = $homepage_url->appendChild($sitemap->createElement('lastmod'));
         $homepage_lastmod->appendChild($sitemap->createTextNode(date('Y-m-d\\TH:i:sP')));
         $homepage_changefreq = $homepage_url->appendChild($sitemap->createElement('changefreq'));
         $homepage_changefreq->appendChild($sitemap->createTextNode($freqNodeValue[$se_sitemap_settings['settings']['sitemap_settings']['home_page']['frequency']]));
         $homepage_priority = $homepage_url->appendChild($sitemap->createElement('priority'));
         $homepage_priority->appendChild($sitemap->createTextNode($priorityNodeValue[$se_sitemap_settings['settings']['sitemap_settings']['home_page']['priority']]));
     }
     // Add Post
     if ($se_sitemap_settings['settings']['sitemap_settings']['post_page']['include'] == 1) {
         $posts_args = array('numberposts' => $se_sitemap_settings['settings']['general_settings']['se_sitemap_islimit'] == 1 ? $se_sitemap_settings['settings']['general_settings']['se_sitemap_limit'] : 45000, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish');
         $posts_array = get_posts($posts_args);
         foreach ($posts_array as $post) {
             $node_url = $urlset->appendChild($sitemap->createElement('url'));
             // Set Loc
             $node_loc = $node_url->appendChild($sitemap->createElement('loc'));
             $post_permalink = get_permalink($post);
             $node_loc->appendChild($sitemap->createTextNode($post_permalink));
             // Set Mobile
             if ($se_sitemap_settings['settings']['sitemap_settings']['post_page']['mobile'] > 0) {
                 $postpage_moblie = $sitemap->createElementNS($mobileXmlNS, 'mobile:mobile');
                 if ($se_sitemap_settings['settings']['sitemap_settings']['post_page']['mobile'] > 2) {
                     $postpage_moblie->setAttribute('type', $mobileNodeType[$se_sitemap_settings['settings']['sitemap_settings']['post_page']['mobile']]);
                 }
                 $postpage_moblie_node = $node_url->appendChild($postpage_moblie);
                 $node_url->appendChild($postpage_moblie_node);
             }
             // Set Lastmod
             $node_lastmod = $node_url->appendChild($sitemap->createElement('lastmod'));
             $post_lastmod = date('Y-m-d\\TH:i:sP', strtotime($post->post_modified));
             $node_lastmod->appendChild($sitemap->createTextNode($post_lastmod));
             // Set Changefreq
             $node_changefreq = $node_url->appendChild($sitemap->createElement('changefreq'));
             $node_changefreq->appendChild($sitemap->createTextNode($freqNodeValue[$se_sitemap_settings['settings']['sitemap_settings']['post_page']['frequency']]));
             // Set Priority
             $node_priority = $node_url->appendChild($sitemap->createElement('priority'));
             $node_priority->appendChild($sitemap->createTextNode($priorityNodeValue[$se_sitemap_settings['settings']['sitemap_settings']['post_page']['priority']]));
         }
     }
     //Add Pages
     $pages_args = array('sort_order' => 'desc', 'sort_column' => 'post_date', 'post_status' => 'publish');
     $pages_array = get_pages($pages_args);
     foreach ($pages_array as $page) {
         $node_url = $urlset->appendChild($sitemap->createElement('url'));
         // Set Loc
         $node_loc = $node_url->appendChild($sitemap->createElement('loc'));
         $page_permalink = get_page_link($page->ID);
         $node_loc->appendChild($sitemap->createTextNode($page_permalink));
         // Set Lastmod
         $node_lastmod = $node_url->appendChild($sitemap->createElement('lastmod'));
         $page_lastmod = date('Y-m-d\\TH:i:sP', strtotime($page->post_modified));
         $node_lastmod->appendChild($sitemap->createTextNode($page_lastmod));
         // Set Changefreq
         $node_changefreq = $node_url->appendChild($sitemap->createElement('changefreq'));
         $node_changefreq->appendChild($sitemap->createTextNode('weekly'));
         // Set Priority
         $node_priority = $node_url->appendChild($sitemap->createElement('priority'));
         $node_priority->appendChild($sitemap->createTextNode('1'));
     }
     // Add Cates
     $cates_args = array('orderby' => 'name', 'order' => 'ASC');
     $cates_array = get_categories($cates_args);
     foreach ($cates_array as $cate) {
         $node_url = $urlset->appendChild($sitemap->createElement('url'));
         // Set Loc
         $node_loc = $node_url->appendChild($sitemap->createElement('loc'));
         $cate_permalink = get_category_link($cate->term_id);
         $node_loc->appendChild($sitemap->createTextNode($cate_permalink));
         // Set Lastmod
         $node_lastmod = $node_url->appendChild($sitemap->createElement('lastmod'));
         $cate_lastmod = date('Y-m-d\\TH:i:sP');
         $node_lastmod->appendChild($sitemap->createTextNode($cate_lastmod));
         // Set Changefreq
         $node_changefreq = $node_url->appendChild($sitemap->createElement('changefreq'));
         $node_changefreq->appendChild($sitemap->createTextNode('weekly'));
         // Set Priority
         $node_priority = $node_url->appendChild($sitemap->createElement('priority'));
         $node_priority->appendChild($sitemap->createTextNode('1'));
     }
     // Add Tags
     $tags_array = get_tags();
     foreach ($tags_array as $tag) {
         $node_url = $urlset->appendChild($sitemap->createElement('url'));
         // Set Loc
         $node_loc = $node_url->appendChild($sitemap->createElement('loc'));
         $tag_permalink = get_tag_link($tag->term_id);
         $node_loc->appendChild($sitemap->createTextNode($tag_permalink));
         // Set Lastmod
         $node_lastmod = $node_url->appendChild($sitemap->createElement('lastmod'));
         $tag_lastmod = date('Y-m-d\\TH:i:sP');
         $node_lastmod->appendChild($sitemap->createTextNode($tag_lastmod));
         // Set Changefreq
         $node_changefreq = $node_url->appendChild($sitemap->createElement('changefreq'));
         $node_changefreq->appendChild($sitemap->createTextNode('weekly'));
         // Set Priority
         $node_priority = $node_url->appendChild($sitemap->createElement('priority'));
         $node_priority->appendChild($sitemap->createTextNode('1'));
     }
     // Add Users
     $users_array = get_users();
     foreach ($users_array as $user) {
         $node_url = $urlset->appendChild($sitemap->createElement('url'));
         // Set Loc
         $node_loc = $node_url->appendChild($sitemap->createElement('loc'));
         $user_permalink = home_url() . '/index.php/author/' . $user->display_name;
         $node_loc->appendChild($sitemap->createTextNode($user_permalink));
         // Set Lastmod
         $node_lastmod = $node_url->appendChild($sitemap->createElement('lastmod'));
         $user_lastmod = date('Y-m-d\\TH:i:sP');
         $node_lastmod->appendChild($sitemap->createTextNode($user_lastmod));
         // Set Changefreq
         $node_changefreq = $node_url->appendChild($sitemap->createElement('changefreq'));
         $node_changefreq->appendChild($sitemap->createTextNode('weekly'));
         // Set Priority
         $node_priority = $node_url->appendChild($sitemap->createElement('priority'));
         $node_priority->appendChild($sitemap->createTextNode('1'));
     }
     $sitemap->formatOutput = true;
     if (is_multisite()) {
         $home_url = preg_replace("/[^a-zA-Z0-9\\s]/", "_", str_replace('http://', '', str_replace('https://', '', home_url())));
         $sitemap->save(ABSPATH . 'sitemap_' . $home_url . '.xml');
     } else {
         $sitemap->save(ABSPATH . 'sitemap.xml');
     }
 }
function XmlCreateBracketIndividual($EventRequested = '')
{
    $XmlDoc = new DOMDocument('1.0', 'UTF-8');
    $TmpNode = $XmlDoc->createProcessingInstruction("xml-stylesheet", 'type="text/xsl" href="/Common/Styles/StyleBracket.xsl" ');
    $XmlDoc->appendChild($TmpNode);
    $XmlRoot = $XmlDoc->createElement('Results');
    $XmlRoot->setAttribute('IANSEO', ProgramVersion);
    $XmlRoot->setAttribute('TS', date('Y-m-d H:i:s'));
    $XmlDoc->appendChild($XmlRoot);
    $ListHeader = NULL;
    $options = array();
    if (isset($_REQUEST["Event"]) && $_REQUEST["Event"][0] != ".") {
        $options['events'] = $_REQUEST["Event"];
    }
    if ($EventRequested) {
        $options['events'] = $EventRequested;
    }
    $rank = Obj_RankFactory::create('GridInd', $options);
    $rank->read();
    $rankData = $rank->getData();
    foreach ($rankData['sections'] as $Event => $Data) {
        // New Event
        $ListHeader = $XmlDoc->createElement('List');
        $ListHeader->setAttribute('Title', $Data['meta']['eventName']);
        $ListHeader->setAttribute('Columns', '4');
        $XmlRoot->appendChild($ListHeader);
        foreach ($Data['phases'] as $Phase => $items) {
            // new Phase
            $XmlPhase = $XmlDoc->createElement('Phase');
            $XmlPhase->setAttribute('Title', $items['meta']['phaseName']);
            $XmlPhase->setAttribute('Columns', '4');
            $ListHeader->appendChild($XmlPhase);
            // creo le colonne
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 1');
            $TmpNode->setAttribute('Name', 'Athlete1');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Athlete') . ' 2');
            $TmpNode->setAttribute('Name', 'Athlete2');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 1');
            $TmpNode->setAttribute('Name', 'Score1');
            $TmpNode->setAttribute('Columns', '1');
            $XmlPhase->appendChild($TmpNode);
            $TmpNode = $XmlDoc->createElement('Caption', get_text('Total') . ' 2');
            $TmpNode->setAttribute('Name', 'Score2');
            $TmpNode->setAttribute('Columns', '2');
            $XmlPhase->appendChild($TmpNode);
            foreach ($items['items'] as $match) {
                // creo il nuovo match e leggo il secondo atleta
                $XmlMatch = $XmlDoc->createElement('Match');
                $XmlPhase->appendChild($XmlMatch);
                $Win1 = ($match['tie'] or $Data['meta']['matchMode'] ? $match['setScore'] > $match['oppSetScore'] : $match['score'] > $match['oppScore']);
                $Win2 = ($match['oppTie'] or $Data['meta']['matchMode'] ? $match['setScore'] < $match['oppSetScore'] : $match['score'] < $match['oppScore']);
                $Tiebreak1 = array();
                $Tiebreak2 = array();
                if ($match['tie'] == 1 || $match['oppTie'] == 1) {
                    for ($i = 0; $i < max(strlen($match['tiebreak']), strlen($match['oppTiebreak'])); ++$i) {
                        $Tiebreak1[] = DecodeFromLetter($match['tiebreak'][$i]);
                        $Tiebreak2[] = DecodeFromLetter($match['oppTiebreak'][$i]);
                    }
                }
                $Tiebreak1 = trim(join(' ', $Tiebreak1));
                if ($Tiebreak1 != '') {
                    $Tiebreak1 = '(' . $Tiebreak1 . ')';
                }
                $Tiebreak2 = trim(join(' ', $Tiebreak2));
                if ($Tiebreak2 != '') {
                    $Tiebreak2 = '(' . $Tiebreak2 . ')';
                }
                // ath1
                $XmlAthlete = $XmlDoc->createElement('Athlete');
                $XmlAthlete->setAttribute('Win', $Win1);
                $XmlAthlete->setAttribute('MatchNo', $match['matchNo']);
                $XmlMatch->appendChild($XmlAthlete);
                $TmpNode = $XmlDoc->createElement('Name', $match['athlete']);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Country', $match['countryCode'] ? '(' . $match['countryCode'] . ' - ' . $match['countryName'] . ')' : ' ');
                $XmlAthlete->appendChild($TmpNode);
                $score = ' ';
                if ($match['athlete']) {
                    if ($match['tie'] == 2) {
                        $score = get_text('Bye');
                    } elseif ($Data['meta']['matchMode']) {
                        $score = $match['setScore'] + $match['oppSetScore'] ? $match['setScore'] : ' ';
                    } else {
                        $score = $match['score'] + $match['oppScore'] ? $match['score'] : ' ';
                    }
                }
                $TmpNode = $XmlDoc->createElement('Score', $score);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak1);
                $XmlAthlete->appendChild($TmpNode);
                // ath2
                $XmlAthlete = $XmlDoc->createElement('Athlete');
                $XmlAthlete->setAttribute('Win', $Win2);
                $XmlAthlete->setAttribute('MatchNo', $match['oppMatchNo']);
                $XmlMatch->appendChild($XmlAthlete);
                $TmpNode = $XmlDoc->createElement('Name', $match['oppAthlete']);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Country', $match['oppCountryCode'] ? '(' . $match['oppCountryCode'] . ' - ' . $match['oppCountryName'] . ')' : ' ');
                $XmlAthlete->appendChild($TmpNode);
                $score = ' ';
                if ($match['oppAthlete']) {
                    if ($match['oppTie'] == 2) {
                        $score = get_text('Bye');
                    } elseif ($Data['meta']['matchMode']) {
                        $score = $match['setScore'] + $match['oppSetScore'] ? $match['oppSetScore'] : ' ';
                    } else {
                        $score = $match['score'] + $match['oppScore'] ? $match['oppScore'] : ' ';
                    }
                }
                $TmpNode = $XmlDoc->createElement('Score', $score);
                $XmlAthlete->appendChild($TmpNode);
                $TmpNode = $XmlDoc->createElement('Tiebreak', $Tiebreak2);
                $XmlAthlete->appendChild($TmpNode);
            }
        }
    }
    return $XmlDoc;
}
 /**
  * Adds XML Stylesheet to the document
  *
  * @param ClassMetadata $metadata
  * @param \DOMDocument $document
  */
 private function addStylesheets(ClassMetadata $metadata, \DOMDocument $document)
 {
     foreach ($metadata->xmlStylesheets as $stylesheet) {
         $dataString = '';
         foreach ($stylesheet as $key => $data) {
             if ($dataString != '') {
                 $dataString .= ' ';
             }
             $dataString .= $key . '=' . '"' . $data . '"';
         }
         $xslt = $document->createProcessingInstruction('xml-stylesheet', $dataString);
         $document->appendChild($xslt);
     }
 }