protected function loadParticles(dom\element $el) { foreach ($el->getChildren() as $child) { $particle = $this->parseComponent($child); $this->addParticle($particle); } }
protected function parseComponentRoot(dom\element $el, $bParse = false, $bDebug = true) { $children = $el->getChildren(); if (!$children->length) { if ($bDebug) { $this->launchException('Empty component not allowed', get_defined_vars()); } $mResult = null; } else { if ($children->length > 1) { $mResult = $this->parseChildren($children); } else { $mResult = $this->parseNode($el->getFirst()); } } return $bParse ? $this->getWindow()->parse($mResult) : $mResult; }
protected function loadElementUnknown(dom\element $el) { $aContent = $this->parseChildren($el->getChildren()); return $aContent; }
protected function mergeElementComplex(dom\element $current, dom\element $import) { foreach ($import->getChildren() as $child) { if ($child->getNamespace() === $this->getNamespace('self')) { continue; } else { if ($el = $current->getx("{$child->getName()}", array(), false)) { $this->mergeElement($el, $child); } } } foreach ($current->getChildren() as $child) { $import->add($child); } return $current->replace($import); }
protected function browseSchemaChild(dom\element $parent, $sNamespace) { $sResult = ''; foreach ($parent->getChildren() as $child) { if ($child->getType() !== $child::COMMENT) { $sName = $this->addSchemaChild($child, $sNamespace); if (!$sResult && $sName) { $sResult = $sName; } } } return $sResult; }
public function includeElement(dom\element $el, dom\element $ext = null) { $sPrefixes = 'extension-element-prefixes'; if ($this->isEmpty()) { $this->throwException(sprintf('Cannot import in empty template')); } if ($sResult = $el->getAttribute($sPrefixes)) { if ($sTarget = $this->getAttribute($sPrefixes)) { $aTarget = explode(' ', $sTarget); $aResult = $aPrefixes = array_diff(explode(' ', $sResult), $aTarget); } else { $aTarget = array(); $aResult = $aPrefixes = explode(' ', $sResult); } foreach ($aPrefixes as $iPrefix => $sPrefix) { if (!$this->getNamespace($sPrefix)) { if ($sNamespace = $el->getNamespace($sPrefix)) { // TODO to add a namespace $this->setAttribute($sPrefix . ':ns', 'null', $sNamespace); // $this->setAttribute('xmlns:'.$sPrefix, $sNamespace); } else { unset($aResult[$iPrefix]); } } } $this->setAttribute($sPrefixes, implode(' ', array_merge($aResult, $aTarget))); } if ($ext) { switch ($ext->getName(true)) { case 'include': $ext->replace($el->getChildren()); break; case 'import': $this->add($el->getChildren()); break; default: $this->throwException(sprintf('Cannot import document in empty template with %s', $ext->asToken())); } } else { $this->shift($el->getChildren()); } }