/** * 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'); } }
public function visit(\DOMElement $node, Compiler $context) { if ($node->hasAttribute("from-exp")) { $filename = $node->getAttribute("from-exp"); } elseif ($node->hasAttribute("from")) { $filename = '"' . $node->getAttribute("from") . '"'; } else { throw new Exception("The 'from' or 'from-exp' attribute is required"); } // remove any non-element node foreach (iterator_to_array($node->childNodes) as $child) { if (!$child instanceof \DOMElement) { $child->parentNode->removeChild($child); } } $context->compileChilds($node); $code = "embed {$filename}"; if ($node->hasAttribute("ignore-missing") && $node->hasAttribute("ignore-missing") !== false) { $code .= " ignore missing"; } if ($node->hasAttribute("with")) { $code .= " with " . $node->getAttribute("with"); } if ($node->hasAttribute("only") && $node->getAttribute("only") !== "false") { $code .= " only"; } $ext = $context->createControlNode($code); $set = iterator_to_array($node->childNodes); $n = $node->ownerDocument->createTextNode("\n"); array_unshift($set, $n); array_unshift($set, $ext); $set[] = $context->createControlNode("endembed"); DOMHelper::replaceWithSet($node, $set); }
/** * Initialize an EndpointType. * * @param DOMElement|NULL $xml The XML element we should load. * @throws Exception */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('Binding')) { throw new Exception('Missing Binding on ' . $xml->tagName); } $this->Binding = $xml->getAttribute('Binding'); if (!$xml->hasAttribute('Location')) { throw new Exception('Missing Location on ' . $xml->tagName); } $this->Location = $xml->getAttribute('Location'); if ($xml->hasAttribute('ResponseLocation')) { $this->ResponseLocation = $xml->getAttribute('ResponseLocation'); } foreach ($xml->attributes as $a) { if ($a->namespaceURI === NULL) { continue; /* Not namespace-qualified -- skip. */ } $fullName = '{' . $a->namespaceURI . '}' . $a->localName; $this->attributes[$fullName] = array('qualifiedName' => $a->nodeName, 'namespaceURI' => $a->namespaceURI, 'value' => $a->value); } }
public function parse(DOMElement $element) { if ($element->hasAttribute('variable')) { $this->variable = $element->getAttribute('variable'); } if ($element->hasAttribute('value')) { $this->value = $element->getAttribute('value'); } for ($i = 0; $i < $element->childNodes->length; $i++) { $childElement = $element->childNodes->item($i); if ($childElement->parentNode !== $element) { continue; } if ($childElement instanceof DOMComment || $childElement instanceof DOMText) { continue; } switch ($childElement->nodeName) { case 'from': $this->part = new Ezer_XmlAssignStepFromAttribute($childElement); break; default: throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName); } } }
/** * Creates a ref-mark as the first element of the given $odtElement, based * on the ID attribute of the given $docbookElement. * * @param DOMElement $docbookElement * @param DOMElement $odtElement */ protected function createRefMark(DOMElement $docbookElement, DOMElement $odtElement) { // Work around for DocBook inconsistency in using ID or id. id // would be correct, if one follows the specs here… if ($docbookElement->hasAttribute('ID') || $docbookElement->hasAttribute('id')) { $refMark = $odtElement->insertBefore($odtElement->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:reference-mark'), $odtElement->firstChild); $refMark->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:name', $docbookElement->hasAttribute('ID') ? $docbookElement->getAttribute('ID') : $docbookElement->getAttribute('id')); } }
/** * Parse font family. * @param DOMElement $node */ public function parse(DOMElement $node) { $this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : ''; $this->name = $node->hasAttribute(IdmlAttributes::Name) ? $node->getAttribute(IdmlAttributes::Name) : ''; $fontNodes = $node->getElementsByTagName('Font'); foreach ($fontNodes as $fontNode) { $font = new IdmlFont(); $font->parse($fontNode); $font->fontFamily = $this; $this->fonts[] = $font; } }
/** * Initialize a saml:BaseID, either from scratch or from an existing \DOMElement. * * @param \DOMElement|null $xml The XML element we should load, if any. */ public function __construct(\DOMElement $xml = null) { if ($xml === null) { return; } $this->element = $xml; if ($xml->hasAttribute('NameQualifier')) { $this->NameQualifier = $xml->getAttribute('NameQualifier'); } if ($xml->hasAttribute('SPNameQualifier')) { $this->SPNameQualifier = $xml->getAttribute('SPNameQualifier'); } }
public function visit(\DOMElement $node, Compiler $context) { $code = "use "; if ($node->hasAttribute("from")) { $code .= '"' . $node->getAttribute("from") . '"'; } else { throw new Exception("The 'from' attribute is required"); } if ($node->hasAttribute("with")) { $code .= " with " . $node->getAttribute("with"); } $pi = $context->createControlNode($code); $node->parentNode->replaceChild($pi, $node); }
/** * Create/parse a mdrpi:RegistrationInfo element. * * @param \DOMElement|null $xml The XML element we should load. * @throws \Exception */ public function __construct(\DOMElement $xml = null) { if ($xml === null) { return; } if (!$xml->hasAttribute('registrationAuthority')) { throw new \Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.'); } $this->registrationAuthority = $xml->getAttribute('registrationAuthority'); if ($xml->hasAttribute('registrationInstant')) { $this->registrationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('registrationInstant')); } $this->RegistrationPolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'RegistrationPolicy'); }
/** * Create/parse a mdrpi:RegistrationInfo element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('registrationAuthority')) { throw new Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.'); } $this->registrationAuthority = $xml->getAttribute('registrationAuthority'); if ($xml->hasAttribute('registrationInstant')) { $this->registrationInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('registrationInstant')); } $this->RegistrationPolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'RegistrationPolicy'); }
/** * @param \DOMElement $xml * @throws \AerialShip\LightSaml\Error\InvalidXmlException */ function loadFromXml(\DOMElement $xml) { $name = $this->getXmlNodeName(); if ($xml->localName != $name || $xml->namespaceURI != Protocol::NS_METADATA) { throw new InvalidXmlException("Expected {$name} element and " . Protocol::NS_METADATA . ' namespace but got ' . $xml->localName); } if (!$xml->hasAttribute('Binding')) { throw new InvalidXmlException("Missing Binding attribute"); } if (!$xml->hasAttribute('Location')) { throw new InvalidXmlException("Missing Location attribute"); } $this->setBinding($xml->getAttribute('Binding')); $this->setLocation($xml->getAttribute('Location')); }
public function parse(DOMElement $element) { $this->class = $element->getAttribute('class'); if ($element->hasAttribute('args')) { $this->args[] = $element->getAttribute('args'); } for ($i = 0; $i < $element->childNodes->length; $i++) { $childElement = $element->childNodes->item($i); if ($childElement->parentNode !== $element) { continue; } if ($childElement instanceof DOMComment || $childElement instanceof DOMText) { continue; } switch ($childElement->nodeName) { case 'args': $this->parseArgs($childElement); break; case 'targets': case 'sources': // already handled by Ezer_XmlStepUtil break; default: throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName); } } }
/** * Initialize a KeyInfo element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if ($xml->hasAttribute('Id')) { $this->Id = $xml->getAttribute('Id'); } for ($n = $xml->firstChild; $n !== NULL; $n = $n->nextSibling) { if (!$n instanceof DOMElement) { continue; } if ($n->namespaceURI !== XMLSecurityDSig::XMLDSIGNS) { $this->info[] = new SAML2_XML_Chunk($n); continue; } switch ($n->localName) { case 'KeyName': $this->info[] = new SAML2_XML_ds_KeyName($n); break; case 'X509Data': $this->info[] = new SAML2_XML_ds_X509Data($n); break; default: $this->info[] = new SAML2_XML_Chunk($n); break; } } }
/** * Create a IDPEntry element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('ProviderID')) { throw new Exception('Missing required attribute "ProviderID" in <samlp:IDPEntry>.'); } $this->ProviderID = $xml->getAttribute('ProviderID'); if ($xml->hasAttribute('Name')) { $this->Name = $xml->getAttribute('Name'); } if ($xml->hasAttribute('Loc')) { $this->Loc = $xml->getAttribute('Loc'); } }
/** * Get an elements class/id weight. Uses regular expressions to tell if this * element looks good or bad. * * @param DOMElement $e * @return number (Integer) */ public function getClassWeight($e) { if (!$this->flagIsActive(self::FLAG_WEIGHT_CLASSES)) { return 0; } $weight = 0; if (preg_match($this->regexps['negative'], $e->tagName)) { $weight -= 250; } if (preg_match($this->regexps['positive'], $e->tagName)) { $weight += 250; } /* Look for a special ID */ if ($e->hasAttribute('id') && $e->getAttribute('id') != '') { if (preg_match($this->regexps['negative'], $e->getAttribute('id'))) { $weight -= 150; } if (preg_match($this->regexps['positive'], $e->getAttribute('id'))) { $weight += 150; } } /* Look for a special classname */ if ($e->hasAttribute('class') && $e->getAttribute('class') != '') { $classes = explode(" ", $e->getAttribute('class')); foreach ($classes as $class) { if (preg_match($this->regexps['negative'], $class)) { $weight -= 25; } if (preg_match($this->regexps['positive'], $class)) { $weight += 25; } } } return $weight; }
protected function get_id(\DOMElement $heading) { if (!$heading->hasAttribute('id')) { return $this->sanitize_id_with_dashes($heading->nodeValue); } return $heading->getAttribute('id'); }
/** * Create/parse a mdrpi:PublicationInfo element. * * @param \DOMElement|null $xml The XML element we should load. * @throws \Exception */ public function __construct(\DOMElement $xml = null) { if ($xml === null) { return; } if (!$xml->hasAttribute('publisher')) { throw new \Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.'); } $this->publisher = $xml->getAttribute('publisher'); if ($xml->hasAttribute('creationInstant')) { $this->creationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('creationInstant')); } if ($xml->hasAttribute('publicationId')) { $this->publicationId = $xml->getAttribute('publicationId'); } $this->UsagePolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'UsagePolicy'); }
/** * Read a data attribute from the attached node. * * @param string $name * @return mixed */ public function __get($name) { $name = $this->encodeName($name); if ($this->_node->hasAttribute($name)) { return $this->decodeValue($this->_node->getAttribute($name)); } return NULL; }
public function match(GoogleDom $dom, \DOMElement $node) { if ($node->hasAttribute('id') && $node->getAttribute('id') == 'imagebox_bigimages') { return self::RULE_MATCH_MATCHED; } else { return self::RULE_MATCH_NOMATCH; } }
/** * Create/parse a mdrpi:PublicationInfo element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('publisher')) { throw new Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.'); } $this->publisher = $xml->getAttribute('publisher'); if ($xml->hasAttribute('creationInstant')) { $this->creationInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('creationInstant')); } if ($xml->hasAttribute('publicationId')) { $this->publicationId = $xml->getAttribute('publicationId'); } $this->UsagePolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'UsagePolicy'); }
public function initFromXmlNode(DOMElement $node) { $this->selected = $node->getAttribute('selected') == 'true'; $this->text = trim($node->textContent); if ($node->hasAttribute('customAnswer')) { $this->customAnswer = trim($node->getAttribute('customAnswer')); } }
/** * Filter a single element * * @param DOMElement $element * @return void */ public function filterElement(DOMElement $element) { $element->setProperty('type', 'orderedlist'); $types = array('a' => 'loweralpha', 'A' => 'upperalpha', 'i' => 'lowerroman', 'I' => 'upperroman'); if ($element->hasAttribute('type') && isset($types[$type = $element->getAttribute('type')])) { $element->setProperty('attributes', array('numeration' => $types[$type])); } }
public static function checkRequiredAttributes(\DOMElement $element, array $attributes) { foreach ($attributes as $name) { if (!$element->hasAttribute($name)) { throw new InvalidXmlException('XML Element ' . $element->localName . ' missing required attribute ' . $name); } } }
/** * Initialize an EndpointType. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('Binding')) { throw new Exception('Missing Binding on ' . $xml->tagName); } $this->Binding = $xml->getAttribute('Binding'); if (!$xml->hasAttribute('Location')) { throw new Exception('Missing Location on ' . $xml->tagName); } $this->Location = $xml->getAttribute('Location'); if ($xml->hasAttribute('ResponseLocation')) { $this->ResponseLocation = $xml->getAttribute('ResponseLocation'); } }
/** * Handle a node * * Handle / transform a given node, and return the result of the * conversion. * * @param ezcDocumentElementVisitorConverter $converter * @param DOMElement $node * @param mixed $root * @return mixed */ public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root) { if (!$node->hasAttribute('class') || $node->getAttribute('class') !== 'normal') { $root .= preg_replace('(\\r\\n|\\r|\\n)', "\n ", $node->textContent) . "\n"; } else { $root .= "\n| " . preg_replace('(\\r\\n|\\r|\\n)', "\n| ", $node->textContent) . "\n"; } return $root; }
/** * Remove blacklisted styles from node inline styles * * @param DOMElement $infobox infobox node * @return DOMNode node with removed styles from blacklist */ public function clearInfoboxStyles(DOMElement $infobox) { if ($infobox->hasAttribute('style')) { $styles = $infobox->getAttribute('style'); $styles = $this->removeBlacklistedProperties($styles); $infobox->setAttribute('style', $styles); } return $infobox; }
public function initFromXmlNode(DOMElement $node) { if ($node->hasAttribute('value')) { $text = $node->getAttribute('value'); } else { $text = $node->textContent; } $this->value = $text ? trim($text) : ''; }
/** * Handle a node * * Handle / transform a given node, and return the result of the * conversion. * * @param ezcDocumentElementVisitorConverter $converter * @param DOMElement $node * @param mixed $root * @return mixed */ public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root) { if ($node->hasAttribute('Role') && $node->getAttribute('Role') === 'strong') { $marker = '**'; } else { $marker = '*'; } return $root . ' ' . $marker . $converter->visitChildren($node, '') . $marker; }
/** * 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); } }
/** * @param \DOMElement $element * @return int */ public function parseElement(\DOMElement $element) { if ($element->hasAttribute(CodepointAssignedParser::ATTR_CODEPOINT)) { return 1; } $first = hexdec($element->getAttribute(CodepointAssignedParser::ATTR_CODEPOINT_FIRST)); $last = hexdec($element->getAttribute(CodepointAssignedParser::ATTR_CODEPOINT_LAST)); return $last - $first + 1; }