/** * The Construct * * @param string $filename * @param arrray $arguments * * @return SiteQ_Report_AbstractReport */ public function __construct($filename, $arguments) { parent::__construct($filename, $arguments); $this->_document = new DOMDocument(); $this->_root = $this->_document->createElement('siteq'); $this->_document->appendChild($this->_root); }
/** * Constructor * * @return void * @access public * @since 1/17/08 */ public function __construct() { $this->doc = new Harmoni_DOMDocument('1.0', 'UTF-8'); $this->doc->appendChild($this->doc->createElement('rss')); $this->doc->documentElement->setAttribute('version', "2.0"); $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:excerpt', 'http://wordpress.org/export/1.1/excerpt/'); $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:content', 'http://purl.org/rss/1.0/modules/content/'); $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:wfw', 'http://wellformedweb.org/CommentAPI/'); $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $this->doc->documentElement->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:wp', 'http://wordpress.org/export/1.1/'); $this->channel = $this->doc->documentElement->appendChild($this->doc->createElement('channel')); // create some comment placeholders for organizing our elements $this->channel->appendChild($this->doc->createComment("Begin - Meta")); $this->endMeta = $this->channel->appendChild($this->doc->createComment("End - Meta")); $this->channel->appendChild($this->doc->createComment("Begin - Authors")); $this->endAuthors = $this->channel->appendChild($this->doc->createComment("End - Authors")); $this->channel->appendChild($this->doc->createComment("Begin - Categories")); $this->endCategories = $this->channel->appendChild($this->doc->createComment("End - Categories")); $this->channel->appendChild($this->doc->createComment("Begin - Tags")); $this->endTags = $this->channel->appendChild($this->doc->createComment("End - Tags")); $this->channel->appendChild($this->doc->createComment("Begin - Files")); $this->endFiles = $this->channel->appendChild($this->doc->createComment("End - Files")); $this->channel->insertBefore($this->getElement('generator', 'http://segue.middlebury.edu/'), $this->endMeta); $this->xpath = new DOMXPath($this->doc); $this->xpath->registerNamespace('wp', 'http://wordpress.org/export/1.1/'); }
/** * {@inheritdoc} */ public function prepare() { $this->xml = new \DOMDocument(); $this->rootNode = $this->xml->createElement($this->rootNodeName); $this->xml->appendChild($this->rootNode); return $this; }
public function build() { $this->doc = new \DOMDocument('1.0', 'UTF-8'); if ($this->structure) { $this->doc->appendChild($this->doc->importNode(dom_import_simplexml($this->structure), true)); } }
/** * @param DOMDocument $documentXml * @param DOMDocument $parent */ public function generateXML($documentXml, $parent) { if ($this->getType() == EiDataSetStructure::$TYPE_NODE) { $element = $documentXml->createElement($this->getEiDataSetStructure()->getXMLTag()); /** @var Doctrine_Node_NestedSet $node */ $node = $this->getNode(); /** @var EiTestSetDataSet[] $descendants */ $descendants = $node->getDescendants(1); if ($descendants !== false) { /** @var EiTestSetDataSet $leaf */ foreach ($descendants as $leaf) { if ($leaf->getType() == EiDataSetStructure::$TYPE_LEAF) { $leaf->generateXML($documentXml, $element); } } } $parent->appendChild($element); if ($descendants !== false) { // On parcours les fils. /** @var EiNodeDataSet $child */ foreach ($node->getDescendants(1) as $child) { if ($child->getType() == EiDataSetStructure::$TYPE_NODE) { // On génère l'élément XSD relatif au noeud fils. $child->generateXML($documentXml, $element); } } } } else { $element = $documentXml->createElement($this->getEiDataSetStructure()->getXMLTag(), htmlspecialchars($this->getValue())); $parent->appendChild($element); } }
/** * Creates a new xml sitemag generator */ function __construct() { $this->domDoc = new \DOMDocument("1.0", "utf-8"); $this->domDoc->formatOutput = true; $this->CreateUrlset(); $this->domDoc->appendChild($this->urlset); }
/** * */ public function run() { $nRecords = mysqli_query($this->conn, 'SELECT COUNT(*) AS `qty` FROM `data`;')->fetch_object()->qty; $xml = new DOMDocument("1.0"); $xml->formatOutput = true; $xml->encoding = 'UTF-8'; $root = $xml->appendChild(new DOMElement('records')); $pBar = new ProgressBar($nRecords); $totalCost = 0; $offset = 0; while ($offset < $nRecords) { $record = mysqli_query($this->conn, 'SELECT * FROM `data` LIMIT 1 OFFSET ' . $offset)->fetch_assoc(); $pid = $record['product_id']; $xmlRecord = $root->appendChild(new DOMElement('record')); $xmlRecord->setAttribute('id', $record['id']); $xmlRecord->appendChild(new DOMElement('product_id', $pid)); $xmlRecord->appendChild(new DOMElement('cost', $record['cost'])); $product = $this->getRecord($pid); $productRatio = isset($product['product_ratio']) ? $product['product_ratio'] : 0; $familyRatio = isset($product['family_ratio']) ? $product['family_ratio'] : 0; $realCost = $record['cost'] * $productRatio * $familyRatio; $xmlRecord->appendChild(new DOMElement('relative_cost', $realCost)); $xmlRecord->appendChild(new DOMElement('product_name', $product['product_name'])); $xmlRecord->appendChild(new DOMElement('family_id', $product['family_id'])); $xmlRecord->appendChild(new DOMElement('family_name', $product['family_name'])); $totalCost += $realCost; $offset++; $pBar->updateValue($offset); } print "\n"; $xml->appendChild(new DOMElement('total_cost', $totalCost)); print $xml->saveXML(); print sprintf("this script lasted %d seconds !\n", intval(date("U") - $this->startTime)); }
/** * Recuperer la configuration au format XML. */ public function saveXML() { $existing = array(); $attributes = $this->domdocument->getElementsByTagName('attribute'); foreach ($attributes as $attribute) { $existing[$attribute->getAttribute('name')] = $attribute; } if ($this->domdocument->getElementsByTagName('config')->item(0) == null) { $root = $this->domdocument->createElement('config'); $this->domdocument->appendChild($root); } else { $root = $this->domdocument->getElementsByTagName('config')->item(0); } foreach ($this->config as $attribute => $value) { if (array_key_exists($attribute, $existing)) { $node = $existing[$attribute]; } else { $node = $this->domdocument->createElement('attribute'); $root->appendChild($node); $node->setAttribute('name', $attribute); } $node->setAttribute('value', $value); } $configNodes = $root->getElementsByTagName('attribute'); foreach ($configNodes as $node) { if (!array_key_exists($node->getAttribute('name'), $this->config)) { $root->removeChild($node); } } $out = $this->domdocument->saveXML(); return $out; }
public function render() { $dom = $dom = new \DOMDocument('1.0'); $header = $dom->createElement('h1', $this->_name); $dom->appendChild($header); $form = $dom->createElement('form'); $form->setAttribute('action', $this->_action); $form->setAttribute('method', $this->_method); $form->setAttribute('id', $this->_id); if ($this->_enctype != null) { $form->setAttribute('enctype', $this->_enctype); } $dom->appendChild($form); foreach ($this->_fields as $name => $field) { if (($field->type == self::FIELD_INPUT_HIDDEN || $field->type == self::FIELD_NOT_RENDER) && $field->error != null) { $err = $dom->createElement('div', $field->error); $err->setAttribute('class', 'form-field-error'); $dom->insertBefore($err, $form); } if (($rendered = $this->createField($name)->render($dom)) != null) { $form->appendChild($rendered); } } return $dom->saveHTML(); }
/** * Appends the "sortable" js code to the bottom of ajax-Request for the category-products loaded after * changing sort order. * * @param Varien_Event_Observer $observer */ public function addSortableScriptOnGrid(Varien_Event_Observer $observer) { $_block = $observer->getBlock(); $_type = $_block->getType(); if (Mage::helper('ffuenf_categoryproductsortbackend')->isExtensionActive() && $_type == 'adminhtml/catalog_category_tab_product') { $content = $observer->getTransport()->getHtml(); $dom = new DOMDocument('1.0', 'utf-8'); $doc = new DOMDocument('1.0', 'utf-8'); $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); foreach ($dom->getElementsByTagName('select') as $element) { if ($element->getAttribute('name') == 'limit') { $option = $dom->createElement('option'); $option->appendChild($dom->createTextNode('All')); $option->setAttribute('value', 0); $option = $element->appendChild($option); } } $additionalHtml = $this->appendScript($content); $additionalDoc = new DOMDocument(); $additionalDoc->loadHTML($additionalHtml); $additionalDocScript = $additionalDoc->getElementsByTagName('script')->item(0); $body = $dom->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $doc->appendChild($doc->importNode($child, true)); } $doc->appendChild($doc->importNode($additionalDocScript, true)); $content = $doc->saveHTML(); $observer->getTransport()->setHtml($content); } }
private function createUrlSet() { $this->dom = new \DOMDocument('1.0', 'UTF-8'); $this->urlset = $this->dom->createElement("urlset"); $this->urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $this->dom->appendChild($this->urlset); }
/** * @param ModelInterface $model * * @return \DOMDocument */ public function serialize(ModelInterface $model) { $this->dom = new \DOMDocument('1.0'); $this->dom->formatOutput = true; $element = $this->visitModel($model); $this->dom->appendChild($element); return $this->dom; }
/** * Initializes this exporter. * * @return void */ public function initialize() { $this->xml = new \DOMDocument('1.0', 'utf-8'); $this->xml->formatOutput = true; $document_element = new \DOMElement('project'); $this->xml->appendChild($document_element); $document_element->setAttribute('version', \phpDocumentor\Application::VERSION); $document_element->setAttribute('title', $this->parser->getTitle()); }
/** * Constructor. * * @param mixed $out * @param bool $reportUselessTests */ public function __construct($out = null, $reportUselessTests = false) { $this->document = new DOMDocument('1.0', 'UTF-8'); $this->document->formatOutput = true; $this->root = $this->document->createElement('testsuites'); $this->document->appendChild($this->root); parent::__construct($out); $this->reportUselessTests = $reportUselessTests; }
/** * Dumps a single Schema model into an XML formatted version. * * @param Schema $schema The schema object * @param boolean $doFinalInitialization Whether or not to validate the schema * @return string */ public function dumpSchema(Schema $schema, $doFinalInitialization = true) { $rootNode = $this->document->createElement('app-data'); $this->document->appendChild($rootNode); foreach ($schema->getDatabases($doFinalInitialization) as $database) { $this->appendDatabaseNode($database, $rootNode); } return trim($this->document->saveXML()); }
/** * Constructor. * * @param mixed $out * @param bool $logIncompleteSkipped */ public function __construct($out = null, $logIncompleteSkipped = false) { $this->document = new DOMDocument('1.0', 'UTF-8'); $this->document->formatOutput = true; $this->root = $this->document->createElement('testsuites'); $this->document->appendChild($this->root); parent::__construct($out); $this->logIncompleteSkipped = $logIncompleteSkipped; }
/** * @param string|resource $out */ public function __construct($out = null) { $this->document = new DOMDocument('1.0', 'UTF-8'); $this->document->formatOutput = true; $this->root = $this->document->createElement('tests'); $this->document->appendChild($this->root); $this->prettifier = new PHPUnit_Util_TestDox_NamePrettifier(); parent::__construct($out); }
/** * */ public function __construct() { $this->document = new \DOMDocument('1.0', 'UTF-8'); $this->document->formatOutput = true; $documentElement = $this->document->createElementNS('http://www.openarchives.org/OAI/2.0/', "OAI-PMH"); $documentElement->setAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/'); $documentElement->setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", 'xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd'); $this->document->appendChild($documentElement); }
function createCCR($action, $raw = "no", $requested_by = "") { $authorID = getUuid(); $patientID = getUuid(); $sourceID = getUuid(); $oemrID = getUuid(); $result = getActorData(); while ($res = sqlFetchArray($result[2])) { ${"labID{$res['id']}"} = getUuid(); } $ccr = new DOMDocument('1.0', 'UTF-8'); $e_styleSheet = $ccr->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="stylesheet/ccr.xsl"'); $ccr->appendChild($e_styleSheet); $e_ccr = $ccr->createElementNS('urn:astm-org:CCR', 'ContinuityOfCareRecord'); $ccr->appendChild($e_ccr); /////////////// Header require_once "createCCRHeader.php"; $e_Body = $ccr->createElement('Body'); $e_ccr->appendChild($e_Body); /////////////// Problems $e_Problems = $ccr->createElement('Problems'); require_once "createCCRProblem.php"; $e_Body->appendChild($e_Problems); /////////////// Alerts $e_Alerts = $ccr->createElement('Alerts'); require_once "createCCRAlerts.php"; $e_Body->appendChild($e_Alerts); ////////////////// Medication $e_Medications = $ccr->createElement('Medications'); require_once "createCCRMedication.php"; $e_Body->appendChild($e_Medications); ///////////////// Immunization $e_Immunizations = $ccr->createElement('Immunizations'); require_once "createCCRImmunization.php"; $e_Body->appendChild($e_Immunizations); /////////////////// Results $e_Results = $ccr->createElement('Results'); require_once "createCCRResult.php"; $e_Body->appendChild($e_Results); /////////////////// Procedures //$e_Procedures = $ccr->createElement('Procedures'); //require_once("createCCRProcedure.php"); //$e_Body->appendChild($e_Procedures); //////////////////// Footer // $e_VitalSigns = $ccr->createElement('VitalSigns'); // $e_Body->appendChild($e_VitalSigns); /////////////// Actors $e_Actors = $ccr->createElement('Actors'); require_once "createCCRActor.php"; $e_ccr->appendChild($e_Actors); if ($action == "generate") { gnrtCCR($ccr, $raw, $requested_by); } if ($action == "viewccd") { viewCCD($ccr, $raw, $requested_by); } }
public function build() { $this->doc = new \DOMDocument('1.0', 'UTF-8'); $dom_root = $this->doc->createElement('document'); $dom_root->setAttribute('debug', $this->getConfigValue('site.debug')); $dom_root->setAttribute('url', (string) E()->getRequest()->getURI()); $this->doc->appendChild($dom_root); $dom_documentProperties = $this->doc->createElement('properties'); $dom_root->appendChild($dom_documentProperties); $prop = $this->doc->createElement('property', E()->getSiteManager()->getCurrentSite()->base); $prop->setAttribute('name', 'base'); $prop->setAttribute('folder', E()->getSiteManager()->getCurrentSite()->folder); $dom_documentProperties->appendChild($prop); $prop = $this->doc->createElement('property', $langID = E()->getLanguage()->getCurrent()); $prop->setAttribute('name', 'lang'); $prop->setAttribute('abbr', E()->getRequest()->getLangSegment()); $prop->setAttribute('real_abbr', E()->getLanguage()->getAbbrByID($langID)); $dom_documentProperties->appendChild($prop); unset($prop); $result = $this->doc->createElement('errors'); $result->setAttribute('xml:id', 'result'); $dom_root->appendChild($result); $vm = E()->getController()->getViewMode(); if ($vm == DocumentController::TRANSFORM_JSON) { $errors = [['message' => $this->e->getMessage()]]; $data = ['result' => false, 'errors' => $errors]; $result->appendChild(new \DOMText(json_encode($data))); } else { $error = $this->doc->createElement('error'); $result->appendChild($error); $error->appendChild($this->doc->createElement('message', $this->e->getMessage())); $error->setAttribute('file', $this->e->getFile()); $error->setAttribute('line', $this->e->getLine()); $bktrace = $this->doc->createElement('backtrace'); $dbgObj = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT, 5); array_walk($dbgObj, function ($callable) use($bktrace) { $bktrace->appendChild($call = $this->doc->createElement('call')); array_walk($callable, function ($value, $key) use($call) { if (is_scalar($value)) { $call->appendChild($this->doc->createElement($key, $value)); } elseif (is_array($value)) { foreach ($value as $k1 => $v1) { if (!is_scalar($v1)) { $v1 = '[...]'; } $call->appendChild($this->doc->createElement($key, $v1)); } } }); }); $result->appendChild($bktrace); if ($vm == DocumentController::TRANSFORM_HTML) { E()->getController()->getTransformer()->setFileName('error_page.xslt'); } } }
/** * Returns the HEAD element, or creates one if it doesn't exist. * * @return DOMElement HEAD element. */ public function getHead() { $head = $this->dom->getElementsByTagName('head'); if ($head->length) { return $head->item(0); } $headelt = $this->dom->createElement('head'); $this->dom->appendChild($headelt); return $headelt; }
/** * @param string $painFormat Supported format: 'pain.001.002.03', 'pain.001.001.03', 'pain.008.002.02', 'pain.008.001.02' */ function __construct($painFormat) { $this->painFormat = $painFormat; $this->doc = new \DOMDocument('1.0', 'UTF-8'); $this->doc->formatOutput = true; $this->root = $this->doc->createElement('Document'); $this->root->setAttribute('xmlns', sprintf("urn:iso:std:iso:20022:tech:xsd:%s", $painFormat)); $this->root->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $this->doc->appendChild($this->root); }
public function __construct() { // create a new dom object $this->oDocument = new DOMDocument('1.0', 'UTF-8'); $this->oDocument->formatOutput = true; // add a root node with the name specified in the implementing class $this->oRootNode = $this->oDocument->createElement($this->sRootNodeName); $this->oRootNode->setAttribute('xmlns', $this->sXMLNamespace); $this->oDocument->appendChild($this->oRootNode); }
/** * Creates a new JUnit file. * * The file will be initialized with an XML definition and the root element. * * @param string $name The filename (without extension) and default value of the name attribute * @param array $testsuitesAttributes Attributes for the root element */ public function createNewFile($name, array $testsuitesAttributes = array()) { $this->setFileName(strtolower(trim(preg_replace('/[^[:alnum:]_]+/', '_', $name), '_'))); $this->domDocument = new \DOMDocument(self::XML_VERSION, self::XML_ENCODING); $this->domDocument->formatOutput = true; $this->testSuites = $this->domDocument->createElement('testsuites'); $this->domDocument->appendChild($this->testSuites); $this->addAttributesToNode($this->testSuites, array_merge(array('name' => $name), $testsuitesAttributes)); $this->flush(); }
/** * Setup the XML document */ public function __construct() { // XML document $this->_xml = new DOMDocument('1.0', Kohana::$charset); // Attributes $this->_xml->formatOutput = TRUE; // Root element $this->_root = $this->_xml->createElement('urlset'); // Append to XML document $this->_xml->appendChild($this->_root); }
/** * Construct a new instance. * * @param string[] $array * @param string $rootElementName * @param bool $replaceSpacesByUnderScoresInKeyNames * * @throws DOMException */ public function __construct(array $array, $rootElementName = '', $replaceSpacesByUnderScoresInKeyNames = true) { $this->document = new DOMDocument(); $this->replaceSpacesByUnderScoresInKeyNames = $replaceSpacesByUnderScoresInKeyNames; if ($this->isArrayAllKeySequential($array) && !empty($array)) { throw new DOMException('Invalid Character Error'); } $root = $this->document->createElement($rootElementName == '' ? 'root' : $rootElementName); $this->document->appendChild($root); $this->convertElement($root, $array); }
/** * Constructor. * * @param \DOMNode $node The node associated with this field */ public function __construct(\DOMNode $node) { $this->node = $node; $this->name = $node->getAttribute('name'); $this->document = new \DOMDocument('1.0', 'UTF-8'); $this->node = $this->document->importNode($this->node, true); $root = $this->document->appendChild($this->document->createElement('_root')); $root->appendChild($this->node); $this->xpath = new \DOMXPath($this->document); $this->initialize(); }
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); }
function foo() { echo "Enter foo()\n"; $dom = new DOMDocument(); $dom->registerNodeClass('DOMElement', 'MyElement'); $child = $dom->createElement('foo')->init(); $dom->appendChild($child); $dom->appendChild($dom->createElement('bar')->init()); echo "Leave foo()\n"; return [$dom, $child]; }
/** * SitemapGen constructor. */ public function __construct() { $this->dom = new DOMDocument(); $this->dom->formatOutput = true; $this->root = $this->dom->createElement("urlset"); $this->dom->appendChild($this->root); $rootAttr = $this->dom->createAttribute('xmlns'); $this->root->appendChild($rootAttr); $rootAttrText = $this->dom->createTextNode('http://www.sitemaps.org/schemas/sitemap/0.9'); $rootAttr->appendChild($rootAttrText); }