/** * (non-PHPdoc) * @see lib/Faett/Channel/Serializer/Interfaces/Faett_Channel_Serializer_Interfaces_Serializer#serialize() */ public function serialize() { try { // initialize a new DOM document $doc = new DOMDocument('1.0', 'UTF-8'); // create new namespaced root element $a = $doc->createElementNS($this->_namespace, 'a'); // add the schema to the root element $a->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', 'http://pear.php.net/dtd/rest.allcategories http://pear.php.net/dtd/rest.allcategories.xsd'); // create an element for the channel's name $ch = $doc->createElement('ch'); $ch->nodeValue = Mage::helper('channel')->getChannelName(); // append the element with the channel's name to the root element $a->appendChild($ch); // load the product's attributes $attributes = $this->_category->getSelectOptions(); // iterate over the channel's categories foreach ($attributes as $attribute) { $c = $doc->createElement('c'); $c->setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '/channel/index/c/' . $attribute . '/info.xml'); $c->nodeValue = $attribute; // append the XLink to the root element $a->appendChild($c); } // append the root element to the DOM tree $doc->appendChild($a); // return the XML document return $doc->saveXML(); } catch (Exception $e) { return $e->getMessage(); } }
static function get($jid, $start = false, $end = false, $limit = false) { $dom = new \DOMDocument('1.0', 'UTF-8'); $query = $dom->createElementNS('urn:xmpp:mam:0', 'query'); $x = $dom->createElementNS('jabber:x:data', 'x'); $query->appendChild($x); $field_type = $dom->createElement('field'); $field_type->setAttribute('var', 'FORM_TYPE'); $field_type->appendChild($dom->createElement('value', 'urn:xmpp:mam:0')); $x->appendChild($field_type); $field_with = $dom->createElement('field'); $field_with->setAttribute('var', 'with'); $field_with->appendChild($dom->createElement('value', $jid)); $x->appendChild($field_with); if ($start) { $field_start = $dom->createElement('field'); $field_start->setAttribute('var', 'start'); $field_start->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $start + 1))); $x->appendChild($field_start); } if ($end) { $field_end = $dom->createElement('field'); $field_end->setAttribute('var', 'end'); $field_end->appendChild($dom->createElement('value', date('Y-m-d\\TH:i:s\\Z', $end + 1))); $x->appendChild($field_end); } if ($limit) { $field_limit = $dom->createElement('field'); $field_limit->setAttribute('var', 'limit'); $field_limit->appendChild($dom->createElement($limit)); $x->appendChild($field_limit); } $xml = \Moxl\API::iqWrapper($query, null, 'set'); \Moxl\API::request($xml); }
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) { if (is_null($doc)) { $doc = new DOMDocument('1.0', 'utf-8'); } if ($this->_rootNamespaceURI != null) { $element = $doc->createElementNS($this->_rootNamespaceURI, $this->_rootElement); } elseif ($this->_rootNamespace !== null) { if (strpos($this->_rootElement, ':') === false) { $elementName = $this->_rootNamespace . ':' . $this->_rootElement; } else { $elementName = $this->_rootElement; } $element = $doc->createElementNS($this->lookupNamespace($this->_rootNamespace), $elementName); } else { $element = $doc->createElement($this->_rootElement); } if ($this->_text != null) { $element->appendChild($element->ownerDocument->createTextNode($this->_text)); } foreach ($this->_extensionElements as $extensionElement) { $element->appendChild($extensionElement->getDOM($element->ownerDocument)); } foreach ($this->_extensionAttributes as $attribute) { $element->setAttribute($attribute['name'], $attribute['value']); } return $element; }
static function set($data) { $dom = new \DOMDocument('1.0', 'UTF-8'); $pubsub = $dom->createElementNS('http://jabber.org/protocol/pubsub', 'pubsub'); $publish = $dom->createElement('publish'); $publish->setAttribute('node', 'urn:xmpp:vcard4'); $pubsub->appendChild($publish); $item = $dom->createElement('item'); $item->setAttribute('id', 'current'); $publish->appendChild($item); $vcard = $dom->createElementNS('urn:ietf:params:xml:ns:vcard-4.0', 'vcard'); $item->appendChild($vcard); $fn = $dom->createElement('fn'); $fn->appendChild($dom->createElement('text', $data->fn)); $vcard->appendChild($fn); $nickname = $dom->createElement('nickname'); $nickname->appendChild($dom->createElement('text', $data->name)); $vcard->appendChild($nickname); $bday = $dom->createElement('bday'); $bday->appendChild($dom->createElement('date', $data->date)); $vcard->appendChild($bday); $url = $dom->createElement('url'); $url->appendChild($dom->createElement('uri', $data->url)); $vcard->appendChild($url); $note = $dom->createElement('note'); $note->appendChild($dom->createElement('text', $data->description)); $vcard->appendChild($note); $gender = $dom->createElement('gender'); $sex = $dom->createElement('sex'); $gender->appendChild($sex); $sex->appendChild($dom->createElement('text', $data->gender)); $vcard->appendChild($gender); $marital = $dom->createElement('marital'); $status = $dom->createElement('status'); $marital->appendChild($status); $status->appendChild($dom->createElement('text', $data->marital)); $vcard->appendChild($marital); $impp = $dom->createElement('impp'); $impp->appendChild($dom->createElement('uri', 'xmpp:' . $data->jid)); if ($data->twitter) { $impp->appendChild($dom->createElement('uri', 'twitter:' . $data->twitter)); } if ($data->yahoo) { $impp->appendChild($dom->createElement('uri', 'ymsgr:' . $data->yahoo)); } if ($data->skype) { $impp->appendChild($dom->createElement('uri', 'skype:' . $data->skype)); } $vcard->appendChild($impp); $email = $dom->createElement('email'); $email->appendChild($dom->createElement('text', $data->email)); $vcard->appendChild($email); $adr = $dom->createElement('adr'); $adr->appendChild($dom->createElement('locality', $data->adrlocality)); $adr->appendChild($dom->createElement('code', $data->adrpostalcode)); $adr->appendChild($dom->createElement('country', $data->adrcountry)); $vcard->appendChild($adr); $xml = \Moxl\API::iqWrapper($pubsub, false, 'set'); \Moxl\API::request($xml); }
static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false) { $session = \Sessionx::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $root = $dom->createElementNS('jabber:client', 'message'); $dom->appendChild($root); $root->setAttribute('to', str_replace(' ', '\\40', $to)); $root->setAttribute('id', $session->id); $root->setAttribute('type', $type); if ($content != false) { $body = $dom->createElement('body', $content); $root->appendChild($body); } if ($html != false) { $xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html'); $body = $dom->createElement('http://www.w3.org/1999/xhtml', 'body', $html); $xhtml->appendChild($body); $root->appendChild($xhtml); } if ($chatstates != false) { $chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates); $root->appendChild($chatstate); } if ($receipts != false) { if ($receipts == 'request') { $request = $dom->createElement('request'); } else { $request = $dom->createElement('received'); $request->setAttribute('id', $receipts); } $request->setAttribute('xmlns', 'urn:xmpp:receipts'); $root->appendChild($request); } \Moxl\API::request($dom->saveXML($dom->documentElement)); }
/** * Creates a You Tube Playlist. * * @param array $data See Model::save() * @param boolean $validate See Model::save() * @param array $fieldList See Model::save() * @return boolean */ public function save($data = null, $validate = true, $fieldList = array()) { // Create the XML payload $doc = new DOMDocument('1.0', 'utf-8'); $entry = $doc->createElementNS('http://www.w3.org/2005/Atom', 'entry'); $entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:yt', 'http://gdata.youTube.com/schemas/2007'); $doc->appendChild($entry); if (isset($data[$this->alias]['title'])) { $title = $doc->createElement('title', $data[$this->alias]['title']); $title->setAttribute('type', 'text'); } $entry->appendChild($title); if (isset($data[$this->alias]['summary'])) { $summary = $doc->createElement('summary', $data[$this->alias]['summary']); } $entry->appendChild($summary); if (!empty($data[$this->alias]['private'])) { $private = $doc->createElementNS('http://gdata.youtube.com/schemas/2007', 'yt:private'); $entry->appendChild($private); } // Add the content type in so OAuth won't use the body in the signature $this->request = array('uri' => array('path' => 'feeds/api/users/default/playlists'), 'header' => array('Content-Type' => 'application/atom+xml'), 'auth' => true, 'body' => $doc->saveXML()); $result = parent::save($data, $validate, $fieldList); if ($result) { $this->setInsertID($this->response['entry']['playlistId']); } return $result; }
public function execute(InputInterface $input, OutputInterface $output) { $file = $input->getArgument('file'); if (!preg_match("'^/|(?:[^:\\\\/]+://)|(?:[a-z]:[\\\\/])'i", $file)) { $file = $this->directory . '/resource/' . $file . '.html.xml'; } $file = Filesystem::normalizePath($file); $questionHelper = $this->getHelper('question'); $question = new ConfirmationQuestion(sprintf('Create view <info>%s</info>? [n] ', $file), false); if (!$questionHelper->ask($input, $output, $question)) { return; } $xml = new \DOMDocument('1.0', 'UTF-8'); $xml->formatOutput = true; $root = $xml->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:composition')); $root->appendChild($xml->createAttribute('extends')); $root->appendChild($xml->createAttribute('xmlns'))->appendChild($xml->createTextNode(ExpressViewParser::NS_XHTML)); $root->appendChild($xml->createTextNode("\n\n ")); $block = $root->appendChild($xml->createElementNS(ExpressViewParser::NS_EXPRESS, 'k:block')); $block->appendChild($xml->createAttribute('name'))->appendChild($xml->createTextNode('main')); $block->appendChild($xml->createTextNode("\n TODO: Create composition contents...\n ")); $root->appendChild($xml->createTextNode("\n\n")); Filesystem::writeFile($file, $xml->saveXML()); $output->writeln(''); $output->writeln(sprintf('CREATED: <info>%s</info>', $file)); }
/** * Serializes one privilege * * @param DOMDocument $doc * @param DOMElement $node * @param string $privName * @return void */ protected function serializePriv($doc, $node, $privName) { $xp = $doc->createElementNS('DAV:', 'd:privilege'); $node->appendChild($xp); $privParts = null; preg_match('/^{([^}]*)}(.*)$/', $privName, $privParts); $xp->appendChild($doc->createElementNS($privParts[1], 'd:' . $privParts[2])); }
public function getTotals() { $totalsContainer = $this->getContextNode()->firstChild; if (!$totalsContainer) { $totalsContainer = $this->getContextNode()->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'totals')); } return new PHP_CodeCoverage_Report_XML_Totals($totalsContainer); }
public function getLineCoverage($line) { $coverage = $this->contextNode->getElementsByTagNameNS('http://schema.phpunit.de/coverage/1.0', 'coverage')->item(0); if (!$coverage) { $coverage = $this->contextNode->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'coverage')); } $lineNode = $coverage->appendChild($this->dom->createElementNS('http://schema.phpunit.de/coverage/1.0', 'line')); return new PHP_CodeCoverage_Report_XML_File_Coverage($lineNode, $line); }
static function get($xmlns) { $dom = new \DOMDocument('1.0', 'utf-8'); $query = $dom->createElementNS('jabber:iq:private', 'query'); $data = $dom->createElementNS($xmlns, 'data'); $query->appendchild($data); $xml = \Moxl\API::iqWrapper($query, false, 'get'); \Moxl\API::request($xml); }
/** * Return DOM object contains RSS 1.0 fomat feed data. * * @param boolean $format_output * @return object */ protected function buildRss1($format_output = false) { $doc = new DOMDocument('1.0', 'UTF-8'); $doc->formatOutput = $format_output; $ns = array('xml' => 'http://www.w3.org/XML/1998/namespace', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'rss' => 'http://purl.org/rss/1.0/', 'dc' => 'http://purl.org/dc/elements/1.1/', 'content' => 'http://purl.org/rss/1.0/modules/content/'); $root = $doc->appendChild($doc->createElementNS($ns['rdf'], 'rdf:RDF')); if (!empty($this->channel->language)) { $root->setAttributeNS($ns['xml'], 'xml:lang', $this->channel->language); } $channel_element = $root->appendChild($doc->createElementNS($ns['rss'], 'channel')); $channel_element->setAttributeNS($ns['rdf'], 'rdf:about', $this->channel->link); $channel_element->appendChild($doc->createElementNS($ns['rss'], 'title', $this->channel->title)); $channel_element->appendChild($doc->createElementNS($ns['rss'], 'link', $this->channel->link)); $channel_element->appendChild($doc->createElementNS($ns['rss'], 'description', $this->channel->description)); $channel_element->appendChild($doc->createElementNS($ns['dc'], 'dc:date', date(DATE_W3C, time()))); if (!empty($this->channel->language)) { $channel_element->appendChild($doc->createElementNS($ns['dc'], 'dc:language', $this->channel->language)); } if ($this->channel->image and !empty($this->channel->image->url)) { $image = $channel_element->appendChild($doc->createElementNS($ns['rss'], 'image')); $image->setAttributeNS($ns['rdf'], 'rdf:resource', $this->channel->image->url); $image_element = $root->appendChild($doc->createElementNS($ns['rss'], 'image')); $image_element->setAttributeNS($ns['rdf'], 'rdf:about', $this->channel->image->url); $image_element->appendChild($doc->createElementNS($ns['rss'], 'url', $this->channel->image->url)); $image_element->appendChild($doc->createElementNS($ns['rss'], 'title', !empty($this->channel->image->title) ? $this->channel->image->title : $this->channel->title)); $image_element->appendChild($doc->createElementNS($ns['rss'], 'link', !empty($this->channel->image->link) ? $this->image->channel->link : $this->channel->link)); } $items_element = $channel_element->appendChild($doc->createElementNS($ns['rss'], 'items')); $rdf_seq_element = $items_element->appendChild($doc->createElementNS($ns['rdf'], 'rdf:Seq')); foreach ($this->channel->items as $item) { $rdf_li = $rdf_seq_element->appendChild($doc->createElementNS($ns['rdf'], 'rdf:li')); $rdf_li->setAttributeNS($ns['rdf'], 'rdf:resource', $item->guid); $item_element = $root->appendChild($doc->createElementNS($ns['rss'], 'item')); $item_element->setAttributeNS($ns['rdf'], 'rdf:about', $item->guid); $item_element->appendChild($doc->createElementNS($ns['rss'], 'title', $item->title)); $item_element->appendChild($doc->createElementNS($ns['rss'], 'link', $item->link)); if (!empty($item->description)) { $plaintext = strip_tags($item->description); if (function_exists('mb_strimwidth')) { $plaintext = mb_strimwidth($plaintext, 0, 500, '...', 'UTF-8'); } $description = $item_element->appendChild($doc->createElementNS($ns['rss'], 'description')); $description->appendChild($doc->createTextNode($plaintext)); $content_encoded = $item_element->appendChild($doc->createElementNS($ns['content'], 'content:encoded')); $content_encoded->appendChild($doc->createCDATASection($item->description)); } if (!empty($item->category)) { $item_element->appendChild($doc->createElementNS($ns['dc'], 'dc:subject', $item->category)); } if (!empty($item->pubDate)) { $item_element->appendChild($doc->createElementNS($ns['dc'], 'dc:date', date(DATE_W3C, $item->pubDate))); } } return $doc; }
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); }
public function buildXmlChildElementShema(\DOMDocument $xml, \DOMElement $sequence, HelperXmlSchemaBuilder $builder) { $when = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element')); $when->setAttribute('ref', 'tns:when'); $when->setAttribute('minOccurs', '1'); $when->setAttribute('maxOccurs', 'unbounded'); $otherwise = $sequence->appendChild($xml->createElementNS(self::NS_XSD, 'element')); $otherwise->setAttribute('ref', 'tns:otherwise'); $otherwise->setAttribute('minOccurs', '0'); $otherwise->setAttribute('maxOccurs', '1'); }
public function serialize(DOMDocument $document) { $xsd = ckXsdNamespace::get('xsd'); $node = $document->createElementNS($xsd->getUrl(), $xsd->qualify($this->getNodeName())); $node->setAttribute('name', $this->getName()); $sequence = $document->createElementNS($xsd->getUrl(), $xsd->qualify('sequence')); foreach ($this->getElements() as $element) { $sequence->appendChild($element->serialize($document)); } $node->appendChild($sequence); return $node; }
/** * */ private function init() { $this->dom = new \DOMDocument('1.0', 'UTF-8'); $this->dom->preserveWhiteSpace = false; $this->dom->formatOutput = true; if ($this->filename->exists()) { $this->dom->load($this->filename->asString()); } else { $this->dom->appendChild($this->dom->createElementNS($this->getNamespace(), $this->getRootElementName())); } $this->xPath = new \DOMXPath($this->dom); $this->xPath->registerNamespace('phive', $this->getNamespace()); }
/** * @see ckDOMSerializable::serialize() */ public function serialize(DOMDocument $document) { $wsdl = ckXsdNamespace::get('wsdl'); $tns = ckXsdNamespace::get('tns'); $soap = ckXsdNamespace::get('soap'); $node = $document->createElementNS($wsdl->getUrl(), $wsdl->qualify($this->getNodeName())); $node->setAttribute('name', $this->getName()); $node->setAttribute('binding', $tns->qualify($this->getBinding()->getName())); $address = $document->createElementNS($soap->getUrl(), $soap->qualify('address')); $address->setAttribute('location', $this->getLocation()); $node->appendChild($address); return $node; }
/** * Dumps the service container as an XML string. * * @param array $options An array of options * * @return string An xml string representing of the service container * * @api */ public function dump(array $options = array()) { $this->document = new \DOMDocument('1.0', 'utf-8'); $this->document->formatOutput = true; $container = $this->document->createElementNS('http://symfony.com/schema/dic/services', 'container'); $container->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $container->setAttribute('xsi:schemaLocation', 'http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd'); $this->addParameters($container); $this->addServices($container); $this->document->appendChild($container); $xml = $this->document->saveXML(); $this->document = null; return $xml; }
/** * Wrap document content into xsl template. * * @param \DOMDocument $document * @return void */ public static function wrapIntoTemplate(\DOMDocument $document) { $stylesheet = $document->createElementNS(self::XSL_NS, 'xsl:stylesheet'); $stylesheet->setAttribute('version', '1.0'); $output = $document->createElementNS(self::XSL_NS, 'xsl:output'); $output->setAttribute('method', 'xml'); $output->setAttribute('encoding', 'UTF-8'); $stylesheet->appendChild($output); $template = $document->createElementNS(self::XSL_NS, 'xsl:template'); $template->setAttribute('match', '/' . self::VALUE_NODE); $template->appendChild($document->documentElement); $stylesheet->appendChild($template); $document->appendChild($stylesheet); }
/** * Return the message as a DOM element * @param DOMDocument $wsdl The wsdl document the messages will be children of */ public function getMessageElement(DOMDocument $dom) { $message = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:message'); $message->setAttribute('name', $this->name); foreach ($this->parts as $part) { if (isset($part['name'])) { $partElement = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:part'); $partElement->setAttribute('name', $part['name']); $partElement->setAttribute('type', $part['type']); $message->appendChild($partElement); } } return $message; }
static function setConfig($to, $data) { $dom = new \DOMDocument('1.0', 'UTF-8'); $query = $dom->createElementNS('http://jabber.org/protocol/muc#owner', 'query'); $dom->appendChild($query); $x = $dom->createElementNS('jabber:x:data', 'x'); $x->setAttribute('type', 'submit'); $query->appendChild($x); $xmpp = new \FormtoXMPP($data); $xmpp->create(); $xmpp->appendToX($dom); $xml = \Moxl\API::iqWrapper($query, $to, 'set'); \Moxl\API::request($xml); }
static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false, $id = false, $replace = false) { $session = \Session::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $root = $dom->createElementNS('jabber:client', 'message'); $dom->appendChild($root); $root->setAttribute('to', str_replace(' ', '\\40', $to)); $root->setAttribute('type', $type); if ($id != false) { $root->setAttribute('id', $id); } else { $root->setAttribute('id', $session->get('id')); } if ($content != false) { $body = $dom->createElement('body', $content); $root->appendChild($body); } if ($replace != false) { $rep = $dom->createElementNS('urn:xmpp:message-correct:0', 'replace'); $rep->setAttribute('id', $replace); $root->appendChild($rep); } if ($html != false) { $xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html'); $body = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'body'); $dom2 = new \DOMDocument('1.0', 'UTF-8'); $dom2->loadXml('<root>' . $html . '</root>'); $bar = $dom2->documentElement->firstChild; // we want to import the bar tree $body->appendChild($dom->importNode($bar, TRUE)); $xhtml->appendChild($body); $root->appendChild($xhtml); } if ($chatstates != false) { $chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates); $root->appendChild($chatstate); } if ($receipts != false) { if ($receipts == 'request') { $request = $dom->createElement('request'); } else { $request = $dom->createElement('received'); $request->setAttribute('id', $receipts); } $request->setAttribute('xmlns', 'urn:xmpp:receipts'); $root->appendChild($request); } \Moxl\API::request($dom->saveXML($dom->documentElement)); }
/** * Convert this message to an unsigned XML document. * * This method does not sign the resulting XML document. * * @return \DOMElement The root element of the DOM tree. */ public function toUnsignedXML() { $this->document = DOMDocumentFactory::create(); $root = $this->document->createElementNS(Constants::NS_SAMLP, 'samlp:' . $this->tagName); $this->document->appendChild($root); /* Ugly hack to add another namespace declaration to the root element. */ $root->setAttributeNS(Constants::NS_SAML, 'saml:tmp', 'tmp'); $root->removeAttributeNS(Constants::NS_SAML, 'tmp'); $root->setAttribute('ID', $this->id); $root->setAttribute('Version', '2.0'); $root->setAttribute('IssueInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->issueInstant)); if ($this->destination !== null) { $root->setAttribute('Destination', $this->destination); } if ($this->consent !== null && $this->consent !== Constants::CONSENT_UNSPECIFIED) { $root->setAttribute('Consent', $this->consent); } if ($this->issuer !== null) { Utils::addString($root, Constants::NS_SAML, 'saml:Issuer', $this->issuer); } if (!empty($this->extensions)) { Extensions::addList($root, $this->extensions); } return $root; }
public function testSerialization() { // create xml doc $DOM = new \DOMDocument('1.0', 'utf-8'); $DOM->formatOutput = true; $error = $DOM->createElementNS('DAV:', 'd:error'); $error->setAttribute('xmlns:s', \Sabre\DAV\Server::NS_SABREDAV); $DOM->appendChild($error); // serialize the exception $message = "1234567890"; $retry = false; $expectedXml = <<<EOD <?xml version="1.0" encoding="utf-8"?> <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:o="http://owncloud.org/ns"> <o:retry xmlns:o="o:">false</o:retry> <o:reason xmlns:o="o:">1234567890</o:reason> </d:error> EOD; $ex = new InvalidPath($message, $retry); $server = $this->getMock('Sabre\\DAV\\Server'); $ex->serialize($server, $error); // assert $xml = $DOM->saveXML(); $this->assertEquals($expectedXml, $xml); }
function payload() { /*return json_encode( array( 'method' => $this->Name, 'params' => $this->Parameters, 'id' => $this->Id ) );*/ // eZ SOAP version $doc = new DOMDocument("1.0"); $doc->name = 'eZSOAP message'; $root = $doc->createElementNS(ggSOAPRequest::ENV, ggSOAPRequest::ENV_PREFIX . ':Envelope'); $root->setAttribute(ggSOAPRequest::ENV_PREFIX . ':encodingStyle', ggSOAPRequest::ENC); $root->setAttribute('xmlns:' . ggSOAPRequest::XSI_PREFIX, ggSOAPRequest::SCHEMA_INSTANCE); $root->setAttribute('xmlns:' . ggSOAPRequest::XSD_PREFIX, ggSOAPRequest::SCHEMA_DATA); $root->setAttribute('xmlns:' . ggSOAPRequest::ENC_PREFIX, ggSOAPRequest::ENC); // add the body $body = $doc->createElement(ggSOAPRequest::ENV_PREFIX . ':Body'); $body->setAttribute('xmlns:' . ggSOAPRequest::REQ_PREFIX, $this->ns); /*foreach( $this->BodyAttributes as $name => $value ) { $body->setAttribute( $name, $value ); }*/ $root->appendChild($body); // add the request $request = $doc->createElement(ggSOAPRequest::REQ_PREFIX . ':' . $this->Name); // add the request parameters /// @todo add support for pre-encoded params... foreach ($this->Parameters as $key => $parameter) { $param = ggSOAPRequest::encodeValue($doc, $key, $parameter); //if ( $param == false ) // eZDebug::writeError( "Error enconding data for payload", "eZSOAPRequest::payload()" ); $request->appendChild($param); } $body->appendChild($request); $doc->appendChild($root); return $doc->saveXML(); }
/** * Zend_Feed_Entry_Abstract constructor * * The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry * is part of, and optionally an XML construct (usually a * SimpleXMLElement, but it can be an XML string or a DOMNode as * well) that contains the contents of the entry. * * @param string $uri * @param SimpleXMLElement|DOMNode|string $element * @return void */ public function __construct($uri = null, $element = null) { if (!$element instanceof DOMElement) { if ($element) { // Load the feed as an XML DOMDocument object @ini_set('track_errors', 1); $doc = new DOMDocument(); $success = @$doc->loadXML($element); @ini_restore('track_errors'); if (!$success) { throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}"); } $element = $doc->getElementsByTagName($this->_rootElement)->item(0); if (!$element) { throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.'); } } else { $doc = new DOMDocument('1.0', 'utf-8'); if ($this->_rootNamespace !== null) { $element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement); } else { $element = $doc->createElement($this->_rootElement); } } } parent::__construct($element); }
/** * Generuojamas xml'as ticketui gauti * * @param $pid * @param string $nodeId * @param string $namespace * @param string $postbackUrl * @param string $correlationData * @param array $authenticationProviders * @param array $authenticationAttributes * @param array $userInformations * @return DOMDocument */ protected static function generateTicketDom($pid, $nodeId = "uniqueNodeId", $namespace = "authentication", $postbackUrl = "https://localhost", $correlationData = "correlationData", $authenticationProviders = null, $authenticationAttributes = null, $userInformations = null) { if (empty($authenticationProviders)) { $authenticationProviders = ["auth.lt.identity.card", "auth.lt.bank", "auth.signatureProvider", "auth.login.pass"]; } if (empty($authenticationAttributes)) { $authenticationAttributes = ["lt-personal-code", "lt-company-code"]; } if (empty($userInformations)) { $userInformations = ["firstName", "lastName", "companyName"]; } $dom = new DOMDocument('1.0', 'utf-8'); $root = $dom->createElementNS("http://www.epaslaugos.lt/services/authentication", "{$namespace}:authenticationRequest"); $root->setAttribute("id", $nodeId); $pid = $dom->createElement("{$namespace}:pid", $pid); $root->appendChild($pid); foreach ($authenticationProviders as $authenticationProvider) { $authenticationProvider_el = $dom->createElement("{$namespace}:authenticationProvider", $authenticationProvider); $root->appendChild($authenticationProvider_el); } foreach ($authenticationAttributes as $authenticationAttribute) { $authenticationAttribute_el = $dom->createElement("{$namespace}:authenticationAttribute", $authenticationAttribute); $root->appendChild($authenticationAttribute_el); } foreach ($userInformations as $userInformation) { $userInformation_el = $dom->createElement("{$namespace}:userInformation", $userInformation); $root->appendChild($userInformation_el); } $postbackUrl_el = $dom->createElement("{$namespace}:postbackUrl", $postbackUrl); $root->appendChild($postbackUrl_el); $customData_el = $dom->createElement("{$namespace}:customData", $correlationData); $root->appendChild($customData_el); $dom->appendChild($root); return $dom; }
function payload() { $doc = new DOMDocument("1.0"); $doc->name = 'eZSOAP message'; $root = $doc->createElementNS(eZSOAPEnvelope::ENV, eZSOAPEnvelope::ENV_PREFIX . ':Envelope'); $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSI_PREFIX, eZSOAPEnvelope::SCHEMA_INSTANCE); $root->setAttribute('xmlns:' . eZSOAPEnvelope::XSD_PREFIX, eZSOAPEnvelope::SCHEMA_DATA); $root->setAttribute('xmlns:' . eZSOAPEnvelope::ENC_PREFIX, eZSOAPEnvelope::ENC); // add the body $body = $doc->createElement(eZSOAPEnvelope::ENV_PREFIX . ':Body'); $body->setAttribute('xmlns:req', $this->Namespace); foreach ($this->BodyAttributes as $name => $value) { $body->setAttribute($name, $value); } $root->appendChild($body); // add the request $request = $doc->createElement('req:' . $this->Name); // add the request parameters foreach ($this->Parameters as $parameter) { $param = eZSOAPCodec::encodeValue($doc, $parameter->name(), $parameter->value()); if ($param == false) { eZDebug::writeError("Error encoding data for payload: " . $parameter->name(), __METHOD__); continue; } $request->appendChild($param); } $body->appendChild($request); $doc->appendChild($root); return $doc->saveXML(); }
/** * Parse a XML string and returns an ArrayCollection of FileEntity * * @return ArrayCollection */ public function ParseEntities() { /** * A default Exiftool XML can contains many RDF Descriptions */ $Entities = new ArrayCollection(); foreach ($this->getDomXpath()->query('/rdf:RDF/rdf:Description') as $node) { /** * Let's create a DOMDocument containing a single RDF result */ $Dom = new \DOMDocument(); $DomRootElement = $Dom->createElementNS(self::RDF_NAMESPACE, 'rdf:RDF'); $DomRootElement->appendChild($Dom->importNode($node, true)); $Dom->appendChild($DomRootElement); $LocalXpath = new \DOMXPath($Dom); $LocalXpath->registerNamespace('rdf', self::RDF_NAMESPACE); $RDFDescriptionRoot = $LocalXpath->query('/rdf:RDF/rdf:Description'); /** * Let's associate a Description to the corresponding file */ $file = $RDFDescriptionRoot->item(0)->getAttribute('rdf:about'); $Entities->set($file, new FileEntity($file, $Dom, new static())); } return $Entities; }
static function sessionStart($to) { $dom = new \DOMDocument('1.0', 'utf-8'); $session = $dom->createElementNS('urn:ietf:params:xml:ns:xmpp-session', 'session'); $xml = \Moxl\API::iqWrapper($session, $to, 'set'); \Moxl\API::request($xml); }