public function exportCoursesToXML() { $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('kurse', '', 'http://dl.dropbox.com/u/357576/saves/dtd/course.dtd'); $doc = $imp->createDocument('', '', $dtd); $doc->formatOutput = true; $doc->encoding = "utf-8"; $doc->version = "1.0"; $pi = $doc->createProcessingInstruction("xml-stylesheet", "type=\"text/css\" href=\"http://dl.dropbox.com/u/357576/saves/dtd/course.css\""); $doc->appendChild($pi); $r = $doc->createElement("kurse"); $doc->appendChild($r); $courses = $this->db->model('kurse')->select()->execute()->result; foreach ($courses as $course) { $k = $doc->createElement("kurs"); $course_id = $doc->createElement("kursId"); $course_id->appendChild($doc->createTextNode($course['id'])); $k->appendChild($course_id); $course_name = $doc->createElement("kursname"); $course_name->appendChild($doc->createTextNode($course['kursname'])); $k->appendChild($course_name); $semester = $doc->createElement("semester"); $semester->appendChild($doc->createTextNode($course['semester'])); $k->appendChild($semester); $r->appendChild($k); } return $doc->saveXML(); }
/** * Array to XML markup. * * @since 160829.74007 XML conversion utils. * * @param string $parent_element_name Parent element name. * @param array $array Input array to convert. * @param array $args Any additional behavioral args. * * @return string XML or HTML (with or w/o a DOCTYPE tag). * * @note `<!DOCTYPE html>` is an HTML DOCTYPE tag. * @note `<?xml version="1.0" encoding="utf-8"?>` is an XML DOCTYPE tag. */ public function __invoke(string $parent_element_name, array $array, array $args = []) : string { $default_args = ['type' => 'xml', 'version' => '1.0', 'encoding' => 'utf-8', 'include_doctype' => true, 'format' => true]; $args += $default_args; // Merge w/ defaults. $args['type'] = (string) $args['type']; $args['version'] = (string) $args['version']; $args['encoding'] = (string) $args['encoding']; $args['include_doctype'] = (bool) $args['include_doctype']; $args['format'] = (bool) $args['format']; if ($args['type'] === 'html') { $DOMImplementation = new \DOMImplementation(); $DOMDocumentType = $DOMImplementation->createDocumentType($args['type']); $DOMDocument = $DOMImplementation->createDocument('', '', $DOMDocumentType); } else { $DOMDocument = new \DOMDocument($args['version']); } $DOMDocument->encoding = $args['encoding']; $DOMDocument->formatOutput = $args['format']; // Indentation. $save = $args['type'] === 'html' ? 'saveHTML' : 'saveXML'; $ParentDOMElement = $DOMDocument->createElement($parent_element_name); $DOMDocument->appendChild($ParentDOMElement); $this->convert($DOMDocument, $ParentDOMElement, $array); if (!$args['include_doctype']) { return (string) $DOMDocument->{$save}($DOMDocument->documentElement); } else { return (string) $DOMDocument->{$save}(); // With doctype. } }
/** * create the response * * @return DOMDocument */ public function getResponse() { // Creates an instance of the DOMImplementation class $imp = new DOMImplementation(); // Creates a DOMDocument instance $document = $imp->createDocument("http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006", 'Autodiscover'); $document->xmlVersion = '1.0'; $document->encoding = 'UTF-8'; $document->formatOutput = false; $response = $document->documentElement->appendChild($document->createElement('Response')); $user = $response->appendChild($document->createElement('User')); $user->appendChild($document->createElement('EMailAddress', $this->emailAddress)); $settings = $document->createElement('Settings'); if (!empty($this->mobileSyncUrl)) { $server = $document->createElement('Server'); $server->appendChild($document->createElement('Type', 'MobileSync')); $server->appendChild($document->createElement('Url', $this->mobileSyncUrl)); $server->appendChild($document->createElement('Name', $this->mobileSyncUrl)); $settings->appendChild($server); } if (!empty($this->certEnrollUrl)) { $server = $document->createElement('Server'); $server->appendChild($document->createElement('Type', 'CertEnroll')); $server->appendChild($document->createElement('Url', $this->certEnrollUrl)); $server->appendChild($document->createElement('Name')); $server->appendChild($document->createElement('ServerData', 'CertEnrollTemplate')); $settings->appendChild($server); } if ($settings->hasChildNodes()) { $action = $response->appendChild($document->createElement('Action')); $action->appendChild($settings); } return $document; }
public function toXmlString() { $impl = new DOMImplementation(); $docTypeName = 'uBookMessage'; $docTypePublic = '-//uBook/DTD uBookMessage 1//EN'; $docTypeId = WEBDIR . 'uBookMessage.dtd'; $docType = $impl->createDocumentType($docTypeName, $docTypePublic, $docTypeId); $doc = $impl->createDocument('', '', $docType); $doc->encoding = 'UTF-8'; $doc->xmlStandalone = false; $message = $doc->createElement('uBookMessage'); $message->setAttribute('version', '1'); $message->setAttribute('from', $this->from); $doc->appendChild($message); foreach ($this->bookList as $i => $b) { $book = $doc->createElement('book'); $book->setAttribute('url', $b->getUrl()); $book->setAttribute('author', $b->getAuthor()); $book->setAttribute('title', $b->getTitle()); $book->setAttribute('price', $b->getPrice()); $message->appendChild($book); } foreach ($this->servers as $i => $s) { $server = $doc->createElement('server'); $server->setAttribute('url', $s->getUrl()); $message->appendChild($server); } $doc->formatOutput = true; return $doc->saveXML(); }
/** * @return \DOMDocument */ public function toDOMDocument() { $implementation = new \DOMImplementation(); $dtd = $implementation->createDocumentType('root', null, 'https://www.sode.pl/sode.dtd'); $dom = $implementation->createDocument('', '', $dtd); $root = $dom->createElement('root'); $properties = $dom->importNode($this->getProperties()->toDOMElement(), true); $client = $dom->importNode($this->getClient()->toDOMElementWithAttributes(), true); $document = $dom->createElement('document'); $document->setAttribute('type', $this->getType()); $document->setAttribute('label', $this->getLabel()); $document->setAttribute('label_name', $this->getLabelName()); $document->setAttribute('notify', $this->getNotify()); $document->setAttribute('paid', $this->getPaid() ? 1 : 0); $root->appendChild($document); $document->appendChild($properties); $document->appendChild($client); $elements = $dom->createElement('elements'); foreach ($this->elements as $element) { $elements->appendChild($dom->importNode($element->toDOMElement(), true)); } if ($this->getAutoTotalEntry()) { $elements->appendChild($dom->importNode($this->getTotalElement()->toDOMElement(), true)); } $document->appendChild($elements); $dom->formatOutput = true; $dom->appendChild($root); return $dom; }
/** * Create a new XML document. * If $url is set, the DOCTYPE definition is treated as a PUBLIC * definition; $dtd should contain the ID, and $url should contain the * URL. Otherwise, $dtd should be the DTD name. */ function &createDocument($type = null, $dtd = null, $url = null) { $version = '1.0'; if (class_exists('DOMImplementation')) { // Use the new (PHP 5.x) DOM $impl = new DOMImplementation(); // only generate a DOCTYPE if type is non-empty if ($type != '') { $domdtd = $impl->createDocumentType($type, isset($url) ? $dtd : '', isset($url) ? $url : $dtd); $doc = $impl->createDocument($version, '', $domdtd); } else { $doc = $impl->createDocument($version, ''); } // ensure we are outputting UTF-8 $doc->encoding = 'UTF-8'; } else { // Use the XMLNode class $doc = new XMLNode(); $doc->setAttribute('version', $version); if ($type !== null) { $doc->setAttribute('type', $type); } if ($dtd !== null) { $doc->setAttribute('dtd', $dtd); } if ($url !== null) { $doc->setAttribute('url', $url); } } return $doc; }
public static function getPlistString($ipa, $bundleIdentifier, $version, $title) { $imp = new \DOMImplementation(); $dtd = $imp->createDocumentType("plist", "-//Apple//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd"); $dom = $imp->createDocument("", "", $dtd); $dom->encoding = "UTF-8"; $dom->formatOutput = true; $dom->appendChild($element = $dom->createElement('plist')); $element->setAttribute('version', '1.0'); $element->appendChild($dict = $dom->createElement('dict')); $dict->appendChild($dom->createElement('key', 'items')); $dict->appendChild($array = $dom->createElement('array')); $array->appendChild($mainDict = $dom->createElement('dict')); $mainDict->appendChild($dom->createElement('key', 'assets')); $mainDict->appendChild($array = $dom->createElement('array')); $array->appendChild($dict = $dom->createElement('dict')); $dict->appendChild($dom->createElement('key', 'kind')); $dict->appendChild($dom->createElement('string', 'software-package')); $dict->appendChild($dom->createElement('key', 'url')); $dict->appendChild($dom->createElement('string', $ipa)); $mainDict->appendChild($dom->createElement('key', 'metadata')); $mainDict->appendChild($dict = $dom->createElement('dict')); $dict->appendChild($dom->createElement('key', 'bundle-identifier')); $dict->appendChild($dom->createElement('string', $bundleIdentifier)); $dict->appendChild($dom->createElement('key', 'bundle-version')); $dict->appendChild($dom->createElement('string', $version)); $dict->appendChild($dom->createElement('key', 'kind')); $dict->appendChild($dom->createElement('string', 'software')); $dict->appendChild($dom->createElement('key', 'title')); $dict->appendChild($titleElement = $dom->createElement('string')); $titleElement->appendChild($dom->createTextNode($title . '-v.' . $version)); return $dom->saveXML(); }
/** * test xml generation for IPhone * * birthday must have 12 hours added */ public function testAppendXmlData() { $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('AirSync', "-//AIRSYNC//DTD AirSync//EN", "http://www.microsoft.com/"); $testDoc = $imp->createDocument('uri:AirSync', 'Sync', $dtd); $testDoc->formatOutput = true; $testDoc->encoding = 'utf-8'; $appData = $testDoc->documentElement->appendChild($testDoc->createElementNS('uri:AirSync', 'ApplicationData')); $email = new Syncroton_Model_FileReference(array('contentType' => 'text/plain', 'data' => 'Lars')); $email->appendXML($appData, $this->_testDevice); #echo $testDoc->saveXML(); $xpath = new DomXPath($testDoc); $xpath->registerNamespace('AirSync', 'uri:AirSync'); $xpath->registerNamespace('AirSyncBase', 'uri:AirSyncBase'); $xpath->registerNamespace('Email', 'uri:Email'); $xpath->registerNamespace('Email2', 'uri:Email2'); $nodes = $xpath->query('//AirSync:Sync/AirSync:ApplicationData/AirSyncBase:ContentType'); $this->assertEquals(1, $nodes->length, $testDoc->saveXML()); $this->assertEquals('text/plain', $nodes->item(0)->nodeValue, $testDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:ApplicationData/ItemOperations:Data'); $this->assertEquals(1, $nodes->length, $testDoc->saveXML()); $this->assertEquals('TGFycw==', $nodes->item(0)->nodeValue, $testDoc->saveXML()); // try to encode XML until we have wbxml tests $outputStream = fopen("php://temp", 'r+'); $encoder = new Syncroton_Wbxml_Encoder($outputStream, 'UTF-8', 3); $encoder->encode($testDoc); }
/** * Constructor * * @param HTMLTree $tree */ public function __construct(HTMLTree $tree) { $this->_tree = $tree; $dom_implementation = new \DOMImplementation(); $doc_type = $dom_implementation->createDocumentType('html', '', ''); $this->_dom = $dom_implementation->createDocument('', 'html', $doc_type); $this->_dom->documentElement->setAttribute('lang', 'en'); }
public static function doctype($docid, $object = false) { $doctypes = array(self::HTML_4_STR => array("HTML", "-//W3C//DTD HTML 4.01//EN", "http://www.w3.org/TR/html4/strict.dtd"), self::HTML_4_TRA => array("HTML", "-//W3C//DTD HTML 4.01 Transitional//EN", "http://www.w3.org/TR/html4/loose.dtd"), self::HTML_4_FRA => array("HTML", "-//W3C//DTD HTML 4.01 Frameset//EN", "http://www.w3.org/TR/html4/frameset.dtd"), self::XHTML_1_STR => array("HTML", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"), self::XHTML_1_TRA => array("HTML", "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"), self::XHTML_1_FRA => array("HTML", "-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"), self::XHTML_1_1 => array("HTML", "-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"), self::XHTML_1_BASIC => array("HTML", "-//W3C//DTD XHTML Basic 1.1//EN", "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"), self::HTML_5 => array("HTML", "", ""), self::MATHML_1 => array("MATH", "", "http://www.w3.org/Math/DTD/mathml1/mathml.dtd"), self::MATHML_2 => array("MATH", "-//W3C//DTD MathML 2.0//EN", "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd")); $implementation = new \DOMImplementation(); $dtd = $implementation->createDocumentType($doctypes[$docid][0], $doctypes[$docid][1], $doctypes[$docid][2]); $document = $implementation->createDocument('', '', $dtd); return $object ? $document : $document->saveHTML(); }
/** * init your xhtml document. * * @access public * @return void */ public function __construct() { $domImplementation = new DOMImplementation(); $doctype = $domImplementation->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); $this->document = $domImplementation->createDocument('http://www.w3.org/1999/xhtml', 'html', $doctype); $this->head = $this->document->createElement('head'); $this->body = $this->document->createElement('body'); $this->setTitle(null); $this->setTitleAppend(null); }
protected function on_create() { $impl = new DOMImplementation(); $dtd = $impl->createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'); $doc = $impl->createDocument($this->ccnamespaces[$this->rootns], null, $dtd); $doc->formatOutput = true; $doc->preserveWhiteSpace = true; $this->doc = $doc; parent::on_create(); }
function __construct($config) { $this->config = $config; $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('OPS_envelope', '', 'ops.dtd'); $dom = $imp->createDocument("", "", $dtd); $dom->encoding = 'UTF-8'; $dom->standalone = false; $this->xml = $dom; }
/** * Initialize destination document * * Initialize the structure which the destination document could be build * with. This may be an initial DOMDocument with some default elements, or * a string, or something else. * * @return mixed */ protected function initializeDocument() { $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('article', '-//OASIS//DTD DocBook XML V4.5//EN', 'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'); $docbook = $imp->createDocument('http://docbook.org/ns/docbook', '', $dtd); $docbook->formatOutput = true; $root = $docbook->createElementNs('http://docbook.org/ns/docbook', 'article'); $docbook->appendChild($root); return $root; }
public function createDomDocument() { $impl = new DOMImplementation(); $dtd = $impl->createDocumentType('docman', '', get_server_url() . '/plugins/docman/docman-1.0.dtd'); $doc = $impl->createDocument('', '', $dtd); $doc->encoding = 'UTF-8'; $doc->standalone = 'no'; $doc->version = '1.0'; $doc->formatOutput = true; return $doc; }
/** * Constructor * * @param RequestInterface $request Request * @param string $data Data * @throws InvalidResponseException if $data is empty */ public function __construct(RequestInterface $request, $data) { $this->request = $request; if (empty($data)) { throw new InvalidResponseException(); } $implementation = new \DOMImplementation(); $responseDom = $implementation->createDocument(); $responseDom->preserveWhiteSpace = false; $responseDom->loadXML($data); $this->data = simplexml_import_dom($responseDom->documentElement->firstChild); }
/** Build xml attributes from line data. See TicketLineInfo constructors. */ private function createAttributes($product, $tax) { // Set xml $domimpl = new \DOMImplementation(); $doctype = $domimpl->createDocumentType('properties', null, "http://java.sun.com/dtd/properties.dtd"); $attrs = $domimpl->createDocument(null, null, $doctype); $attrs->encoding = "UTF-8"; $attrs->version = "1.0"; $attrs->standalone = false; // Add root properties element $properties = $attrs->createElement("properties"); $attrs->appendChild($properties); // Add comment element $comment = $attrs->createElement("comment"); $comment->appendChild($attrs->createTextNode("POS-Tech")); // This is actually the application name $properties->appendChild($comment); // Add some product keys $entry = $attrs->createElement("entry"); $key = $attrs->createAttribute("key"); $key->appendChild($attrs->createTextNode("product.taxcategoryid")); $entry->appendChild($key); $entry->appendChild($attrs->createTextNode($tax->taxCatId)); $properties->appendChild($entry); $entry = $attrs->createElement("entry"); $key = $attrs->createAttribute("key"); $key->appendChild($attrs->createTextNode("product.com")); $entry->appendChild($key); $entry->appendChild($attrs->createTextNode("false")); // TODO add iscom field $properties->appendChild($entry); $entry = $attrs->createElement("entry"); $key = $attrs->createAttribute("key"); $key->appendChild($attrs->createTextNode("product.categoryid")); $entry->appendChild($key); $entry->appendChild($attrs->createTextNode($product->categoryId)); $properties->appendChild($entry); $entry = $attrs->createElement("entry"); $key = $attrs->createAttribute("key"); $key->appendChild($attrs->createTextNode("product.scale")); $entry->appendChild($key); $entry->appendChild($attrs->createTextNode(strval($product->scaled) ? "true" : "false")); $properties->appendChild($entry); $entry = $attrs->createElement("entry"); $key = $attrs->createAttribute("key"); $key->appendChild($attrs->createTextNode("product.name")); $entry->appendChild($key); $entry->appendChild($attrs->createTextNode($product->label)); $properties->appendChild($entry); // Save all this stuff $this->attributes = $attrs->saveXML(); }
function __construct() { // Define HTTP Client $this->client = new Proxy_Request(null, array('useBrackets' => false)); $this->client->setMethod(HTTP_REQUEST_METHOD_POST); $this->client->addHeader('Content-Type', 'text/xml'); $this->client->setURL($configArray['NCIP']['url']); // Setup XML Messages $dom = new DOMImplementation(); $doctype = $dom->createDocumentType('NCIPMessage', '-//NISO//NCIP DTD Version 1//EN', 'http://www.niso.org/ncip/v1_0/imp1/dtd/ncip_v1_0.dtd'); $this->doc = $dom->createDocument('', '', $doctype); $this->doc->encoding = 'UTF-8'; $this->doc->formatOutput = true; $this->agencyCode = $configArray['NCIP']['agencyId']; }
/** * Docarate BBCode AST * * Visit the BBCode abstract syntax tree. * * @param ezcDocumentBBCodeDocumentNode $ast * @return mixed */ public function visit(ezcDocumentBBCodeDocumentNode $ast) { // Create article from AST $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('article', '-//OASIS//DTD DocBook XML V4.5//EN', 'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'); $this->document = $imp->createDocument('http://docbook.org/ns/docbook', '', $dtd); $this->document->formatOutput = true; // $root = $this->document->createElement( 'article' ); $root = $this->document->createElementNs('http://docbook.org/ns/docbook', 'article'); $this->document->appendChild($root); // Visit all childs of the AST root node. foreach ($ast->nodes as $node) { $this->visitNode($root, $node); } return $this->document; }
/** * * @return \DOMDocument */ protected function buildDocument() { $dom = $this->domImplementation->createDocument(); $dom->encoding = "UTF-8"; $dom->version = "1.0"; return $dom; }
public function __construct($name = null, $public = null, $system = null) { /* DOMImplementation methods seem to be very fussy about how ** they are passed arguments. We do it this way to reduce errors and ** warnings that we don't need. */ $impl = new DOMImplementation(); if (is_null($name)) { $this->_dom = $impl->createDocument('', ''); } else { $dtd = $impl->createDocumentType($name, $public, $system); $this->_dom = $impl->createDocument('', '', $dtd); } $this->elementClass(); $this->_stack = array($this->_dom); }
/** * Creates HTML document. * * @return \DOMDocument */ protected function getDocument() { if (null === $this->document) { $this->document = \DOMImplementation::createDocument('http://www.w3.org/1999/xhtml', 'html', \DOMImplementation::createDocumentType('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd')); } return $this->document; }
/** * Creates and returns a new DOMDocument instance * * @param string $xml XML string * * @return DOMDocument */ protected function createDOMDocument($xml = null) { $domimp = new DOMImplementation(); $doctype = $domimp->createDocumentType('xliff', '-//XLIFF//DTD XLIFF//EN', 'http://www.oasis-open.org/committees/xliff/documents/xliff.dtd'); $dom = $domimp->createDocument('', '', $doctype); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; if (null !== $xml && is_string($xml)) { // Add header for XML with UTF-8 if (!preg_match('/<\\?xml/', $xml)) { $xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $xml; } $dom->loadXML($xml); } return $dom; }
function saveToXml($output, $searchFor) { $dom = new DOMImplementation(); $dtd = $dom->createDocumentType('albums', '', 'albums.dtd'); // Creates a DOMDocument instance $dom = $dom->createDocument("", "", $dtd); $xslt = $dom->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="albumfound.xsl"'); $dom->appendChild($xslt); $root = $dom->appendChild($dom->createElement('albums')); if ($searchFor == 'artist') { $data = $output['albums']['items']; } else { $data = $output['items']; } //var_dump($output); $counter = 1; foreach ($data as $album) { $url = 'https://api.spotify.com/v1/albums/' . $album['id']; $albumInfo = fetchAsJson($url); $albumNode = $dom->createElement('album'); $root->appendChild($albumNode); $albumNodeAttr = $dom->createAttribute('ID'); $albumNodeAttr->appendChild($dom->createTextNode($counter)); $albumNode->appendChild($albumNodeAttr); $albumName = $dom->createElement('albumName', $albumInfo["name"]); $albumNode->appendChild($albumName); $artist = $dom->createElement('artist', $albumInfo['artists'][0]['name']); $albumNode->appendChild($artist); $yearReleased = $albumInfo['release_date']; if ($albumInfo['release_date_precision'] != 'year') { $arr = explode("-", $yearReleased, 2); $yearReleased = $arr[0]; } $year = $dom->createElement('year', $yearReleased); $albumNode->appendChild($year); $numTracks = $dom->createElement('numTracks', $albumInfo['tracks']['total']); $albumNode->appendChild($numTracks); $imgUrl = $dom->createElement('imgUrl', $albumInfo['images'][0]['url']); $albumNode->appendChild($imgUrl); $albumUrl = $dom->createElement('albumUrl', $albumInfo['external_urls']['spotify']); $albumNode->appendChild($albumUrl); $counter++; } $dom->formatOutput = true; $songlib = $dom->saveXML(); $dom->save('xml/albumlib.xml'); }
public function __construct() { $doctype = DOMImplementation::createDocumentType('html', '-//W3C//DTD HTML 4.01//EN', 'http://www.w3.org/TR/html4/strict.dtd'); $this->document = DOMImplementation::createDocument(null, null, $doctype); $this->document->recover = true; $this->document->formatOutput = true; $this->element = $this->document; }
/** * Creates an XML Exception according to WMS 1.1.1 * * @return an XML String * @param $errorCode String * @param $errorMessage String */ function createExceptionXml($errorCode, $errorMessage) { // see http://de2.php.net/manual/de/domimplementation.createdocumenttype.php $imp = new DOMImplementation(); $dtd = $imp->createDocumentType("ServiceExceptionReport", "", "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd"); $doc = $imp->createDocument("", "", $dtd); $doc->encoding = 'UTF-8'; $doc->standalone = false; $el = $doc->createElement("ServiceExceptionReport"); $exc = $doc->createElement("ServiceException", $errorMessage); if ($errorCode) { $exc->setAttribute("code", $errorCode); } $el->appendChild($exc); $doc->appendChild($el); return $doc->saveXML(); }
/** * Create document with corresponding document description. * @param $xmlfile XML file to create document from * @param $dtdfile DTD file to create document from * @param $root tagname of the root element. * should be gathered from original XML file. * @return DOMDocument with $dtdfile attached */ private function createValidatableDocument($xmlfile = null, $dtdfile = null) { $d = null; $dx = new \DOMDocument(); if ($dx->load($xmlfile)) { $di = new \DOMImplementation(); $dtd = $di->createDocumentType($dx->documentElement->tagName, '', $dtdfile); $d = $di->createDocument("", $dx->documentElement->tagName, $dtd); $d->xmlStandalone = false; $d->xmlVersion = "1.0"; $d->removeChild($d->documentElement); $d->appendChild($d->importNode($dx->documentElement->cloneNode(true), true)); $d->formatOutput = true; } $this->logger->logge("%", array($d)); return $d; }
function __construct() { parent::__construct(); $this->texte = ""; $this->pourcentage = 0; $this->flag_country = false; $this->flag_capitale = false; $this->flag_asie = false; $this->flag_eligible = false; $this->xml_string = ""; $imp = new DOMImplementation(); $dtd = $imp->createDocumentType('liste-pays', '', 'liste-pays.dtd'); $this->xml = $imp->createDocument("", "", $dtd); $this->xml->encoding = 'UTF-8'; $this->xml->standalone = false; $this->xml_liste_pays = $this->xml->createElement("liste-pays"); $this->xml->appendChild($this->xml_liste_pays); }
public static function generateTmx() { $languageRowSet = Centurion_Db::getSingleton('translation/language')->all(); $translationTable = Centurion_Db::getSingleton('translation/translation'); $uidTable = Centurion_Db::getSingleton('translation/uid'); foreach ($languageRowSet as $languageRow) { $implementation = new DOMImplementation(); $dtd = $implementation->createDocumentType('tmx', '', 'http://www.lisa.org/fileadmin/standards/tmx14.dtd.txt'); $dom = $implementation->createDocument('', '', $dtd); $dom->encoding = 'UTF-8'; $dom->version = '1.0'; $dom->formatOutput = true; $root = $dom->createElement('tmx'); $root->setAttribute('version', '1.4'); $header = $dom->createElement('header'); $header->setAttribute('creationtool', 'Centurion'); $header->setAttribute('creationtoolversion', '1.0.0'); $header->setAttribute('datatype', 'winres'); $header->setAttribute('segtype', 'sentence'); $header->setAttribute('adminlang', 'en-us'); $header->setAttribute('srclang', 'en-us'); $header->setAttribute('o-tmf', 'abc'); $root->appendChild($header); $body = $dom->createElement('body'); $select = $uidTable->select(false)->reset(Zend_Db_Select::COLUMNS)->from(array('a' => 'translation_uid', 'a.uid'))->setIntegrityCheck(false)->join(array('b' => 'translation_translation'), 'b.uid_id = a.id and b.language_id = ' . $languageRow->id, 'b.translation'); $translationRowset = $uidTable->fetchAll($select); foreach ($translationRowset as $translationRow) { $tu = $dom->createElement('tu'); $tu->setAttribute('tuid', $translationRow->uid); $tuv = $dom->createElement('tuv'); $tuv->setAttribute('xml:lang', $languageRow->locale); $seg = $dom->createElement('seg'); $seg->appendChild($dom->createCDATASection(null !== $translationRow->translation ? $translationRow->translation : $translationRow->uid)); $tuv->appendChild($seg); $tu->appendChild($tuv); $body->appendChild($tu); } $root->appendChild($body); $dom->appendChild($root); $dom->save(Centurion_Config_Manager::get('resources.translate.data') . DIRECTORY_SEPARATOR . sprintf("%s.xml", $languageRow->locale)); } }
public function __construct() { $imp = new \DOMImplementation(); $dtd = $imp->createDocumentType('yml_catalog', '', 'shops.dtd'); $dom = $imp->createDocument("", "", $dtd); $dom->encoding = 'UTF-8'; $root = $dom->createElement('yml_catalog'); $root->setAttribute('date', date('Y-m-d H:i')); $shop = $dom->createElement('shop'); // ShopName $shop->appendChild($dom->createElement('name'))->appendChild($dom->createTextNode(self::SHOP_NAME)); // ShopUrl $shop->appendChild($dom->createElement('url'))->appendChild($dom->createTextNode(self::SHOP_URL)); // Offers $offers = $dom->createElement('offers'); $shop->appendChild($offers); $root->appendChild($shop); $dom->appendChild($root); $this->setDom($dom)->setOffers($offers); }