function main() { $x = new XMLWriter(); $x->openMemory(); $x->setIndent(true); $x->startDocument('1.0'); $x->startElementNS(null, 'startNullPrefix', null); $x->startElementNS('', 'startEmptyPrefix', null); $x->writeElementNS(null, 'writeNullPrefix', null); $x->writeElementNS('', 'writeEmptyPrefix', null); $x->endElement(); $x->endElement(); $x->endDocument(); var_dump($x->outputMemory(true)); }
/** * Start Generating EDMX file. * * @return EDMX xml object. */ public function generateEDMX() { $this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_ELEMENT, ODataConnectorForMySQLConstants::EDMX_NAMESPACE_1_0); $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::EDMX_VERSION, ODataConnectorForMySQLConstants::EDMX_VERSION_VALUE); $this->xmlWriter->endAttribute(); $this->xmlWriter->startElementNS(ODataConnectorForMySQLConstants::EDMX_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::EDMX_DATASERVICES_ELEMENT, null); $this->xmlWriter->startElement(ODataConnectorForMySQLConstants::SCHEMA); $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::NAMESPACE1, $this->schema->namespace); $this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_NAMESPACE); $this->xmlWriter->writeAttributeNS(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE_PREFIX, null, ODataConnectorForMySQLConstants::ODATA_METADATA_NAMESPACE); $this->xmlWriter->writeAttribute(ODataConnectorForMySQLConstants::XMLNS_NAMESPACE_PREFIX, ODataConnectorForMySQLConstants::CSDL_VERSION_1_0); $this->xmlWriter->endAttribute(); try { $this->writeEntityType(); $this->writeAssociations(); $this->writeEntityContainer(); $this->writeEntityInfo(); $this->writeMappingDetails(); } catch (Exception $e) { ODataConnectorForMySQLException::createInternalServerError(); } $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); $this->xmlWriter->endElement(); return $this->xmlWriter->outputMemory(true); }
/** * Вывод в XMLWriter * @codegen true * @param XMLWriter $xw * @param string $xmlname Имя корневого узла * @param string $xmlns Пространство имен * @param int $mode */ public function toXmlWriter(\XMLWriter &$xw, $xmlname = self::ROOT, $xmlns = self::NS, $mode = \Adaptor_XML::ELEMENT) { if ($mode & \Adaptor_XML::STARTELEMENT) { $xw->startElementNS(NULL, $xmlname, $xmlns); } $xw->text($this->_text()); if ($mode & \Adaptor_XML::ENDELEMENT) { $xw->endElement(); } }
public function generateBody() { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->startDocument("1.0", "UTF-8"); $xmlWriter->startElementNS(NULL, "Message", Constants::MNS_XML_NAMESPACE); $this->writeMessagePropertiesForSendXML($xmlWriter); $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(); }
public function generateBody() { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->startDocument("1.0", "UTF-8"); $xmlWriter->startElementNS(NULL, "Topic", Constants::MNS_XML_NAMESPACE); $this->attributes->writeXML($xmlWriter); $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(); }
public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag) { $xml = $this->value->asXML(); // Not all combinations of PHP/libxml support stripping // the XML declaration. So, we do it ourselves here. if (strlen($xml) >= 6 && !strncmp($xml, '<?xml', 5) && strpos(" \t\r\n", $xml[5]) !== false) { $xml = (string) substr($xml, strpos($xml, '?>') + 2); } $writer->startElementNS('ex', 'dom', 'http://ws.apache.org/xmlrpc/namespaces/extensions'); $writer->writeRaw($xml); $writer->fullEndElement(); }
/** * Serialize a PlayReadyLicenseResponseTemplate object into a PlayReadyLicenseResponseTemplate XML. * * @param PlayReadyLicenseResponseTemplate $template * * @return string The PlayReadyLicenseResponseTemplate XML */ public static function serialize($template) { self::ValidateLicenseResponseTemplate($template); $writer = new \XMLWriter(); $writer->openMemory(); $writer->startElementNS(null, 'PlayReadyLicenseResponseTemplate', Resources::PRL_XML_NAMESPACE); $writer->writeAttributeNS('xmlns', 'i', null, Resources::XSI_XML_NAMESPACE); self::serializeLicenseTemplates($writer, $template->getLicenseTemplates()); $writer->writeElement('ResponseCustomData', $template->getResponseCustomData()); $writer->endElement(); return $writer->outputMemory(); }
public function generateBody() { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->startDocument("1.0", "UTF-8"); $xmlWriter->startElementNS(NULL, "Messages", Constants::MNS_XML_NAMESPACE); foreach ($this->sendMessageRequestItems as $item) { $item->writeXML($xmlWriter, $this->base64); } $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(); }
public function generateBody() { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->startDocument("1.0", "UTF-8"); $xmlWriter->startElementNS(NULL, Constants::RECEIPT_HANDLES, Constants::MNS_XML_NAMESPACE); foreach ($this->receiptHandles as $receiptHandle) { $xmlWriter->writeElement(Constants::RECEIPT_HANDLE, $receiptHandle); } $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(); }
/** * Write a property * * @param ODataProperty &$odataProperty Property to be written * @param boolean $isTopLevel is link top level or not. * * @return nothing */ protected function beginWriteProperty(ODataProperty &$odataProperty, $isTopLevel) { $this->xmlWriter->startElementNS(ODataConstants::ODATA_NAMESPACE_PREFIX, $odataProperty->name, null); if ($odataProperty->typeName != null) { $this->xmlWriter->startAttributeNs(ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, ODataConstants::ATOM_TYPE_ATTRIBUTE_NAME, null); $this->xmlWriter->text($odataProperty->typeName); } if ($isTopLevel) { $this->xmlWriter->startAttribute(ODataConstants::XMLNS_NAMESPACE_PREFIX); $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE); $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_NAMESPACE_PREFIX, null); $this->xmlWriter->text(ODataConstants::ODATA_NAMESPACE); $this->xmlWriter->startAttributeNs(ODataConstants::XMLNS_NAMESPACE_PREFIX, ODataConstants::ODATA_METADATA_NAMESPACE_PREFIX, null); $this->xmlWriter->text(ODataConstants::ODATA_METADATA_NAMESPACE); } if ($odataProperty->typeName != null || $isTopLevel) { $this->xmlWriter->endAttribute(); } }
<?php /* $Id$ */ $xw = new XMLWriter(); $xw->openMemory(); $xw->setIndent(TRUE); $xw->setIndentString(' '); $xw->startDocument('1.0', "UTF-8"); $xw->startElement('root'); $xw->startElementNS('ns1', 'child1', 'urn:ns1'); $xw->writeAttributeNS('ns1', 'att1', 'urn:ns1', '<>"\'&'); $xw->writeElement('chars', "special characters: <>\"'&"); $xw->endElement(); $xw->endDocument(); // Force to write and empty the buffer $output = $xw->flush(true); print $output;
/** * Writes this SourceDescription to an XML writer. * * @param \XMLWriter $writer The XML writer. * @param bool $includeNamespaces Whether to write out the namespaces in the element. */ public function toXml(\XMLWriter $writer, $includeNamespaces = true) { $writer->startElementNS('gx', 'sourceDescription', null); if ($includeNamespaces) { $writer->writeAttributeNs('xmlns', 'gx', null, 'http://gedcomx.org/v1/'); } $this->writeXmlContents($writer); $writer->endElement(); }
/** * Writes this ChildAndParentsRelationship to an XML writer. * * @param \XMLWriter $writer The XML writer. * @param bool $includeNamespaces Whether to write out the namespaces in the element. */ public function toXml(\XMLWriter $writer, $includeNamespaces = true) { $writer->startElementNS('fs', 'childAndParentsRelationship', null); if ($includeNamespaces) { $writer->writeAttributeNs('xmlns', 'gx', null, 'http://gedcomx.org/v1/'); $writer->writeAttributeNs('xmlns', 'fs', null, 'http://familysearch.org/v1/'); } $this->writeXmlContents($writer); $writer->endElement(); }
PMF_String::init($LANGCODE); $faq = new PMF_Faq($faqConfig); $rssData = $faq->getAllOpenQuestions(false); $num = count($rssData); $rss = new XMLWriter(); $rss->openMemory(); $rss->setIndent(true); $rss->startDocument('1.0', 'utf-8'); $rss->startElement('rss'); $rss->writeAttribute('version', '2.0'); $rss->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); $rss->startElement('channel'); $rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgOpenQuestions']); $rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription'))); $rss->writeElement('link', $faqConfig->get('main.referenceURL')); $rss->startElementNS('atom', 'link', 'http://www.w3.org/2005/Atom'); $rss->writeAttribute('rel', 'self'); $rss->writeAttribute('type', 'application/rss+xml'); $rss->writeAttribute('href', $faqConfig->get('main.referenceURL') . 'feed/openquestions/rss.php'); $rss->endElement(); if ($num > 0) { $counter = 0; foreach ($rssData as $item) { if ($counter < PMF_RSS_OPENQUESTIONS_MAX) { $counter++; $rss->startElement('item'); $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item['question'], ENT_COMPAT, 'UTF-8'), 8) . " (" . $item['username'] . ")"); $rss->startElement('description'); $rss->writeCdata($item['question']); $rss->endElement(); $rss->writeElement('link', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER['SCRIPT_NAME']) . "?action=open#openq_" . $item['id']);
public function wsdl() { /************************ ** SETUP XML ************************/ $uri = sprintf("http://%s/api/soap", $_SERVER['HTTP_HOST']); $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(TRUE); $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS('wsdl', 'definitions', 'http://schemas.xmlsoap.org/wsdl/'); $xml->writeAttributeNS('xmlns', 'soap', NULL, "http://schemas.xmlsoap.org/wsdl/soap/"); #$xml->writeAttributeNS('xmlns', 'schema', NULL, $uri); $xml->writeAttributeNS('xmlns', 'xsd', NULL, "http://www.w3.org/2001/XMLSchema"); $xml->writeAttributeNS('xmlns', 'xsi', NULL, "http://www.w3.org/2001/XMLSchema-instance"); $xml->writeAttributeNS('xmlns', 'tns', NULL, "{$uri}"); $xml->writeAttribute('targetNamespace', "{$uri}"); #$xml->writeAttribute('name', $this->name); $xml->startElementNS('wsdl', 'documentation', NULL); $xml->text(sprintf('Auto Generated WSDL For %s Class By Quick_WSDL', $this->name)); $xml->endElement(); /************************ ** TYPES ************************/ $xml->startElementNS('wsdl', 'types', NULL); $xml->startElementNS('xsd', 'schema', NULL); $xml->writeAttribute('targetNamespace', "{$uri}"); foreach (array_keys($this->ctes) as $n) { $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', $n); $xml->startElementNS('xsd', 'complexType', NULL); $xml->startElementNS('xsd', 'sequence', NULL); foreach ($this->ctes[$n] as $p) { $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', $p->name); $xml->writeAttribute('type', $p->type); if ($p->mand) { $xml->writeAttribute('minOccurs', '1'); $xml->writeAttribute('maxOccurs', '1'); } else { $xml->writeAttribute('minOccurs', '0'); $xml->writeAttribute('maxOccurs', '1'); } $xml->endElement(); //element } $xml->endElement(); //sequence $xml->endElement(); //complexType $xml->endElement(); //element } foreach ($this->oper as $o) { if (!isset($this->ctes[$o])) { $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', sprintf('%s', $o)); $xml->startElementNS('xsd', 'complexType', NULL); $xml->startElementNS('xsd', 'sequence', NULL); foreach ($this->msgs[$o] as $p) { $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', $p->name); $xml->writeAttribute('type', $p->type); if ($p->mand) { $xml->writeAttribute('minOccurs', '1'); $xml->writeAttribute('maxOccurs', '1'); } else { $xml->writeAttribute('minOccurs', '0'); $xml->writeAttribute('maxOccurs', '1'); } $xml->endElement(); } $xml->endElement(); //sequence $xml->endElement(); //complexType $xml->endElement(); //element } if (!isset($this->ctes[sprintf('%sResponse', $o)])) { $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', sprintf('%sResponse', $o)); $xml->startElementNS('xsd', 'complexType', NULL); $xml->startElementNS('xsd', 'sequence', NULL); $xml->startElementNS('xsd', 'element', NULL); $xml->writeAttribute('name', $this->rets[$o]->name); $xml->writeAttribute('type', $this->rets[$o]->type); if ($p->mand) { $xml->writeAttribute('minOccurs', '1'); $xml->writeAttribute('maxOccurs', '1'); } else { $xml->writeAttribute('minOccurs', '0'); $xml->writeAttribute('maxOccurs', '1'); } $xml->endElement(); $xml->endElement(); //sequence $xml->endElement(); //complexType $xml->endElement(); //message } } $xml->endElement(); //schema $xml->endElement(); //types /************************ ** MESSAGES ************************/ foreach ($this->oper as $o) { $xml->startElementNS('wsdl', 'message', NULL); $xml->writeAttribute('name', sprintf('%sIn', $o)); $xml->startElementNS('wsdl', 'part', NULL); $xml->writeAttribute('name', 'parameters'); $xml->writeAttribute('element', sprintf('tns:%s', $o)); $xml->endElement(); $xml->endElement(); //message $xml->startElementNS('wsdl', 'message', NULL); $xml->writeAttribute('name', sprintf('%sOut', $o)); $xml->startElementNS('wsdl', 'part', NULL); $xml->writeAttribute('name', 'parameters'); $xml->writeAttribute('element', sprintf('tns:%sResponse', $o)); $xml->endElement(); $xml->endElement(); //message } /************************ ** PORTTYPE ************************/ $xml->startElementNS('wsdl', 'portType', NULL); $xml->writeAttribute('name', sprintf('Class_%s', $this->name)); foreach ($this->oper as $o) { $xml->startElementNS('wsdl', 'operation', NULL); $xml->writeAttribute('name', $o); $xml->startElementNS('wsdl', 'documentation', NULL); $xml->text('TODO: Add Documentation'); $xml->endElement(); $xml->startElementNS('wsdl', 'input', NULL); $xml->writeAttribute('message', sprintf('tns:%sIn', $o)); $xml->endElement(); $xml->startElementNS('wsdl', 'output', NULL); $xml->writeAttribute('message', sprintf('tns:%sOut', $o)); $xml->endElement(); $xml->endElement(); //operation } $xml->endElement(); //portType /************************ ** BINDING ************************/ $xml->startElementNS('wsdl', 'binding', NULL); $xml->writeAttribute('name', sprintf('Bind_%s', $this->name)); $xml->writeAttribute('type', sprintf('tns:Class_%s', $this->name)); $xml->startElementNS('soap', 'binding', NULL); $xml->writeAttribute('style', 'document'); $xml->writeAttribute('transport', 'http://schemas.xmlsoap.org/soap/http'); //$xml->writeAttribute('namespace', "$uri"); $xml->endElement(); foreach ($this->oper as $o) { $xml->startElementNS('wsdl', 'operation', NULL); $xml->writeAttribute('name', $o); $xml->startElementNS('soap', 'operation', NULL); $xml->writeAttribute('soapAction', "{$uri}/{$o}"); $xml->endElement(); $xml->startElementNS('wsdl', 'input', NULL); $xml->startElementNS('soap', 'body', NULL); $xml->writeAttribute('use', 'literal'); //$xml->writeAttribute('namespace',"$uri/$o"); $xml->endElement(); $xml->endElement(); $xml->startElementNS('wsdl', 'output', NULL); $xml->startElementNS('soap', 'body', NULL); $xml->writeAttribute('use', 'literal'); $xml->endElement(); $xml->endElement(); $xml->endElement(); //wsdl:operation } $xml->endElement(); //wsdl:binding /************************ ** SERVICE ************************/ $xml->startElementNS('wsdl', 'service', NULL); $xml->writeAttribute('name', $this->name); $xml->startElementNS('wsdl', 'port', NULL); $xml->writeAttribute('name', sprintf('%sEndpoint', $this->name)); $xml->writeAttribute('binding', sprintf('tns:Bind_%s', $this->name)); $xml->startElementNS('soap', 'address', NULL); $xml->writeAttribute('location', "{$uri}/index.php"); $xml->endElement(); $xml->endElement(); //port $xml->endElement(); //service /************************ ** CLEANUP ************************/ $xml->endElement(); //definitions $xml->endDocument(); header('Content-type: text/xml; charset=UTF-8'); echo $xml->outputMemory(TRUE); }
/** * Method to make an output of document records in simple XML format * * @return string */ public function XMLresult() { global $sysconf; $mods_version = '3.3'; $_buffer = ''; // loop data $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->startElement('modsCollection'); $xml->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $xml->writeAttribute('xmlns', 'http://www.loc.gov/mods/v3'); $xml->writeAttribute('xmlns:slims', 'http://slims.web.id'); $xml->writeAttribute('xsi:schemaLocation', 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd'); // $_buffer = '<modsCollection xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" xmlns:slims="http://slims.web.id" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">'."\n"; $xml->startElementNS('slims', 'resultInfo', null); $xml->startElementNS('slims', 'modsResultNum', null); $this->xmlWrite($xml, $this->num_rows); $xml->endElement(); $xml->startElementNS('slims', 'modsResultPage', null); $this->xmlWrite($xml, $this->current_page); $xml->endElement(); $xml->startElementNS('slims', 'modsResultShowed', null); $this->xmlWrite($xml, $this->num2show); $xml->endElement(); $xml->endElement(); while ($_biblio_d = $this->resultset->fetch_assoc()) { $xml->startElement('mods'); $xml->writeAttribute('version', $mods_version); $xml->writeAttribute('ID', $_biblio_d['biblio_id']); // parse title $_title_sub = ''; if (stripos($_biblio_d['title'], ':') !== false) { $_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], ':') + 1)); $_title_sub = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], ':') + 1)); } else { $_title_main = trim($_biblio_d['title']); } // parse title $_title_main = trim($_biblio_d['title']); $_title_sub = ''; $_title_statement_resp = ''; if (stripos($_biblio_d['title'], '/') !== false) { $_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], '/') + 1)); $_title_statement_resp = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], '/') + 1)); } if (stripos($_biblio_d['title'], ':') !== false) { $_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], ':') + 1)); $_title_sub = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], ':') + 1)); } $xml->startElement('titleInfo'); $xml->startElement('title'); $this->xmlWrite($xml, $_title_main); $xml->endElement(); if ($_title_sub) { // $_xml_output .= '<subTitle><![CDATA['.$_title_sub.']]></subTitle>'."\n"; $xml->startElement('subTitle'); $this->xmlWrite($xml, $_title_sub); $xml->endElement(); } // $_xml_output .= '</titleInfo>'."\n"; $xml->endElement(); // get the authors data $_biblio_authors_q = $this->obj_db->query('SELECT a.*,ba.level FROM mst_author AS a' . ' LEFT JOIN biblio_author AS ba ON a.author_id=ba.author_id WHERE ba.biblio_id=' . $_biblio_d['biblio_id']); while ($_auth_d = $_biblio_authors_q->fetch_assoc()) { // some rules to set name type in mods standard if ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Personal Name') { $sysconf['authority_type'][$_auth_d['authority_type']] = 'personal'; } elseif ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Organizational Body') { $sysconf['authority_type'][$_auth_d['authority_type']] = 'corporate'; } elseif ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Conference') { $sysconf['authority_type'][$_auth_d['authority_type']] = 'conference'; } else { $sysconf['authority_type'][$_auth_d['authority_type']] = 'personal'; } $xml->startElement('name'); $xml->writeAttribute('type', $sysconf['authority_type'][$_auth_d['authority_type']]); $xml->writeAttribute('authority', $_auth_d['auth_list']); $xml->startElement('namePart'); $this->xmlWrite($xml, $_auth_d['author_name']); $xml->endElement(); $xml->startElement('role'); $xml->startElement('roleTerm'); $xml->writeAttribute('type', 'text'); $this->xmlWrite($xml, $sysconf['authority_level'][$_auth_d['level']]); $xml->endElement(); $xml->endElement(); $xml->endElement(); } $_biblio_authors_q->free_result(); $xml->startElement('typeOfResource'); $xml->writeAttribute('collection', 'yes'); $this->xmlWrite($xml, 'mixed material'); $xml->endElement(); $xml->startElement('identifier'); $xml->writeAttribute('type', 'isbn'); $this->xmlWrite($xml, str_replace(array('-', ' '), '', $_biblio_d['isbn_issn'])); $xml->endElement(); // imprint/publication data $xml->startElement('originInfo'); $xml->startElement('place'); $xml->startElement('placeTerm'); $xml->writeAttribute('type', 'text'); $this->xmlWrite($xml, $_biblio_d['publish_place']); $xml->endElement(); $xml->startElement('publisher'); $this->xmlWrite($xml, $_biblio_d['publisher']); $xml->endElement(); $xml->startElement('dateIssued'); $this->xmlWrite($xml, $_biblio_d['publish_year']); $xml->endElement(); $xml->endElement(); $xml->endElement(); // images $_image = ''; if (!empty($_biblio_d['image'])) { $_image = urlencode($_biblio_d['image']); $xml->startElementNS('slims', 'image', null); $this->xmlWrite($xml, $_image); $xml->endElement(); } $xml->endElement(); // MODS } // free resultset memory $this->resultset->free_result(); $xml->endElement(); $_buffer .= $xml->flush(); // $_buffer .= '</modsCollection>'; return $_buffer; }
function generateWSDL($array) { if (is_array($array)) { $a = new ArrayObject(); // Création d'un tableau d'objet foreach ($array as $r) { $bdd = new PDO('mysql:host=localhost;dbname=new_schema;charset=utf8', 'root', 'admin', array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $result = $bdd->query("SELECT DISTINCT function_name,variable_name,variable_input,type_namewsdl,server_name " . "FROM access,client,function,variable,type,server " . "WHERE client.client_id=access.client_id " . "AND function.function_id=access.function_id " . "AND function.server_id=server.server_id " . "AND function.function_id={$r} " . "AND function.function_id=variable.function_id " . "AND variable.type_id=type.type_id "); while ($row = $result->fetch()) { //On définit une nouvelle instance de la classe resultat $ligne = new resultat($row); // On fait un appel à la methode "population" qui stocke la ligne de resultat de la requête $ligne->population($row); // On stocke l'objet dans un tableau d'objet. $a->append($ligne); } $bdd = null; } } /* * definition des variables utiles pour écrire le WSDL */ $tempRequest = ""; // variable utile pour la création du fichier WSDL $tempResponse = ""; // variable utile pour la création du fichier WSDL $tempServer = ""; // On va stocker plus tard le nom de serveur dans cette variable $tempFunction = ""; $parcours = 0; /* * on commence l'écriture du WSDL au format XML */ header('Content-type: text/xml; charset=UTF-8'); $oXMLWriter = new XMLWriter(); $oXMLWriter->openMemory(); $oXMLWriter->startDocument('1.0', 'UTF-8'); $oXMLWriter->setIndent(true); foreach ($a as $q) { if (strcmp($q->server_name, $tempServer) != 0) { /* * écriture de la balise d'ouverture "definition" */ $oXMLWriter->startElementNS('wsdl', 'definition', 'http://schemas.xmlsoap.org/wsdl/'); $oXMLWriter->writeAttribute('name', $q->server_name); $oXMLWriter->writeAttributeNs('xmlns', 'soap', NULL, 'http://schemas.xmlsoap.org/wsdl/soap/'); $oXMLWriter->writeAttributeNs('xmlns', 'xsd', NULL, 'http://www.w3.org/2001/XMLSchema'); $oXMLWriter->writeAttributeNs('xmlns', 'soapenc', NULL, 'http://schemas.xmlsoap.org/soap/encoding/'); $oXMLWriter->writeAttribute('xmlns', 'http://schemas.xmlsoap.org/wsdl/'); //on utilise une boucle foreach pour parcourir l'ensemble des résultats foreach ($a as $r) { //ecriture de la premiere balise request // Dans la boucle if, si lors d'une nouvelle itération la fonction est toujours la meme on ne rentre pas dedans. if ($r->variable_input == 1 && strcmp($r->function_name, $tempRequest) != 0) { $oXMLWriter->startElementNS('wsdl', 'message', NULL); $oXMLWriter->writeAttribute('name', 'get' . $r->function_name . 'Request'); foreach ($a as $s) { if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 1) { $oXMLWriter->startElementNS('wsdl', 'part', NULL); $oXMLWriter->writeAttribute('name', $s->variable_name); $oXMLWriter->writeAttribute('type', $s->type_namewsdl); $oXMLWriter->endElement(); } } $oXMLWriter->endElement(); } $tempRequest = $r->function_name; if ($r->variable_input == 0) { //&& (strcmp($r->function_name,$tempResponse))!=0){ $oXMLWriter->startElementNS('wsdl', 'message', NULL); $oXMLWriter->writeAttribute('name', 'get' . $r->function_name . 'Response'); foreach ($a as $s) { if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 0) { $oXMLWriter->startElementNS('wsdl', 'part', NULL); $oXMLWriter->writeAttribute('name', $s->variable_name); $oXMLWriter->writeAttribute('type', $s->type_namewsdl); $oXMLWriter->endElement(); } } $oXMLWriter->endElement(); } $tempResponse = $r->function_name; } foreach ($a as $r) { if (strcmp($r->function_name, $tempFunction) != 0) { $oXMLWriter->startElementNS('wsdl', 'portType', NULL); $oXMLWriter->writeAttribute('name', $r->function_name . 'PortType'); $oXMLWriter->startElementNS('wsdl', 'operation', NULL); $oXMLWriter->writeAttribute('name', 'get' . $r->function_name); foreach ($a as $s) { if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 1 && $parcours == 0) { $oXMLWriter->startElementNS('wsdl', 'input', NULL); $oXMLWriter->writeAttribute('message', 'tns:get' . $r->function_name . 'Request'); $oXMLWriter->endElement(); $parcours = 1; } if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 0) { $oXMLWriter->startElementNS('wsdl', 'output', NULL); $oXMLWriter->writeAttribute('message', 'tns:get' . $r->function_name . 'Response'); $oXMLWriter->endElement(); } } $oXMLWriter->endElement(); $oXMLWriter->endElement(); } $tempFunction = $r->function_name; $parcours = 0; } $tempFunction = ""; foreach ($a as $r) { if (strcmp($r->function_name, $tempFunction) != 0) { $oXMLWriter->startElementNS('wsdl', 'binding', NULL); $oXMLWriter->writeAttribute('name', $r->function_name . 'binding'); $oXMLWriter->writeAttribute('type', 'tns:' . $r->function_name . 'PortType'); $oXMLWriter->startElementNS('soap', 'binding', NULL); $oXMLWriter->writeAttribute('style', 'rpc'); $oXMLWriter->writeAttribute('transport', 'http://schemas.xmlsoap.org/soap/http'); $oXMLWriter->endElement(); $oXMLWriter->startElementNS('wsdl', 'operation', NULL); $oXMLWriter->writeAttribute('name', 'get' . $r->function_name); $oXMLWriter->startElementNS('soap', 'operation', NULL); $oXMLWriter->writeAttribute('soapAction', 'urn:xmethods-delayed-quotes#get' . $r->function_name); $oXMLWriter->endElement(); foreach ($a as $s) { if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 1 && $parcours == 0) { $oXMLWriter->startElementNS('wsdl', 'input', NULL); $oXMLWriter->startElementNS('soap', 'body', NULL); $oXMLWriter->writeAttribute('use', 'encoded'); $oXMLWriter->writeAttribute('namespace', 'urn:xmethods-delayed-quotes'); $oXMLWriter->writeAttribute('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); $oXMLWriter->endElement(); $oXMLWriter->endElement(); $parcours = 1; } if (strcmp($s->function_name, $r->function_name) == 0 && $s->variable_input == 0) { $oXMLWriter->startElementNS('wsdl', 'output', NULL); $oXMLWriter->startElementNS('soap', 'body', NULL); $oXMLWriter->writeAttribute('use', 'encoded'); $oXMLWriter->writeAttribute('namespace', 'urn:xmethods-delayed-quotes'); $oXMLWriter->writeAttribute('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); $oXMLWriter->endElement(); $oXMLWriter->endElement(); } } $oXMLWriter->endElement(); $oXMLWriter->endElement(); } $tempFunction = $r->function_name; $parcours = 0; } $tempFunction = ""; foreach ($a as $r) { if (strcmp($r->function_name, $tempFunction) != 0) { $oXMLWriter->startElementNS('wsdl', 'service', NULL); $oXMLWriter->writeAttribute('name', $r->function_name . 'Service'); $oXMLWriter->startElementNS('wsdl', 'port', NULL); $oXMLWriter->writeAttribute('name', $r->function_name . 'Port'); $oXMLWriter->writeAttribute('binding', $r->function_name . 'binding'); $oXMLWriter->startElementNS('soap', 'adress', NULL); $oXMLWriter->writeAttribute('location', 'http://localhost/' . $q->server_name . '/wsdl_server.php'); $oXMLWriter->endElement(); $oXMLWriter->endElement(); $oXMLWriter->endElement(); } $tempFunction = $r->function_name; } $oXMLWriter->endElement(); } $tempServer = $q->server_name; } $oXMLWriter->endDocument(); $wsdl = ''; $wsdl = $oXMLWriter->outputMemory(TRUE); //echo $oXMLWriter->outputMemory(TRUE); return $wsdl; }
$sql .= "INSERT INTO `links` (id,type,source,destination,dt_start,dt_end,xmlview) VALUES"; foreach ($persons as $p) { $id = gen_uuid(); $sql .= "("; $sql .= "\"" . $id . "\","; $sql .= "\"pupil\","; $sql .= "\"" . $p[12] . "\","; $sql .= "\"d5WqRO3g\","; $sql .= "\"" . $p[0] . "\","; $sql .= "\"" . $p[1] . "\","; $xw = new \XMLWriter(); $xw->openMemory(); $xw->setIndent(false); //$xw->setIndentString(' '); $xw->startDocument('1.0', 'UTF-8'); $xw->startElementNS(null, "Link", "urn:com:summerfields:Archive:Links"); $xw->writeElement("ID", $id); $xw->writeElement("type", "pupil"); $xw->writeElement("source", $p[12]); $xw->writeElement("destination", "d5WqRO3g"); $xw->writeElement("dtStart", $p[0]); $xw->writeElement("dtEnd", $p[1]); $xw->endElement(); $xw->endDocument(); $sql .= "\"" . mysql_escape_string($xw->flush()) . "\"),\n"; } $sql = substr($sql, 0, -2) . ";"; file_put_contents("../sql/pupils.sql", $sql); function gen_uuid($len = 8) { $hex = md5("summerfields_1864" . uniqid("", true));
<?php $xw = xmlwriter_open_memory(); xmlwriter_set_indent($xw, true); xmlwriter_start_document($xw); xmlwriter_start_element_ns($xw, 'test', 'test', 'urn:x-test:'); xmlwriter_write_element_ns($xw, 'test', 'foo', null, ''); xmlwriter_write_element_ns($xw, null, 'bar', 'urn:x-test:', ''); xmlwriter_write_element_ns($xw, null, 'bar', '', ''); xmlwriter_end_element($xw); xmlwriter_end_document($xw); print xmlwriter_flush($xw, true); print "\n"; $xw = new XMLWriter(); $xw->openMemory(); $xw->setIndent(true); $xw->startDocument(); $xw->startElementNS('test', 'test', 'urn:x-test:'); $xw->writeElementNS('test', 'foo', null, ''); $xw->writeElementNS(null, 'bar', 'urn:x-test:', ''); $xw->writeElementNS(null, 'bar', '', ''); $xw->endElement(); $xw->endDocument(); print $xw->flush(true);
/** * Return the generated Autodiscover XML request body. * * @return string */ public function getAutodiscoverRequest() { if (!empty($this->requestxml)) { return $this->requestxml; } $xml = new \XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS(null, 'Autodiscover', 'http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006'); $xml->startElement('Request'); $xml->writeElement('EMailAddress', $this->email); $xml->writeElement('AcceptableResponseSchema', 'http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a'); $xml->endElement(); $xml->endElement(); $this->requestxml = $xml->outputMemory(); return $this->requestxml; }
/** * Construct the catalog entry * * @param XmlWriter $xml XML stream to write to * @param array $data data-blob of i18n and config variables * @param array $dataset array of the dataset identifiers */ function writeCatalog(XMLWriter $xml, array $data, array $dataset) { $xml->startElementNS('rdf', 'Description', null); $xml->writeAttributeNS('rdf', 'about', null, $data['config']['uri'] . '#catalog'); $xml->startElementNS('rdf', 'type', null); $xml->writeAttributeNS('rdf', 'resource', null, 'http://www.w3.org/ns/dcat#Catalog'); $xml->endElement(); $xml->startElementNS('dcterms', 'license', null); $xml->writeAttributeNS('rdf', 'resource', null, $data['config']['catalog-license']); $xml->endElement(); $xml->startElementNS('dcat', 'themeTaxonomy', null); $xml->writeAttributeNS('rdf', 'resource', null, 'http://eurovoc.europa.eu/'); $xml->endElement(); $xml->writeElementNS('foaf', 'homepage', null, $data['config']['catalog-homepage']); $xml->startElementNS('dcterms', 'modified', null); $xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date'); $xml->text(date('Y-m-d')); $xml->endElement(); $xml->startElementNS('dcterms', 'issued', null); $xml->writeAttributeNS('rdf', 'datatype', null, 'http://www.w3.org/2001/XMLSchema#date'); $xml->text($data['config']['catalog-issued']); $xml->endElement(); $xml->startElementNS('dcterms', 'publisher', null); $xml->writeAttributeNS('rdf', 'nodeID', null, $data['ids']['publisher']); $xml->endElement(); // add language, title and description in each language writeCatalogI18n($xml, $data); // add datasets foreach ($dataset as $key => $value) { $xml->startElementNS('dcat', 'dataset', null); $xml->writeAttributeNS('rdf', 'resource', null, $value); $xml->endElement(); } $xml->endElement(); }
/** * Writes this HealthConfig to an XML writer. * * @param \XMLWriter $writer The XML writer. * @param bool $includeNamespaces Whether to write out the namespaces in the element. */ public function toXml($writer, $includeNamespaces = true) { $writer->startElementNS('fs', 'healthConfig', null); if ($includeNamespaces) { $writer->writeAttributeNs('xmlns', 'fs', null, 'http://familysearch.org/v1/'); } $this->writeXmlContents($writer); $writer->endElement(); }
/** * Lists all events in the time range, optionally restricting results to * only events with alarms. * * @param Horde_Date $startInterval Start of range date object. * @param Horde_Date $endInterval End of range data object. * @param boolean $showRecurrence Return every instance of a recurring * event? If false, will only return * recurring events once inside the * $startDate - $endDate range. * @param boolean $hasAlarm Only return events with alarms? * @param boolean $json Store the results of the events' * toJson() method? * @param boolean $coverDates Whether to add the events to all days * that they cover. * $param boolean $hideExceptions Hide events that represent exceptions * to a recurring event. * * @return array Events in the given time range. * @throws Kronolith_Exception */ protected function _listCalDAVEvents($startDate = null, $endDate = null, $showRecurrence = false, $hasAlarm = false, $json = false, $coverDates = true, $hideExceptions = false) { if (!is_null($startDate)) { $startDate = clone $startDate; $startDate->hour = $startDate->min = $startDate->sec = 0; } if (!is_null($endDate)) { $endDate = clone $endDate; $endDate->hour = 23; $endDate->min = $endDate->sec = 59; } /* Build report query. */ $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->startDocument(); $xml->startElementNS('C', 'calendar-query', 'urn:ietf:params:xml:ns:caldav'); $xml->writeAttribute('xmlns:D', 'DAV:'); $xml->startElement('D:prop'); $xml->writeElement('D:getetag'); $xml->startElement('C:calendar-data'); $xml->startElement('C:comp'); $xml->writeAttribute('name', 'VCALENDAR'); $xml->startElement('C:comp'); $xml->writeAttribute('name', 'VEVENT'); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->startElement('C:filter'); $xml->startElement('C:comp-filter'); $xml->writeAttribute('name', 'VCALENDAR'); $xml->startElement('C:comp-filter'); $xml->writeAttribute('name', 'VEVENT'); if (!is_null($startDate) || !is_null($endDate)) { $xml->startElement('C:time-range'); if (!is_null($startDate)) { $xml->writeAttribute('start', $startDate->toiCalendar()); } if (!is_null($endDate)) { $xml->writeAttribute('end', $endDate->toiCalendar()); } } $xml->endDocument(); $url = $this->_getUrl(); list($response, $events) = $this->_request('REPORT', $url, $xml, array('Depth' => 1)); if (!$events->children('DAV:')->response) { return array(); } if (isset($response['headers']['content-location'])) { $path = $response['headers']['content-location']; } else { $parsedUrl = parse_url($url); $path = $parsedUrl['path']; } $results = array(); foreach ($events->children('DAV:')->response as $response) { if (!$response->children('DAV:')->propstat) { continue; } $ical = new Horde_Icalendar(); try { $ical->parsevCalendar($response->children('DAV:')->propstat->prop->children('urn:ietf:params:xml:ns:caldav')->{'calendar-data'}); } catch (Horde_Icalendar_Exception $e) { throw new Kronolith_Exception($e); } $this->_processComponents($results, $this->_convertEvents($ical), $startDate, $endDate, $showRecurrence, $json, $coverDates, $hideExceptions, trim(str_replace($path, '', $response->href), '/')); } return $results; }
/** * Get object properties as array * * @param object $object Source object * @param \XMLWriter $xmlWriter Xml writer to use * * @return array */ private static function _serializeRecursive($object, $xmlWriter) { Validate::notNull($object, 'object'); $reflectionClass = new \ReflectionClass($object); $methodArray = $reflectionClass->getMethods(); $result = array(); foreach ($methodArray as $method) { if (strpos($method->name, 'get') === 0 && $method->isPublic()) { $variableName = substr($method->name, 3); $variableValue = $method->invoke($object); if (!empty($variableValue) || ContentPropertiesSerializer::_isRequired($object, $variableName)) { if (is_a($variableValue, '\\DateTime')) { $variableValue = $variableValue->format(\DateTime::ATOM); } if (gettype($variableValue) == 'array') { $xmlWriter->startElementNS('data', $variableName, Resources::DS_XML_NAMESPACE); foreach ($variableValue as $item) { $xmlWriter->startElementNS('data', Resources::ELEMENT, Resources::DS_XML_NAMESPACE); ContentPropertiesSerializer::_serializeRecursive($item, $xmlWriter); $xmlWriter->endElement(); } $xmlWriter->endElement(); } else { if (gettype($variableValue) == 'object') { $xmlWriter->startElementNS('data', $variableName, Resources::DS_XML_NAMESPACE); ContentPropertiesSerializer::_serializeRecursive($variableValue, $xmlWriter); $xmlWriter->endElement(); } else { $xmlWriter->writeElementNS('data', $variableName, Resources::DS_XML_NAMESPACE, (string) $variableValue); } } } } } return $result; }
/** * Writes an XML representing the generator. * * @param \XMLWriter $xmlWriter The XML writer. * * @return none */ public function writeXml($xmlWriter) { $xmlWriter->startElementNS('atom', Resources::CATEGORY, Resources::ATOM_NAMESPACE); $this->writeOptionalAttribute($xmlWriter, 'uri', $this->uri); $this->writeOptionalAttribute($xmlWriter, 'version', $this->version); $xmlWriter->writeRaw($this->text); $xmlWriter->endElement(); }
<?php $xml = new XMLWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS(null, 'urlset', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $xml->endElement(); $xml->endDocument(); echo $xml->flush(); $xml = new XMLWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS('', 'urlset', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $xml->endElement(); $xml->endDocument(); echo $xml->flush(); $xml = new XMLWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS('foo', 'urlset', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $xml->endElement(); $xml->endDocument(); echo $xml->flush();
/** * Write an element with namespace if used * * @param \XMLWriter $xmlWriter XML writer resource * @param string $prefix Namespace prefix if any * @param string $name Element name * @param string $namespace The uri of the namespace * @param string $value The element content */ protected function writeElement(\XMLWriter $xmlWriter, $prefix, $name, $namespace, $value) { $xmlWriter->startElementNS($prefix, $name, $namespace); if (strpbrk($value, '<>&')) { $xmlWriter->writeCData($value); } else { $xmlWriter->writeRaw($value); } $xmlWriter->endElement(); }
$languages[$lang] = $label->getAttribute('value'); } } } //set dbpedia and wikidata $dbpedia = 'http://dbpedia.org/resource/' . trim($pieces[4]); $wikidata = 'http://www.wikidata.org/entity/' . $entityId; } } $type = 'foaf:Person'; $writer = new XMLWriter(); $writer->openURI('ids/' . trim($row['nomisma_id']) . '.rdf'); //$writer->openURI('php://output'); $writer->setIndent(true); $writer->startDocument('1.0', 'UTF-8'); $writer->startElementNS('rdf', 'RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); $writer->writeAttribute('xmlns:nm', 'http://nomisma.org/id/'); $writer->writeAttribute('xmlns:skos', 'http://www.w3.org/2004/02/skos/core#'); $writer->writeAttribute('xmlns:geo', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); $writer->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema#'); $writer->writeAttribute('xmlns:nmo', 'http://nomisma.org/ontology#'); $writer->writeAttribute('xmlns:org', 'http://www.w3.org/ns/org#'); $writer->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); $writer->writeAttribute('xmlns:un', 'http://www.owl-ontologies.com/Ontology1181490123.owl#'); $writer->writeAttribute('xmlns:foaf', 'http://xmlns.com/foaf/0.1/'); $writer->writeAttribute('xmlns:rdfs', 'http://www.w3.org/2000/01/rdf-schema#'); $writer->writeAttribute('xmlns:rdac', 'http://www.rdaregistry.info/Elements/c/'); $writer->writeAttribute('xmlns:crm', 'http://erlangen-crm.org/current/'); $writer->startElement($type); $writer->writeAttribute('rdf:about', 'http://nomisma.org/id/' . trim($row['nomisma_id'])); $writer->startElement('rdf:type');
/** * Writes this Entry to an XML writer. * * @param \XMLWriter $writer The XML writer. * @param bool $includeNamespaces Whether to write out the namespaces in the element. */ public function toXml($writer, $includeNamespaces = true) { $writer->startElementNS('atom', 'entry', null); if ($includeNamespaces) { $writer->writeAttributeNs('xmlns', 'gx', null, 'http://gedcomx.org/v1/'); $writer->writeAttributeNs('xmlns', 'atom', null, 'http://www.w3.org/2005/Atom'); } $this->writeXmlContents($writer); $writer->endElement(); }
/** * Serialize a TokenRestrictionTemplate object into a TokenRestrictionTemplate XML * @param TokenRestrictionTemplate $tokenRestriction * @return string The TokenRestrictionTemplate XML */ public static function serialize($tokenRestriction) { if (empty($tokenRestriction->getPrimaryVerificationKey()) && ($tokenRestriction->getOpenIdConnectDiscoveryDocument() == null || empty($tokenRestriction->getOpenIdConnectDiscoveryDocument()->getOpenIdDiscoveryUri()))) { throw new \RuntimeException("Both PrimaryVerificationKey and OpenIdConnectDiscoveryDocument are null"); } if (empty($tokenRestriction->getAudience())) { throw new \RuntimeException("TokenRestrictionTemplate Serialize: Audience is required"); } if (empty($tokenRestriction->getIssuer())) { throw new \RuntimeException("TokenRestrictionTemplate Serialize: Issuer is required"); } $writer = new \XMLWriter(); $writer->openMemory(); $writer->startElementNS(null, 'TokenRestrictionTemplate', Resources::TRT_XML_NAMESPACE); $writer->writeAttributeNS('xmlns', 'i', null, Resources::XSI_XML_NAMESPACE); if (!empty($tokenRestriction->getAlternateVerificationKeys())) { TokenRestrictionTemplateSerializer::serializeAlternateVerificationKeys($writer, $tokenRestriction->getAlternateVerificationKeys()); } $writer->writeElement("Audience", $tokenRestriction->getAudience()); $writer->writeElement("Issuer", $tokenRestriction->getIssuer()); if (!empty($tokenRestriction->getPrimaryVerificationKey())) { $writer->startElement('PrimaryVerificationKey'); TokenRestrictionTemplateSerializer::serializeTokenVerificationKey($writer, $tokenRestriction->getPrimaryVerificationKey()); $writer->endElement(); } if (!empty($tokenRestriction->getRequiredClaims())) { TokenRestrictionTemplateSerializer::serializeRequiredClaims($writer, $tokenRestriction->getRequiredClaims()); } if (!empty($tokenRestriction->getTokenType())) { $writer->writeElement('TokenType', $tokenRestriction->getTokenType()); } if (!empty($tokenRestriction->getOpenIdConnectDiscoveryDocument())) { TokenRestrictionTemplateSerializer::serializeOpenIdConnectDiscoveryDocument($writer, $tokenRestriction->getOpenIdConnectDiscoveryDocument()); } $writer->endElement(); return $writer->outputMemory(); }