/** * Create a PAOS Request element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) { throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.'); } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') { throw new Exception('Invalid value of soap-env:mustUnderstand attribute in <paos:Request>.'); } if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) { throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.'); } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') { throw new Exception('Invalid value of soap-env:actor attribute in <paos:Request>.'); } if (!$xml->hasAttribute('responseConsumerURL')) { throw new Exception('Missing responseConsumerURL attribute in <paos:Request>.'); } $this->responseConsumerURL = $xml->getAttribute('responseConsumerURL'); if (!$xml->hasAttribute('service')) { throw new Exception('Missing service attribute in <paos:Request>.'); } $this->service = $xml->getAttribute('service'); if ($xml->hasAttribute('messageID')) { $this->messageID = $xml->getAttribute('messageID'); } }
/** * Basic check of the given XML, it is not part of __construct in order to reduce NPath Complexity * * @param DOMElement|NULL $xml The XML element we should check before loading. */ public function checkXML(DOMElement $xml) { if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) { return 'Missing soap-env:mustUnderstand attribute in <ecp:Request>.'; } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') { return 'Invalid value of soap-env:mustUnderstand attribute in <ecp:Request>.'; } if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) { return 'Missing soap-env:mustUnderstand attribute in <ecp:Request>.'; } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') { return 'Invalid value of soap-env:actor attribute in <ecp:Request>.'; } return TRUE; }
/** * @param DOMElement $element * @param array $style * @return array */ function parseStyles(DOMElement $element, $style = array()) { if ($element->hasAttributeNS($this->ttsNS, 'fontWeight') && $element->getAttributeNS($this->ttsNS, 'fontWeight') == 'bold') { $style['bold'] = true; } if ($element->hasAttributeNS($this->ttsNS, 'fontStyle') && $element->getAttributeNS($this->ttsNS, 'fontStyle') == 'italic') { $style['italic'] = true; } $copiedAtts = array('textAlign', 'displayAlign', 'color', 'backgroundColor', 'fontFamily', 'fontSize'); foreach ($copiedAtts as $copiedAtt) { if ($element->hasAttributeNS($this->ttsNS, $copiedAtt)) { $style[$copiedAtt] = $element->getAttributeNS($this->ttsNS, $copiedAtt); } } return $style; }
/** * Create a ECP RelayState element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) { throw new Exception('Missing soap-env:mustUnderstand attribute in <ecp:RelayState>.'); } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') { throw new Exception('Invalid value of soap-env:mustUnderstand attribute in <ecp:RelayState>.'); } if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) { throw new Exception('Missing soap-env:mustUnderstand attribute in <ecp:RelayState>.'); } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') { throw new Exception('Invalid value of soap-env:actor attribute in <ecp:RelayState>.'); } $this->RelayState = $xml->textContent; }
/** * Required by the ArrayAccess interface. * * @param string $offset * @return boolean */ public function offsetExists($offset) { if (strpos($offset, ':') !== false) { list($ns, $attr) = explode(':', $offset, 2); return $this->_element->hasAttributeNS(Zend_Feed::lookupNamespace($ns), $attr); } else { return $this->_element->hasAttribute($offset); } }
/** * Validate if an attribute exists * * @param string $name * @return bool */ public function hasAttribute($name) { list($namespace, $localName) = $this->resolveTagName($name); if ($namespace != '') { return parent::hasAttributeNS($namespace, $localName); } else { return parent::hasAttribute($name); } }
private function isElementValueNull(\DOMElement $element) { $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance'; if (!$element->hasAttributeNS($namespaceUri, 'nil')) { return false; } return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil'); }
public function getChildAttribute(\DOMElement $node) { $name = $node->getAttributeNS($this->namespaces['sv'], 'name'); $type = strtolower($node->getAttributeNS($this->namespaces['sv'], 'type')); $values = array(); if ($name == 'jcr:created') { $values[] = date(self::DATEFORMAT); } else { foreach ($node->getElementsByTagNameNS($this->namespaces['sv'], 'value') as $nodeValue) { $values[] = $nodeValue->nodeValue; } } $isMultiValue = false; if ($name == 'jcr:mixinTypes' || count($values) > 1 || $node->hasAttributeNS($this->namespaces['sv'], 'multiple') && $node->getAttributeNS($this->namespaces['sv'], 'multiple') == 'true') { $isMultiValue = true; } return array($name, array('type' => $type, 'value' => $values, 'multiValued' => $isMultiValue)); }
/** * @param \DOMElement $node * @return string */ private function getType(\DOMElement $node) { if ($node->hasAttributeNS(self::XMLNS_JSONDOM, 'type')) { return $node->getAttributeNS(self::XMLNS_JSONDOM, 'type'); } else { $xpath = new Xpath($node->ownerDocument); return $xpath('count(*) > 0', $node) ? 'object' : 'string'; } }
/** * Parses the provided XML element object and stores it as a feed textinput in * the provided ezcFeed object. * * @param ezcFeed $feed The feed object in which to store the parsed XML element as a feed textinput * @param DOMElement $xml The XML element object to parse */ private function parseTextInput(ezcFeed $feed, DOMElement $xml = null) { $textInput = $feed->add('textInput'); if ($xml !== null) { foreach ($xml->childNodes as $itemChild) { if ($itemChild->nodeType == XML_ELEMENT_NODE) { $tagName = $itemChild->tagName; switch ($tagName) { case 'title': case 'description': case 'name': case 'link': $textInput->{$tagName} = $itemChild->textContent; break; } } } if ($xml->hasAttributeNS(self::NAMESPACE_URI, 'about')) { $textInput->about = $xml->getAttributeNS(self::NAMESPACE_URI, 'about'); } } }
/** * Get a attribute value * * @param DOMElement $nod * @param string $name * @param string $ns * @return string */ public function get_attr_value(&$nod, $name, $ns = null) { return is_null($ns) ? $nod->hasAttribute($name) ? $nod->getAttribute($name) : null : ($nod->hasAttributeNS($ns, $name) ? $nod->getAttributeNS($ns, $name) : null); }
/** * Returns the list style name of the given $odtElement. * * Recursively searches for the style name of the given list element. The * style name is only present at the top most list (for nested lists). * * @param DOMElement $odtElement * @return string */ protected function getListStyleName(DOMElement $odtElement) { if ($odtElement->namespaceURI === ezcDocumentOdt::NS_ODT_TEXT && $odtElement->localName === 'list' && $odtElement->hasAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'style-name')) { return $odtElement->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'style-name'); } if ($odtElement->parentNode === null) { throw new RuntimeException('No list style name found.'); } return $this->getListStyleName($odtElement->parentNode); }
/** * Parses a list level style. * * Parses the given $listLevelElement and returns a corresponding * list-level style object. * * @param DOMElement $listLevelElement * @return ezcDocumentOdtListLevelStyle */ protected function parseListLevel(DOMElement $listLevelElement) { if (!isset(self::$listClassMap[$listLevelElement->localName])) { throw new RuntimeException("Unknown list-level element {$listLevelElement->localName}."); } $listLevelClass = self::$listClassMap[$listLevelElement->localName]; $listLevel = new $listLevelClass($listLevelElement->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'level')); foreach (self::$listAttributeMap[$listLevelElement->localName] as $ns => $attrs) { foreach ($attrs as $xmlAttr => $objAttr) { if ($listLevelElement->hasAttributeNS($ns, $xmlAttr)) { $listLevel->{$objAttr} = $listLevelElement->getAttributeNS($ns, $xmlAttr); } } } return $listLevel; }
/** * @param \DOMElement $node * @return string */ private function getName(\DOMElement $node) { if ($node->hasAttributeNS(self::XMLNS_JSONDOM, 'name')) { return $node->getAttributeNS(self::XMLNS_JSONDOM, 'name'); } else { return $node->localName; } }
protected function parseScriptTask($id, \DOMElement $el, BusinessProcessBuilder $builder) { if ($el->hasAttributeNS(self::NS_IMPL, 'resource')) { $scriptTask = $builder->scriptResourceTask($id, $el->getAttributeNS(self::NS_IMPL, 'resource'), $el->getAttribute('name')); } else { $script = ''; foreach ($this->xpath->query('m:script', $el) as $scriptElement) { $script .= $scriptElement->textContent; } $scriptTask = $builder->scriptTask($id, $el->getAttribute('scriptFormat'), $script, $el->getAttribute('name')); } $scriptTask->setDocumentation($builder->stringExp($this->getDocumentation($el))); $scriptTask->setAsyncBefore($this->getAsyncBefore($el)); $scriptTask->setAsyncAfter($this->getAsyncAfter($el)); if ($el->hasAttributeNS(self::NS_IMPL, 'resultVariable')) { $scriptTask->setResultVariable($el->getAttributeNS(self::NS_IMPL, 'resultVariable')); } return $scriptTask; }