/** * This function is executed by the compiler during the third compilation stage, * linking. */ public function preLink(Opt_Compiler_Class $compiler) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE)); // Display the prolog and DTD, if it was set in the node. // Such construct ensures us that they will appear in the // valid place in the output document. if ($this->hasProlog()) { $compiler->appendOutput(str_replace('<?xml', '<<?php echo \'?\'; ?>xml', $this->getProlog()->getProlog())) . "\r\n"; } if ($this->hasDtd()) { $compiler->appendOutput($this->getDtd()->getDoctype() . "\r\n"); } $compiler->setChildren($this); }
/** * This function is executed by the compiler during the third compilation stage, * linking. */ public function preLink(Opt_Compiler_Class $compiler) { if ($compiler->isNamespace($this->getNamespace())) { // This code handles the XML elements that represent the // OPT instructions. They have shorter code, because // we do not need to display their tags. if (!$this->hasChildren() && $this->get('single')) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE, Opt_Xml_Buffer::TAG_SINGLE_BEFORE)); } elseif ($this->hasChildren()) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE, Opt_Xml_Buffer::TAG_OPENING_BEFORE, Opt_Xml_Buffer::TAG_OPENING_AFTER, Opt_Xml_Buffer::TAG_CONTENT_BEFORE)); $compiler->setChildren($this); } else { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE, Opt_Xml_Buffer::TAG_OPENING_BEFORE, Opt_Xml_Buffer::TAG_OPENING_AFTER, Opt_Xml_Buffer::TAG_CONTENT_BEFORE)); } } else { // This code is executed for normal tags that must be rendered. // The first thing is to check if we are a root node, because we must add the "xmlns" // attributes there. /* if($this->get('rootNode') === true) { if(!$this->getParent() instanceof Opt_Xml_Root) { throw new Opt_APIInvalidParent_Exception($this->getType(), $this->getParent()->getType(), 'Opt_Xml_Root'); } foreach($this->getParent()->getNamespaces() as $prefix => $uri) { $newAttr = new Opt_Xml_Attribute($prefix, $uri); $newAttr->setNamespace('xmlns'); $this->addAttribute($newAttr); } } */ // Now construct the output code... $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE, Opt_Xml_Buffer::TAG_OPENING_BEFORE)); if ($this->bufferSize(Opt_Xml_Buffer::TAG_NAME) == 0) { $name = $this->getXmlName(); } elseif ($this->bufferSize(Opt_Xml_Buffer::TAG_NAME) == 1) { $name = $this->buildCode(Opt_Xml_Buffer::TAG_NAME); } else { throw new Opt_CompilerCodeBufferConflict_Exception(1, 'TAG_NAME', $this->getXmlName()); } if (!$this->hasChildren() && $this->bufferSize(Opt_Xml_Buffer::TAG_CONTENT) == 0 && $this->get('single')) { $compiler->appendOutput('<' . $name . $this->_linkAttributes() . ' />' . $this->buildCode(Opt_Xml_Buffer::TAG_SINGLE_AFTER, Opt_Xml_Buffer::TAG_AFTER)); } else { $compiler->appendOutput('<' . $name . $this->_linkAttributes() . '>' . $this->buildCode(Opt_Xml_Buffer::TAG_OPENING_AFTER)); $this->set('_name', $name); if ($this->bufferSize(Opt_Xml_Buffer::TAG_CONTENT) > 0) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_CONTENT_BEFORE, Opt_Xml_Buffer::TAG_CONTENT, Opt_Xml_Buffer::TAG_CONTENT_AFTER)); } elseif ($this->hasChildren()) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_CONTENT_BEFORE)); $compiler->setChildren($this); } } } }
/** * This function is executed by the compiler during the third compilation stage, * linking. */ public function preLink(Opt_Compiler_Class $compiler) { $compiler->appendOutput($this->buildCode(Opt_Xml_Buffer::TAG_BEFORE)); $compiler->setChildren($this); }